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
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -384,5 +384,8 @@ ARCHITECTURE.md
_DEAD/

# Build artifacts
docs/
assets/
docs/build/
docs/.vitepress/dist/
docs/.vitepress/cache/
assets/build/
assets/dist/
20 changes: 15 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
> **上传一部电影 → AI 自动完成语义拆条、解说稿、配音、字幕、合成导出**
> 从「几天一条」变成「一天十条」。

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=for-the-badge)](LICENSE)
[![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge&logo=python&logoColor=white)](https://www.python.org/)
[![PySide6](https://img.shields.io/badge/Qt-6.9+-41C845?style=for-the-badge&logo=qt&logoColor=white)](https://qt.io/)
[![Platform](https://img.shields.io/badge/Platform-Win%20%7C%20macOS%20%7C%20Linux-silver?style=for-the-badge)](https://github.com/Agions/scene-fab/releases)
[![Version](https://img.shields.io/badge/v1.1.0-10B981?style=for-the-badge)](https://github.com/Agions/scene-fab/releases)
[![License: MIT](assets/badges/license-mit.svg)](LICENSE)
[![Python](assets/badges/python.svg)](https://www.python.org/)
[![PySide6](assets/badges/pyside6.svg)](https://qt.io/)
[![Platform](assets/badges/platform.svg)](https://github.com/Agions/scene-fab/releases)
[![Version](assets/badges/version.svg)](https://github.com/Agions/scene-fab/releases)

[**在线文档**](https://agions.github.io/scene-fab/) · [**下载安装**](https://github.com/Agions/scene-fab/releases) · [**报告问题**](https://github.com/Agions/scene-fab/issues/new) · [**功能建议**](https://github.com/Agions/scene-fab/discussions)

Expand Down Expand Up @@ -239,3 +239,13 @@ SceneFab 的诞生离不开以下开源项目:
⭐ 如果 SceneFab 对你有帮助,请给一个 Star · 🐛 遇到问题请提交 [Issue](https://github.com/Agions/scene-fab/issues)

</div>

<!--
徽标说明:本仓库 README 中所有徽标均为自托管 SVG(位于 `assets/badges/`),
不依赖任何第三方徽标服务(如 shields.io)。优势:
- 100% 离线可用(无外网请求)
- 零隐私追踪
- 风格与 SceneFab logo 系统统一(橙红渐变对应主题色)
- Version 徽标由 `scripts/generate_badges.py` 自动从 `pyproject.toml` 同步
维护说明:bump 版本时运行 `python scripts/generate_badges.py` 即可。
-->
24 changes: 24 additions & 0 deletions assets/badges/license-mit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions assets/badges/platform.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions assets/badges/pyside6.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions assets/badges/python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions assets/badges/version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions docs/public/badges/license-mit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions docs/public/badges/platform.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions docs/public/badges/pyside6.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions docs/public/badges/python.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions docs/public/badges/version.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions scripts/generate_badges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/usr/bin/env python3
"""Generate SceneFab version badge SVG from pyproject.toml.

Usage:
python scripts/generate_badges.py
python scripts/generate_badges.py --version 1.2.0
python scripts/generate_badges.py --check # CI check (fail if drift)
"""

from __future__ import annotations

import argparse
import re
import sys
from pathlib import Path

ROOT = Path(__file__).resolve().parent.parent
PYPROJECT = ROOT / "pyproject.toml"
BADGE_PATH = ROOT / "assets" / "badges" / "version.svg"


def read_pyproject_version() -> str:
"""Extract `version = "X.Y.Z"` from pyproject.toml."""
if not PYPROJECT.exists():
sys.exit(f"❌ pyproject.toml not found at {PYPROJECT}")
content = PYPROJECT.read_text(encoding="utf-8")
match = re.search(r'^version\s*=\s*"([^"]+)"', content, re.MULTILINE)
if not match:
sys.exit(f"❌ No version field found in {PYPROJECT}")
return match.group(1)


def render_version_badge(version: str) -> str:
"""Render the version badge SVG with the given version string."""
svg = f'''<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="98" height="28" role="img" aria-label="SceneFab v{version}">
<title>SceneFab v{version}</title>
<defs>
<linearGradient id="bgVersion" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#555555"/>
<stop offset="100%" stop-color="#333333"/>
</linearGradient>
<linearGradient id="bgValueVersion" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" stop-color="#ff8a5b"/>
<stop offset="100%" stop-color="#e63946"/>
</linearGradient>
</defs>
<g shape-rendering="crispEdges">
<rect width="44" height="28" rx="4" ry="4" fill="url(#bgVersion)"/>
<rect x="44" width="54" height="28" rx="4" ry="4" fill="url(#bgValueVersion)"/>
<rect x="40" width="8" height="28" fill="url(#bgValueVersion)"/>
</g>
<g font-family="Verdana, Geneva, Tahoma, sans-serif" font-weight="700" font-size="11" text-anchor="middle" fill="#ffffff">
<text x="22" y="18">version</text>
<text x="71" y="18">v{version}</text>
</g>
</svg>
'''
return svg


def main() -> int:
parser = argparse.ArgumentParser(description="Generate SceneFab version badge.")
parser.add_argument(
"--version", help="Override version (default: read from pyproject.toml)"
)
parser.add_argument(
"--check",
action="store_true",
help="CI check: exit 1 if badge is out of sync with pyproject.toml",
)
args = parser.parse_args()

version = args.version or read_pyproject_version()

if args.check:
if not BADGE_PATH.exists():
print(f"❌ Badge not found at {BADGE_PATH}")
return 1
existing = BADGE_PATH.read_text(encoding="utf-8")
expected = render_version_badge(version)
if existing == expected:
print(f"✅ Badge in sync (v{version})")
return 0
print(f"❌ Badge drift: expected v{version}, file is out of sync")
print(f" Run: python scripts/generate_badges.py")
return 1

BADGE_PATH.parent.mkdir(parents=True, exist_ok=True)
BADGE_PATH.write_text(render_version_badge(version), encoding="utf-8")
print(f"✅ Wrote {BADGE_PATH} (v{version})")
return 0


if __name__ == "__main__":
sys.exit(main())
Loading