Skip to content

docs(badges): replace img.shields.io with native self-hosted SVG badges#65

Merged
Agions merged 1 commit into
mainfrom
docs/native-badges
Jun 2, 2026
Merged

docs(badges): replace img.shields.io with native self-hosted SVG badges#65
Agions merged 1 commit into
mainfrom
docs/native-badges

Conversation

@Agions
Copy link
Copy Markdown
Owner

@Agions Agions commented Jun 2, 2026

徽标原生化 (Self-hosted Badges)

移除所有 img.shields.io 第三方徽标服务依赖, 改用 SceneFab 自托管 SVG 徽标

🎯 Why

shields.io 适合原型, 但对 ship 出去的产品有实际风险:

  • 宕机暴露 — shields.io 挂掉 = README 5 个徽标全变红 X
  • 网络依赖 — 离线/防火墙后用户看到破图
  • 隐私泄漏 — 每次 README 浏览都向第三方 CDN 发送带 UA/Referer 请求
  • 风格漂移 — 第三方渲染规则随时可能变
  • 品牌不一致 — 颜色字体不匹配 SceneFab 3 色 logo 系统

🎨 5 个自托管 SVG 徽标

徽标 路径 配色
License: MIT assets/badges/license-mit.svg Indigo 渐变 (#6366F1 → #4F46E5)
Python 3.10+ assets/badges/python.svg Python 蓝 (#41A5DB → #2B7CB3)
PySide6 Qt 6.9 assets/badges/pyside6.svg Qt 绿 (#52C752 → #2E8B2E)
Platform assets/badges/platform.svg 中性灰 (#9CA3AF → #6B7280)
Version v1.1.0 assets/badges/version.svg SceneFab 品牌橙红 (#ff8a5b → #e63946)

统一规格: 28px 高, for-the-badge 风格, Verdana 11px 粗体, 全部含 role="img" + aria-label + <title> (无障碍)

🤖 自动化

新增 scripts/generate_badges.pypyproject.toml 读 version 自动生成 version 徽标:

python scripts/generate_badges.py            # 重新生成
python scripts/generate_badges.py --check    # CI: 不同步则 exit 1

🔧 附带修复 .gitignore

docs/ + assets/ 规则太宽 (阻止任何资源目录被 track), 改为精确 build-output 规则:

  • docs/build/
  • docs/.vitepress/dist/
  • docs/.vitepress/cache/
  • assets/build/
  • assets/dist/

📋 文件清单

  • 5 新徽标 SVG: assets/badges/*.svg
  • 5 同步副本: docs/public/badges/*.svg (VitePress 文档站)
  • 1 新生成脚本: scripts/generate_badges.py
  • README.md: 5 个 shields.io URL → 5 个本地 SVG 路径 + 决策说明 HTML 注释
  • .gitignore: build 规则精确化

✅ 验证

  • 5 个 SVG 全部 XML valid
  • ruff check src/scenefab/ 0 errors
  • generate_badges.py --check v1.1.0 同步
  • rg img.shields.io 无残留
  • README 路径全部 resolve 到 assets/badges/

📋 Post-merge (可选 TODO)

  • 加 pre-commit hook: python scripts/generate_badges.py --check
  • Release workflow 调用 generate_badges.py 自动同步 version 徽标
  • 考虑把 logo + badges 打包成 npm-style icon library

## Why

shields.io is great for prototypes, but for a shipped product it brings
real downsides:

- **Outage exposure** — if shields.io goes down, all 5 badges in our
  README turn into red error icons
- **Network dependency** — offline / CI-behind-firewall users see broken
  images
- **Privacy leak** — every README view sends a request with User-Agent
  and Referer to a third-party CDN
- **Style drift** — third-party rendering can change without notice
- **Brand inconsistency** — the colors/typography don't match our
  SceneFab 3-color logo system

## What changed

5 self-hosted SVG badges under `assets/badges/`, synced to
`docs/public/badges/` for the VitePress docs site:

| Badge | Path | Color story |
|-------|------|-------------|
| License: MIT | license-mit.svg | Indigo gradient (`#6366F1 → #4F46E5`) |
| Python 3.10+ | python.svg | Python blue (`#41A5DB → #2B7CB3`) |
| PySide6 Qt 6.9 | pyside6.svg | Qt green (`#52C752 → #2E8B2E`) |
| Platform | platform.svg | Neutral gray (`#9CA3AF → #6B7280`) |
| Version v1.1.0 | version.svg | **SceneFab brand orange-red** (`#ff8a5b → #e63946`) |

All 5 SVGs:
- 28px tall, for-the-badge style
- Verdana bold 11px text, accessible (role=img + aria-label + <title>)
- Validated as XML

## Automation

`scripts/generate_badges.py` reads the version from `pyproject.toml`
and regenerates `assets/badges/version.svg`:

```bash
python scripts/generate_badges.py            # regenerate
python scripts/generate_badges.py --check    # CI: exit 1 if drift
```

CI integration TODO: add a `make badges` or pre-commit hook so version
bumps always stay in sync.

## .gitignore fix

The previous `docs/` and `assets/` rules were too broad — they
prevented tracking any new resources in those directories. Replaced
with build-output-specific rules (`docs/build/`, `docs/.vitepress/dist/`,
`docs/.vitepress/cache/`, `assets/build/`, `assets/dist/`).

## Files

- 5 new badge SVGs in `assets/badges/`
- 5 sync copies in `docs/public/badges/` (VitePress)
- 1 new generator script: `scripts/generate_badges.py`
- README.md: 5 shields.io URLs → 5 local SVG paths + inline HTML
  comment block documenting the decision
- .gitignore: build-artifact rules narrowed to actual build outputs
@Agions Agions merged commit 5743b98 into main Jun 2, 2026
2 checks passed
@Agions Agions deleted the docs/native-badges branch June 2, 2026 12:01
Agions added a commit that referenced this pull request Jun 2, 2026
)

主人偏好确认: 徽标用业界原生 shields.io (img.shields.io),
不用自定义 SVG.

Changes:
- 删除 10 个自定义 SVG (assets/badges/* + docs/public/badges/*)
- 删除 scripts/generate_badges.py
- 还原 .gitignore (docs/ + assets/ 整个 ignore)
- README.md 改回 shields.io 5 行标准 Markdown 徽标

shields.io 是 GitHub 生态最常用的'原生'徽标方案, 所有顶级
OSS 项目都用 (React, Vue, TensorFlow 等). 自定义 SVG 反而
是偏离惯例.

Refs: PR #65
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant