Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions .github/workflow-proposals/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# INACTIVE PROPOSAL. Requires approval before replacing workflows/hugo.yaml.
# Required external settings: main PR protection + required checks + github-pages reviewers.
name: Reviewed Pages release

on:
push:
branches: [main]

permissions:
contents: read

concurrency:
group: pages
cancel-in-progress: false

jobs:
review-gate:
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.11'
- name: Require reviewed PR for this exact commit
env:
GITHUB_TOKEN: ${{ github.token }}
run: python scripts/review_gate.py
validate:
needs: review-gate
uses: ./.github/workflows/quality.yml
permissions:
contents: read
package:
needs: validate
runs-on: ubuntu-24.04
permissions:
contents: read
actions: read
steps:
- name: Download tested artifact
env:
GH_TOKEN: ${{ github.token }}
run: gh run download "$GITHUB_RUN_ID" --repo "$GITHUB_REPOSITORY" --name verified-site --dir site
- uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4
with:
path: site
deploy:
needs: package
runs-on: ubuntu-24.04
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Publish tested artifact after environment approval
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
69 changes: 45 additions & 24 deletions .github/workflows/hugo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ on:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
concurrency:
Expand All @@ -29,44 +27,67 @@ defaults:
jobs:
# Build job
build:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
permissions:
contents: read
pages: read
timeout-minutes: 20
env:
HUGO_VERSION: 0.141.0 # 这里可以指定版本0.141.0,或者删掉这行用默认latest
HUGO_ENV: production
steps:
- name: Install Hugo CLI
run: |
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
- name: Install Dart Sass
run: sudo snap install dart-sass
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
submodules: recursive
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '24'
cache: npm
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.11'
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: .cache/hugo
key: pages-hugo-${{ runner.os }}-${{ hashFiles('toolchain.json') }}-${{ github.sha }}
restore-keys: pages-hugo-${{ runner.os }}-${{ hashFiles('toolchain.json') }}-
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
- name: Install Node.js dependencies
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
- name: Build with Hugo
run: npm ci --ignore-scripts
- name: Install verified Hugo Extended
run: python scripts/install_hugo.py
- name: Install browser
run: npm run browsers -- --with-deps
- name: Validate, build and test
env:
# For maximum backward compatibility with Hugo modules
HUGO_ENVIRONMENT: production
HUGO_ENV: production
run: |
hugo \
--gc \
--minify \
--baseURL "${{ steps.pages.outputs.base_url }}/"
HUGO_BASEURL: "${{ steps.pages.outputs.base_url }}/"
run: npm run verify
- name: Preserve validation reports
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: pages-validation-reports
path: |
reports/
playwright-report/
test-results/
retention-days: 7
if-no-files-found: ignore
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4
with:
path: ./public
path: ./.build/site

# Deployment job
deploy:
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand All @@ -75,4 +96,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4
84 changes: 84 additions & 0 deletions .github/workflows/quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: Blog quality

on:
pull_request:
push:
branches-ignore: [main]
workflow_dispatch:
workflow_call:

permissions:
contents: read

