发布Walrus站点

现在一切都已安装和配置,您应该可以开始发布您的第一个 Walrus Site!

选择站点的源材料

site-builder 通过将任何 web 框架生成的文件目录上传到 Walrus 并将相关元数据添加到 Sui 来工作。此目录的根目录中应有一个名为 index.html 的文件,该文件将是 Walrus Site 的入口点。

在本教程的其余部分中,我们将以 ./examples/snake 中包含的简单站点为例。

发布站点

由于我们已将 walrus 二进制文件和配置放置在默认位置,发布 ./examples/snake 站点就像调用发布命令一样简单:

./target/release/site-builder publish ./examples/snake --epochs 100

Tip

Currently on Walrus testnet, the duration of an epoch is 1 day. If you want your site to stay up longer, specify the number of epochs with the --epochs flag!

Note

The site builder will look for the default configuration file sites-config.yaml in the ./walrus-sites directory. In case you are calling the site-builder command from a different location, use the --config flag to specify the path to the configuration file.

输出的末尾应如下所示:

Execution completed
Resource operations performed:
  - created resource /Oi-Regular.ttf with blob ID 76npyqDyGF10-jP_ov-UBHpi-RaRFnxcWgslueGEfr0
  - created resource /file.svg with blob ID w70pYgtLmi--38Jg1sTGaLlZkQtximNMHXjxDQdXKa0
  - created resource /index.html with blob ID LVLk9VSnBrEgQ2HJHAgU3p8IarKypQpfn38aSeUZzzE
  - created resource /walrus.svg with blob ID 866UDjMAy_BB8SsTcgjGEOFp2uAO9BbcVbLh5-_oBNE
The site routes were modified

Created new site: test site
New site object ID: 0x407a308190eb82b266be9cc28b888d04c5b2e5a503c7d0ffd3f69681ea83b73a
Browse the resulting site at: https://1lupgq2auevjruy7hs9z7tskqwjp5cc8c5ebhci4v57qyl4piy.walrus.site

此输出告诉您,对于文件夹中的每个文件,创建了一个新的 Walrus blob 及其相应的 blob ID。此外,它还打印了 Sui 上 Walrus Site 对象的对象 ID(因此您可以在资源管理器中查看并使用它来设置 SuiNS 名称),最后是您可以浏览站点的 URL。

请注意,这里我们将默认配置 ./sites-config.yaml 作为 site builder 的配置。配置文件是必要的,以确保 site-builder 知道 Walrus Sites 逻辑的正确 Sui 包。

有关 site-builder 配置的更多详细信息,请参见 高级配置 部分。

更新站点

假设现在您想更新站点的内容,例如将标题从 "eat all the blobs!" 更改为 "Glob all the Blobs!"。

首先,在 ./examples/snake/index.html 文件中进行此编辑。

然后,您可以通过运行 update 命令来更新现有站点,提供找到更新文件的目录(仍然是 ./example/snake)和现有站点的对象 ID (0x407a3081...):

./target/release/site-builder update --epochs 100 examples/snake  0x407a3081...

这次的输出应为:

Execution completed
Resource operations performed:
  - deleted resource /index.html with blob ID LVLk9VSnBrEgQ2HJHAgU3p8IarKypQpfn38aSeUZzzE
  - created resource /index.html with blob ID pcZaosgEFtmP2d2IV3QdVhnUjajvQzY2ev8d9U_D5VY
The site routes were left unchanged

Site object ID: 0x407a308190eb82b266be9cc28b888d04c5b2e5a503c7d0ffd3f69681ea83b73a
Browse the resulting site at: https://1lupgq2auevjruy7hs9z7tskqwjp5cc8c5ebhci4v57qyl4piy.walrus.site

publish 操作相比,我们可以看到现在执行的唯一操作是删除旧的 index.html,并用更新的文件更新它。

浏览提供的 URL 应反映更改。您已更新站点!

Note

The wallet you are using must be the owner of the Walrus Site object to be able to update it.

Extending the expiration date of an existing site

To extend the expiration date of a previously-stored site, use the update command with the --force flag, and specify the number of additional epochs (from the current epoch) with the --epochs flag.