创建静态扩展存储库¶
To host your own extensions and leverage Blender update system all that is required is to host a static JSON file that is generated by Blender.
JSON¶
To generate a valid JSON file use the server generate Blender command-line tool:
blender --command extension server-generate --repo-dir=/path/to/packages
This creates an index.json
listing from all the .zip extensions found in the --repo-dir location.
有关详细信息,请阅读生成的 JSON API。
测试¶
To test the generated repository, add a new Remote Repository from the Preferences:
获取扩展 → 存储库 → [+] → 添加扩展存储库
Paste the location of the generated JSON as the URL. So the example
/path/to/packages
would use the:file:///path/to/packages/index.json
on Linux and macOS.file:///C:/path/to/packages/index.json
on Windows.file://HOST/share/path/to/packages/index.json
for network shares on Windows.
Tip
Open file:///
in a web browser and navigate to the repository location
and copy that as the remote repository URL.
Extensions Listing HTML¶
server-generate
命令可以选择使用 --html
参数创建一个简单的网站。
blender --command extension server-generate --repo-dir=/path/to/packages --html
这会创建一个随时可用的 index.html
文件,列出可放入 Blender 安装的扩展。
下载链接¶
为了支持从远程存储库拖放安装,有几种可选的方法来准备 URL。
唯一严格的要求是下载 URL 必须以 .zip
结尾。
你可以将不同的参数传递给 URL,从而为 Blender 提供更多线索来告诉 Blender 如何处理 URL。
- repository:
用于在 Blender 中安装存储库的 JSON 文件链接。支持相对 URL。
- platforms:
以逗号分隔的支持平台列表。如果省略,扩展将适用于所有操作系统。
- blender_version_min:
Blender 的最低支持版本,例如
4.2.0
。- blender_version_max:
扩展不支持的 Blender 版本,支持更早的版本。
Tip
您提供的细节越多,用户体验就越好。
除了 repository
以外,所有其他参数都可以从扩展清单中提取。这些参数将作为 URL 的一部分进行编码。
- 预期的格式:
{URL}.zip?repository={repository}&blender_version_min={version_min}&blender_max={version_max_exclusive}&platforms={platform1,platform2}
- 自托管存储库示例:
http://my-site.com/my-addon.zip?repository=.%2Findex.json&blender_version_min=4.2.0&platforms=windows-x64
- 扩展平台示例:
https://extensions.blender.org/download/sha256:57a6a5f39fa2cc834dc086a27b7b2e572c12fd14f8377fb8bd1c7022df3d7ccb/add-on-amaranth-v1.0.23.zip?repository=%2Fapi%2Fv1%2Fextensions%2F&blender_version_min=4.2.0&platforms=linux-x64%2Cmacos-x64
Note
%2F
and%2C
are simply the url-encoded equivalent of/
and,
respectively.