concurrency:
group: quality-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
verify:
name: Verify content and site
runs-on: ubuntu-24.04
timeout-minutes: 20
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
submodules: recursive
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: '24'
cache: npm
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: '3.11'
- uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: .cache/hugo
key: hugo-${{ runner.os }}-${{ hashFiles('toolchain.json') }}-${{ github.sha }}
restore-keys: hugo-${{ runner.os }}-${{ hashFiles('toolchain.json') }}-
- name: Install locked dependencies
run: npm ci --ignore-scripts
- name: Install verified Hugo and audited math assets
run: |
python scripts/install_hugo.py
python scripts/sync_vendor.py
- name: Content and Markdown checks
run: |
python scripts/site.py check
npm run lint
- name: Unit tests
run: |
python -m unittest discover -s tests -v
npm run test:workflows
- name: Dependency and source security
run: |
npm audit --audit-level=low
python scripts/security_check.py
- name: Build and check every local reference
run: |
python scripts/site.py build
python scripts/check_site.py
- name: Install browser
run: npm run browsers -- --with-deps
- name: Browser and accessibility tests
run: npm run test:e2e
- name: Preserve diagnostic reports
if: always()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: quality-reports
path: |
reports/
playwright-report/
test-results/
retention-days: 7
if-no-files-found: ignore
- name: Preserve tested site
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: verified-site
path: .build/site/
retention-days: 3
- name: Summarize failures
if: failure()
run: echo 'Validation failed. Open the first failing step and download quality-reports. Production deployment was not started.' >> "$GITHUB_STEP_SUMMARY"
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/.tools/
/.build/
/.cache/
/assets/lib/katex/
/assets/lib/mermaid/
/resources/_gen/
/node_modules/
/test-results/
/playwright-report/
/reports/*.json
/reports/*.png
/reports/*.log
/.hugo_build.lock
__pycache__/
*.pyc
.env
.env.*
!.env.example
14 changes: 14 additions & 0 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"globs": ["content/**/*.md", "*.md"],
"config": {
"default": true,
"MD013": false,
"MD024": { "siblings_only": true },
"MD025": false,
"MD029": false,
"MD033": false,
"MD041": false,
"MD046": { "style": "fenced" },
"MD060": false
}
}
50 changes: 50 additions & 0 deletions ARCHITECTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# 架构与现状审计

当前界面(2026-10-30):恢复 Blowfish 原生 background 首页,主要发布文章并使用 Tags。分类、项目、友链、写作约定及工作台模板已归档到 archive/,不生成公开页面。下文保留首次重构的审计与决策记录;开发与测试工具继续使用。

审计日期:2026-10-29。工作区为 `D:\hugo`,实际 Git/Hugo 项目根为 `myblog/`;所有开发命令从该目录执行。初始工作区干净,基线提交 `efbb03e`,远程为 `git@github.com:Nizeross/nizeross.github.io.git`,默认分支 `main`。本次仅在本地 `refactor/blog-system` 开发。

## 决策:保留 Hugo + Blowfish

内容使用 Markdown + TOML Frontmatter;Hugo 在构建时生成 HTML、RSS、搜索 JSON。浏览器只加载主题现有库与少量原生 JavaScript,不引入 React、数据库或在线写作 API。Blowfish 子模块固定在 `3a9016a6d93f6d498ab5fc3b0aa7d51869962f25`,所有覆盖位于站点自己的 `layouts/` 和 `assets/`。

换成其他框架对三篇既有文章没有实质收益,却要重做 shortcode、图片处理、搜索和链接兼容。本方案保留 `/posts/<原目录>/`,用首页覆盖和独立 Projects 模板提供辨识度;构建和审核工具独立于主题,未来换主题仍能复用。

## 审计事实

| 项目 | 发现与处理策略 |
| --- | --- |
| 内容 | 三个 leaf bundle,含本地封面。保留文章正文与路径;首篇示例有未闭合代码围栏,修复语法并记录。 |
| 配置 | `config/_default/` 分文件;语言文件标为 English/en 但内容为中文,需修正;全站基础色遵循原生色板,白天纯白、夜间 #1E293B。 |
| 主题 | submodule,无本地改动;要求 Hugo Extended 0.141.0–0.154.5。工作区二进制为非 Extended 0.155.0,线上 workflow 用 Extended 0.141.0,需统一到受支持的 Extended 0.154.5。 |
| 输出 | 仓库根与 `public/` 都有历史生成文件。本次不删除;新本地构建输出到忽略的 `.build/site/`,避免修改这些历史文件。未来在确认后才从 Git 移除旧输出。 |
| 部署 | `.github/workflows/hugo.yaml` push main 后直接部署;整个 workflow 有 Pages 写权限、未做内容检查、Sass 未锁版本、npm 失败被忽略。保留现有 workflow 原样,提供待批准的替换方案。 |
| 域名 | 根 `CNAME` 为 `kirisame.me`;baseURL 仍为用户名地址。不能自行决定哪一个是权威域名,保持配置不变,批准迁移时再核对 Pages base URL。 |
| 远程 | 连接可见的 Nizeross 仓库只有 `nizeross.github.io`,未发现另一个可见用户名站点;这不是对所有私有仓库的证明。GitHub 最近一次部署 efbb03e 成功;读取 rulesets 返回空列表,不能证明已有审核保护。 |
| 安全 | 原 footer 请求第三方访问统计;有注释掉的 Firebase 配置。移除页面统计依赖,清理无效配置;自托管资源,不将在线 AI 设为必需。个人邮箱本来公开,保留用户身份资料。 |

