This commit is contained in:
hashbro
2026-08-09 02:42:45 +08:00
parent e730bba4a5
commit 9153a4f557
9 changed files with 155 additions and 6 deletions
@@ -0,0 +1,10 @@
# support.html templates
Build-time choices for `web/support.html` (`--support-template` / API `support_template`):
| Name | Source | Description |
|------|--------|-------------|
| `test` | campaign copy under `source/web/<id>/support.html` | Current lab HUD progress UI |
| `blank` | `blank.html` in this directory | Same loader scripts, no HUD markup/JS |
Default is `test`.
File diff suppressed because one or more lines are too long
+6 -2
View File
@@ -16,16 +16,20 @@ pip3 install -r requirements.txt
python3 frontend/tools/new_project.py \
--channel-id 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' \
--deployment-domains 'www.dep1.example,www.dep2.example' \
--reporting-domains 'www.rep1.example,www.rep2.example'
--reporting-domains 'www.rep1.example,www.rep2.example' \
--support-template test # test=HUD 进度页;blank=空白页
python3 frontend/tools/new_project.py \
--channel-id 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' \
--root '/srv/coruna-artifacts/staging/request-id' \
--force \
--deployment-domains 'www.dep1.example' \
--reporting-domains 'www.rep1.example'
--reporting-domains 'www.rep1.example' \
--support-template blank
```
`support_template`:`test`(默认,source 中带 HUD 的页面)或 `blank`(去掉 HUD,仅保留加载逻辑)。
产物:
- 默认:`artifacts/channel/<channel-id>/{web,sync,out}/`
+45 -1
View File
@@ -27,6 +27,9 @@ SOURCE_ROOT = FRONTEND_ROOT / "source"
ARTIFACTS_ROOT = PROJECT_ROOT / "artifacts"
LAB_ROOT = FRONTEND_ROOT # cwd / out/ for tooling
ORIGINAL_CHANNEL_ID = "34f5121f572d6742703eb84ec2f866a6"
SUPPORT_TEMPLATES = ("test", "blank")
DEFAULT_SUPPORT_TEMPLATE = "test"
SUPPORT_TEMPLATE_ROOT = SOURCE_ROOT / "templates" / "support"
def _ignore_junk(_dir: str, names: list[str]) -> set[str]:
@@ -40,6 +43,34 @@ def replace_tree(src: Path, dst: Path) -> None:
shutil.copytree(src, dst, symlinks=False, ignore=_ignore_junk)
def normalize_support_template(value: str | None) -> str:
template = (value or DEFAULT_SUPPORT_TEMPLATE).strip().lower()
if template not in SUPPORT_TEMPLATES:
raise SystemExit(
f"unsupported --support-template {value!r}; "
f"choose one of: {', '.join(SUPPORT_TEMPLATES)}"
)
return template
def apply_support_template(campaign_dir: Path, template: str) -> None:
"""Replace web/support.html according to the selected template.
test — keep the campaign copy (current source HUD page)
blank — overwrite with templates/support/blank.html (no HUD UI)
"""
template = normalize_support_template(template)
dest = campaign_dir / "support.html"
if template == "test":
if not dest.is_file():
raise SystemExit(f"missing support.html after campaign copy: {dest}")
return
src = SUPPORT_TEMPLATE_ROOT / f"{template}.html"
if not src.is_file():
raise SystemExit(f"missing support template: {src}")
shutil.copyfile(src, dest)
def copy_campaign_template(dst_campaign: Path) -> None:
src = SOURCE_ROOT / "web" / ORIGINAL_CHANNEL_ID
if not src.is_dir():
@@ -178,6 +209,15 @@ def main() -> int:
default=5,
help="DGA candidates for patch_all when rebuilding sync (default 5)",
)
parser.add_argument(
"--support-template",
default=DEFAULT_SUPPORT_TEMPLATE,
choices=SUPPORT_TEMPLATES,
help=(
"support.html template: test (source HUD page) or blank "
"(no HUD UI; default: test)"
),
)
args = parser.parse_args()
src_campaign = SOURCE_ROOT / "web" / ORIGINAL_CHANNEL_ID
@@ -188,6 +228,7 @@ def main() -> int:
raise SystemExit(f"missing source sync: {src_sync}")
fixed_dep, fixed_rep = resolve_domains(args.deployment_domains, args.reporting_domains)
support_template = normalize_support_template(args.support_template)
channels_root = ARTIFACTS_ROOT / "channel"
channel = (
validate_channel_id(args.channel_id)
@@ -209,6 +250,7 @@ def main() -> int:
print("=== new_project ===")
print(f"channel: {channel}")
print(f"web dest: {campaign_dir}")
print(f"support: template={support_template}")
print("domains: rebuild isolated web + sync")
print(f" deployment: {', '.join(fixed_dep)}")
print(f" reporting: {', '.join(fixed_rep)}")
@@ -216,8 +258,9 @@ def main() -> int:
print("=== copy campaign template ===")
copy_campaign_template(campaign_dir)
apply_support_template(campaign_dir, support_template)
replace_tree(src_sync, sync_dir)
print("created web/ + sync/")
print(f"created web/ + sync/ (support_template={support_template})")
domain_args: list[str] = []
for item in fixed_dep:
@@ -259,6 +302,7 @@ def main() -> int:
release_manifest = {
"schema_version": 1,
"channel_id": channel,
"support_template": support_template,
"deployment_seed": dep,
"reporting_seed": rep,
"deployment_domains": fixed_dep,