完全版(単一ファイル)ビルドスクリプトを追加#12
Merged
Merged
Conversation
各章の index.html から shared/ の CSS・JS とローカル画像を インライン化し、dist/<章名>.html として 1 ファイルに生成する build.py。 リポジトリ・ネット接続なしで開ける配布/オフライン閲覧用。 - build.py: Python 3 標準ライブラリのみ。NN-* 章を自動検出 - 正本は各章 index.html(shared/ 参照版)のまま。dist/ は git 管理外 - progress-strip.js は readyState 自前ガードのため defer 除去でも安全 - Web フォント(Google Fonts @import)は埋め込まない(既知の制約) - .gitignore に dist/ を追加。lecture.html→index.html の旧コメントも訂正 - README に「完全版をビルドする」手順を追記 No-Issue: 配布・オフライン閲覧用の単一ファイル生成 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CodeQL py/bad-tag-filter(high)の指摘に対応。`</script>` リテラルが `</script >`(空白入り)や大文字に非対応だったため、`</\s*script\s*>` + re.IGNORECASE に変更。 No-Issue: PR #12 の CodeQL 指摘修正 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
script 要素全体(<script>...</script>)をマッチする正規表現は CodeQL に 脆弱なタグフィルタと判定される。開始タグ <script src="..."> だけを 置換し、元の </script> をそのまま閉じタグとして再利用する方式に変更。 あわせて、インライン化する JS 内の "</script" を "<\/script" に無害化 (HTML パーサの誤クローズ防止。JS 上は等価)。 No-Issue: PR #12 の CodeQL 指摘修正(再対応) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 22, 2026
watanabe-kohei-jp
added a commit
that referenced
this pull request
May 22, 2026
## 何をしているか
main への push で `python build.py` を CI で実行し、生成された
完全版 HTML (`dist/*.html`) を既存リポと一緒に Pages にデプロイ。
これまで「ローカルでビルドして手動配布」だった完全版が、Pages 上の
URL(`co-lect.github.io/lectures/dist/<章名>.html`)として常に
最新版が公開され、右クリック → 保存でダウンロードできるようになる。
## 変更
- `.github/workflows/pages-deploy.yml` (新規)
- main push でビルド + デプロイ。PR では build-only で破損検出
- `_site/` に編集用(リポ全体)+ 完全版(`dist/*.html`)を rsync で詰める
- 既存の編集用 URL(章フォルダ、`shared/`、`sitemap.xml` 等)は維持
- `build.py`
- 完全版 HTML の `</head>` 直前に `<link rel="canonical">` と
`<meta name="robots" content="noindex, follow">` を自動挿入
- 重複コンテンツ対策。検索エンジンには編集用 URL を正本として扱わせる
- `README.md`
- 「完全版を入手する」セクションを Pages 経由のダウンロード手順に拡張
- 取り扱い注意(dist/ を直接編集しない・force-add しない)を明文化
## 設計判断
- **`_site` パターン採用**: Pages 設定を「Actions」に切り替えると、
artifact に含めなかった既存 URL は消える。rsync で `.git` `.github`
`dist` `_site` のみ除外して残りを全部 `_site/` に入れることで、
編集用 URL の互換性を保つ
- **`dist/` は引き続き git 管理外**: CI が生成・配信するため、リポに
入れる必要なし。PR #12 で確立した不変条件を維持
- **canonical/noindex を build.py 側で注入**: ワークフローではなく
ビルドスクリプトで仕込むことで、ローカルビルドした完全版にも同じ
メタが入る(手元配布版でも検索エンジン的に安全)
- **PR ジョブは build-only**: 外部 PR で deploy 権限を持たせない
## デプロイ前に必要な手動作業
Settings → Pages → Source を「GitHub Actions」に切り替える必要あり
(現状は「Deploy from a branch」想定)。切替後は本ワークフローが
唯一のデプロイ経路になる。
## 動作確認(ローカル)
- `python build.py` で 4 章すべて [OK]、size 妥当
- 全章に canonical / robots=noindex が `</head>` 直前に挿入されることを確認
Closes #33
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: watanabe-kohei-jp <283722319+watanabe-kohei-jp@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
各章のスライドをオフラインで開いたり、1 ファイルで配布・共有したいというニーズへの対応。現状の各章
index.htmlはshared/の CSS・JS と_assets/画像を相対参照しており、単体では完結しない。変更
build.py(新規)— 各章index.htmlから、shared/theme.css/deck-stage.js/progress-strip.jsと画像(qr.svg/_assets/*.png)をインライン化し、dist/<章名>.htmlとして単一ファイルを生成NN-*形式の章を自動検出(新章追加でも変更不要)index.html(shared/参照版)のまま。dist/はビルド成果物.gitignore—dist/を追加(生成物は管理外)。あわせてlecture.html→index.htmlの旧コメントを訂正README.md— 「完全版をビルドする」手順を追記設計判断
shared/単一正本の思想を維持し、dist/はビルド生成dist/を commit するかdefer除去の安全性progress-strip.jsはreadyStateを自前ガード、deck-stage.jsは head 配置で問題なし@importは埋め込まない(JP フォント実体は数 MB 級)。完全オフラインではシステムフォントにフォールバック(レイアウトは不変)ビルド結果(ローカル検証済み)
外部ローカル参照(
..//_assets/)の残存ゼロを確認。No-Issue: 配布・オフライン閲覧用の単一ファイル生成
🤖 Generated with Claude Code