## 数据与控制流

```text
Markdown + 本地图片 → 内容/格式检查 → Hugo → HTML/RSS/JSON
↓
链接、集成与浏览器测试
↓
PR 审核 → main → Pages artifact
```

站点代码:`layouts/`(首页、项目列表、小型扩展)、`assets/css/`(主题色板与排版)、`assets/js/`(阅读进度)。`content/` 是唯一文章来源;archetypes 定义五种文章与项目模板。`scripts/` 提供写作、验证、建议工具。Node 依赖只用于开发检查和浏览器测试;Python 3.11+ 使用标准库解析 TOML、HTML 与本地链接。

## 发布边界

新增 CI 只有 contents:read,不部署。生产 workflow 的建议版本保存在 `.github/workflow-proposals/`,不会被 GitHub 执行。最终需要人工批准替换旧工作流,并配置 main 必须 PR、必需检查、禁止绕过,以及 github-pages 环境审核。代码无法代替服务器端分支保护;未配置前不能声称审核已强制生效。本次不修改默认分支、远程、域名或 Pages 设置,也不推送。

参考:[Blowfish 自定义机制](https://blowfish.page/docs/advanced-customisation/)、[GitHub Pages workflows](https://docs.github.com/en/pages/getting-started-with-github-pages/using-custom-workflows-with-github-pages)、[Hugo 安全配置](https://gohugo.io/configuration/security/)。

## 本地重构落地情况

`home/custom.html` 提供工作台首页,Projects 使用独立列表模板,其余文章保留主题的主体模板。目录、图标、搜索与移动菜单通过小范围站点覆盖修复可访问性问题。`contentType` 用作文章类型字段,避免占用 Hugo 保留的 kind。五种 archetypes 同时支持原生 Hugo 与本地助手。

构建同时隔离 publishDir 与 resourceDir,分别为 `.build/site` 和 `.build/resources`;历史 public/ 与 resources/ 文件不作为新源码。构建前同步锁定的数学资源,并从经 audit 的依赖图重建 Mermaid,随后 Hugo 负责指纹与按需发布。esbuild 只在这一步打包已有图表库,不形成应用框架依赖。

只读 HTTP 核对确认用户名地址返回 200 并跳转 `https://kirisame.me/`,未发现独立占用的第二站点。仍需站点所有者确认后才统一 canonical/baseURL 与正式发布策略。当前方案、实现和验证均保存在本地分支,线上仍为原有版本。
56 changes: 56 additions & 0 deletions DELIVERY_REPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# 本地重构交付报告

2026-10-30 更新:作者选择回归文章博客。已恢复原背景图首页,移除分类、项目展示、友情链接与写作约定,保留 Tags、文章阅读与自动检查。下面的项目展示交付清单为上一轮历史,已撤下内容可从 archive/removed-site-sections/2026-10-30/ 找回。

2026-10-29。本地分支:`refactor/blog-system`;基线:`efbb03e`。本地开发六阶段已完成,生产发布审批尚未执行。

## 可运行的成果

网站保留 Hugo 与固定版本 Blowfish,新增工作台风首页,沿用原头像、站名和明暗色板。首页包含个人介绍、文章/项目入口、五种内容类型和最近更新。Projects 页面展示真实项目、技术栈、仓库、运行截图、过程、收获及后续计划;关于、友情链接和写作约定页面均可访问。

文章具备代码高亮/复制、KaTeX 公式、可折叠目录、标题锚点、图片放大、阅读进度、标签/分类、相关文章、RSS 与基础 SEO。搜索使用本地 JSON 与 Fuse,无需网络 API;输入会等待索引准备完成,结果使用安全文本节点构造。

白天基础背景为纯白,夜间为 #1E293B;顶部栏与文章背景仍使用 Blowfish 自带的透明度和模糊。中文使用系统字体回退,没有引入在线字体或大量动画。移动端菜单支持键盘开启、Escape 和焦点循环。

## 写作与工程工具

- 五类 TOML Frontmatter 模板:技术学习、项目开发、读书笔记、思想随笔、生活记录。
- 写作助手:生成 slug、创建草稿、拒绝覆盖、检查内容/图片、预览、生产构建、展示提交草稿。
- 离线建议:摘要摘取、标签与相关文章候选,输出报告供人工审阅;不调用生成式 API、不修改正文、不执行代码示例。
- 一键 `npm run verify`:执行内容、格式、37 项 Python 测试、3 项 workflow 测试、安全、依赖、构建、内部链接和浏览器验证。失败停在对应阶段,日志保存到 reports/verify.log。

## 实际验证结果

| 项目 | 结果 |
| --- | --- |
| Python 单元测试 | 37 项通过 |
| Workflow 配置测试 | 3 项通过 |
| 浏览器端到端测试 | 桌面/移动端共 8 组通过 |
| 内容、格式、安全、构建 | 通过 |
| 生成页与链接 | 40 个 HTML、1213 个内部引用通过 |
| 旧文章链接 | 3 条全部保留 |
| 基础无障碍 | 受测首页、文章、移动菜单未发现 axe A/AA 违规 |
| 本站依赖审计 | 0 个已知漏洞 |
| 上游主题审计 | 29 个告警包节点,单独记录并处理当前使用的公式/图表运行库 |
| 外链 | 7/8 可访问;知乎 403 保留待人工验证 |

完整证据和复现范围见 [验证记录](reports/validation.md) 与 [安全说明](SECURITY.md)。截图位于 reports/home-desktop-light.png、home-desktop-dark.png、home-mobile-light.png、home-mobile-dark.png 等文件;HTML 报告为 playwright-report/index.html。本地首页测得约 286 KB 的资源(不含 HTML、未压缩传输),未加载公式/图表库。

## 兼容与保留

三个旧文章目录、旧 URL、既有正文、原始图片、主题子模块及历史生成目录均保留。正文只修复未闭合围栏与格式,补充分类/摘要等元数据,没有替作者重写观点。新构建写入 .build,不更新历史根目录 HTML 或 public。

远程 origin、默认分支、CNAME、baseURL、原生产 workflow 和 Pages 设置均未修改,也没有推送、创建远程 PR、合并或部署。本地变更按阶段提交,记录见 MIGRATION_PLAN。

## 尚需批准的上线事项

1. 审阅本地界面与内容。真实项目示例的截图来自本次运行。
2. 确认 `kirisame.me` 为正式权威域名;只读检查已确认用户名地址跳转到该域名,但本次不自行更改 baseURL。
3. 批准替换生产 workflow,并配置 main 分支保护、可信审核者和 github-pages 环境批准。新发布提案位于 `.github/workflow-proposals/pages.yml`,当前不会执行。
4. 明确授权后才能推送重构分支并创建 PR。审核后的部署还需在 GitHub 上验证;不能把本地测试成功当成线上已经发布。

现有生产 workflow 仍会在 main 推送时直接发布,因此正式替换前不要绕过 PR 把本次变更直接推到 main。新方案要求另一名真人审核者批准最终提交;单人维护如何安排审核,需要在启用前明确。

## 下一次打开项目

从 myblog/ 运行 `python scripts/site.py preview` 即可查看本地草稿预览;首次换电脑按 README 安装锁定依赖。先阅读 ARCHITECTURE 了解选择,再按 DEVELOPMENT 写文章,正式上线按 DEPLOYMENT 执行。LEARNING_NOTES 解释其中的 Git、HTTP、静态站点与 CI/CD 原理。
Loading
Loading