feat: add wiki publishing tooling
This commit is contained in:
@@ -97,6 +97,32 @@ docker compose up --build
|
||||
- 根目录已经补上 .gitignore,避免后续再次提交 .env
|
||||
- 如果 .env 已经在 Git 索引里,.gitignore 不会自动取消跟踪,需要你本地手动把它移出索引后再提交
|
||||
|
||||
## Wiki.js 资产与页面发布记录
|
||||
|
||||
Wiki.js 页面发布使用 `scripts/wiki_update_page.py`,图片上传使用 `scripts/wiki_upload_assets.py`。发布 HTML 页面时,页面内 `<style>` 应通过 `--extract-style-to-script-css` 写入 Wiki.js 页面 CSS;页面内 `<script>` 应通过 `--extract-script-to-script-js` 写入页面 JS。Wiki.js 会把 `scriptJs` 原样注入页面 body,因此发布脚本会保留完整 `<script>...</script>` 包裹。
|
||||
|
||||
曾出现所有图片 URL 返回 `500 Internal Server Error`,但数据库 `assets` / `assetData` 中记录和二进制数据都存在的情况。根因是 Wiki.js 的 storage target `disk` 被启用,但 `config.path` 为空;Wiki.js 的 Local File System storage 要求绝对路径,空路径会导致资产服务读取/缓存文件路径异常。修复方式是通过 Wiki.js GraphQL `storage.updateTargets` 将 `disk` 的路径设为绝对目录 `/wiki/data/storage`,随后执行 `storage.executeAction(targetKey: "disk", handler: "dump")`,并在操作前后临时授予/移除 `manage:system`。
|
||||
|
||||
验证图片时不要只用 `HEAD` 或只查数据库。应实际 `GET` 资产 URL,并确认 HTTP 200、`Content-Type` 为 `image/*`。上传脚本现在默认会做真实 GET 验证,例如:
|
||||
|
||||
```bash
|
||||
python scripts/wiki_upload_assets.py --source-dir data/KSP/wiki-upload-echo-current --file echo_mk2_cross_section.png --folder-slug echo --skip-existing
|
||||
```
|
||||
|
||||
如果 Echo / Enterprise 图片误传到 `/vulture`,先 dry-run 查看目标,再通过官方 `assets.deleteAsset` 删除错放资源。清理脚本只匹配 `/vulture` 下文件名以 `echo_` 或 `enterprise_` 开头的资产,并在操作后移除临时系统权限:
|
||||
|
||||
```bash
|
||||
py scripts/wiki_cleanup_misplaced_assets.py
|
||||
py scripts/wiki_cleanup_misplaced_assets.py --delete
|
||||
py scripts/wiki_verify_asset_cleanup.py
|
||||
```
|
||||
|
||||
六个航天飞机页面的图片点击放大由 `scripts/wiki_apply_image_lightbox.py` 统一注入,发布后可用以下脚本做浏览器级验证:
|
||||
|
||||
```bash
|
||||
py scripts/wiki_verify_lightbox.py
|
||||
```
|
||||
|
||||
## 下一步建议
|
||||
|
||||
1. 把 Communication、Tank、Vehicle Cost 的页面也补成 CRUD
|
||||
|
||||
Reference in New Issue
Block a user