ゆるい開発と学習の記録。Modern C++を中心に、学習目的で作成したプロジェクトを公開しています。 誰かの参考になれば嬉しいです。
このハブサイトは、以下の機能を提供します:
- 自動メタデータ収集: GitHub Actions で各プロジェクトの README.md からメタデータを自動収集
- プロジェクト一覧表示: 番号順・Stars順・更新日順でソート可能
- 検索・フィルタ: タイトル、説明、タグで検索、カテゴリ・難易度でフィルタ
- 統計情報: プロジェクト数、カテゴリ数、総Stars数を自動集計
sumimi.github.io/
├── index.html # メインページ
├── projects.json # プロジェクトメタデータ(自動生成)
├── projects-list.txt # 収集対象リポジトリリスト
├── .github/
│ └── workflows/
│ └── update-projects.yml # メタデータ自動更新
├── scripts/
│ └── fetch-metadata.py # メタデータ収集スクリプト
└── assets/
├── css/
│ └── style.css
└── js/
└── app.js
- Git がインストールされていること
- Python 3.7 以上がインストールされていること
- GitHubアカウントを持っていること
Python パッケージをインストールします:
pip install requests pyyamlcd /path/to/sumimi.github.io
git add .
git commit -m "Initial commit: Hub site setup"
git remote add origin https://github.com/sumimi/sumimi.github.io.git
git branch -M main
git push -u origin main- GitHubリポジトリの Settings > Pages に移動
- Source を
mainブランチの/rootに設定 - Save をクリック
数分後、 https://sumimi.github.io/ でサイトが公開されます。
初回公開時は projects.json を生成する必要があります:
方法1: ローカルで生成(推奨)
python3 scripts/fetch-metadata.py
git add projects.json
git commit -m "Add initial projects metadata"
git push方法2: GitHub Actions で生成
- https://github.com/sumimi/sumimi.github.io/actions に移動
- 「Update Projects Metadata」ワークフローを選択
- 「Run workflow」をクリック
projects-list.txt に新しいプロジェクトのリポジトリを追加:
echo "sumimi/new-project" >> projects-list.txt
git add projects-list.txt
git commit -m "Add new project"
git pushGitHub Actions が自動的にメタデータを収集します。
各プロジェクトの README.md には、以下の形式でメタデータを記述:
<!--
---
number: 001
id: project-id
slug: project-slug
title: "プロジェクトタイトル"
subtitle_ja: "日本語サブタイトル"
subtitle_en: "English Subtitle"
description_ja: "日本語の説明"
description_en: "English description"
category_ja:
- カテゴリ名
category_en:
- Category
difficulty: 2
tags:
- tag1
- tag2
- tag3
repo_url: "https://github.com/user/repo"
demo_url: "https://user.github.io/repo/"
hub: true
---
-->GitHub Actions により、以下のタイミングでメタデータが自動更新されます:
- 定期実行: 毎日 0:00 UTC(日本時間 9:00)
- 手動実行: GitHub の Actions タブから実行可能
- 自動実行:
projects-list.txtまたはscripts/fetch-metadata.pyが更新された時
# 依存関係をインストール(初回のみ)
pip install requests pyyaml
# メタデータ収集を実行
python3 scripts/fetch-metadata.py
# 生成された projects.json を確認
cat projects.json | jq . # jq がインストールされている場合# Python の簡易サーバーを起動
python3 -m http.server 8000
# ブラウザで開く
# http://localhost:8000このプロジェクトには、以下のセキュリティ対策が実装されています:
- XSS対策: すべてのユーザーデータをHTMLエスケープ
- URLサニタイゼーション: 危険なURLスキーム(
javascript:,data:など)をブロック - CSP(Content Security Policy): 厳格なポリシーで外部リソースを制限
- Reverse Tabnabbing対策: 外部リンクに
rel="noopener noreferrer"を設定
- 入力検証: メタデータの型チェック・長さ制限・範囲制限
- URLプロトコル検証: http/https のみ許可
- 安全なYAMLパース:
yaml.safe_load()を使用
- 最小権限の原則: GitHub Actions の権限を必要最小限に制限
- トークン管理: 環境変数とSecrets で適切に管理
原因: projects.json が存在しないか、正しく生成されていない
解決方法:
-
ローカルでメタデータを生成:
python3 scripts/fetch-metadata.py git add projects.json git commit -m "Add projects metadata" git push -
または GitHub Actions を手動実行:
- https://github.com/sumimi/sumimi.github.io/actions
- 「Update Projects Metadata」を実行
原因: .gitignore に projects.json が含まれている
解決方法: .gitignore から projects.json の行を削除してください。このファイルはGitHub Pagesで必須です。
# ユーザー環境にインストール
pip install --user requests pyyaml
# または仮想環境を使用
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install requests pyyaml- Actions タブで詳細なエラーログを確認
- Permissions が正しく設定されているか確認:
- Settings > Actions > General > Workflow permissions
- 「Read and write permissions」を選択
⚠️ .gitignoreに含めないでください- このファイルはGitHub Pagesで必須です
- GitHub Actions が自動生成しますが、Git に追跡される必要があります
- ワークフローには
contents: write権限が必要です projects.jsonを自動コミットするために使用されます
projects.json の構造:
{
"generated_at": "2026-02-22T09:00:00+09:00",
"total_count": 1,
"projects": [
{
"number": 1,
"id": "modern-cpp-template-learnkit",
"title": "Modern C++ Template LearnKit",
"subtitle_ja": "Modern C++学習用プロジェクトテンプレート",
"category_ja": ["C++/テンプレート"],
"difficulty": 2,
"tags": ["cpp17", "cmake", "googletest"],
"repo_url": "https://github.com/sumimi/modern-cpp-template-learnkit",
"stars": 0,
"forks": 0,
"updated_at": "2026-02-22T00:00:00Z"
}
]
}MIT License