feat(gitea): 升 28.2.0 并把品牌装饰层纳管为可重跑的仓库真源
自建 Gitea 此前是出厂外观(茶杯标 + 「Gitea: Git with a cup of tea」标题),而品牌「纯字标 + 朱砂条」已在官网落地;同时现网 1.27.2 落后两个安全版本 —— 1.27.3 的 fix(git): restrict hook permissions 打的正是本实例 8 月被入侵所用的 packObjectsHook 向量。装饰基准取自升级后从容器抽出的真实模板,不凭记忆手写。 - 升级 28.2.0:pg_dump 后还原到一次性探针库对账(116 表 / 20 仓库 / 8 用户全等),停服 8s;28.0.0 的 git egress BREAKING 按裁定收为 EGRESS_MODE=strict(实测 app.ini 无旧 ALLOWED_* 键、mirror 仓库 0 个 ⇒ 空白名单不伤业务)。 - 装饰层真源入库 infra/cicd/gitea-custom/(结构即实测 CustomPath=/data/gitea):页头/OG/默认头像换简标与刻版、novalon- brand.css 覆盖 --color-primary 全色阶、custom/header.tmpl 外链注入、signin_inner.tmpl 登录页加字标锁定(220×103)。 - 色阶由脚本生成并自带夹具:先对上游 14 档对账(light/dark 两档 ramp 命名互为反向,手敲必错),再喂上游蓝做反向自证,双双通过才写盘。 - 深档按钮改「黑字朱底」:Gitea 用同一令牌既当按钮底色又当链接文字色,AA 区间为空(按钮白字 L≤0.1833 vs 链接 on #1e1f20 L≥0.2362)⇒ #E13C58 × #0D0D0D 实测 4.62:1;深档链接 3.92:1 作为已登记让步保留(上游蓝同位 4.14,本就不达标)。 - deploy/verify 带预检、备份、内容 sha256 比对、负对照与 0/1/2/3 退出码分档,核心判红自动回滚(首轮就靠它把「标题未生效」与「装饰未生效」区分开)。 - 纠正两处生产口径失真:仓库那份「加固版」compose 从未上线(真实文件纳管为 infra/cicd/gitea/docker-compose.live.yml);生产 REQUIRE_SIGNIN_VIEW 实为 false,且 compose 的 DISABLE_REGISTRATION=false 会经 environment-to-ini 在重建时静默打开注册 —— 已对齐为 true。遗留的匿名浏览面与 SSH_PORT 错配只登记不擅动。
This commit is contained in:
1 parent
03be1c9e36
commit
becb9407bd
55 files changed
+1657
-2
No files matched your search
@@ -0,0 +1,41 @@
|
||||
# 取证 · Gitea 升级 28.2.0 与品牌装饰层(2026-10-22)
|
||||
|
||||
## 复跑方式
|
||||
|
||||
```bash
|
||||
python3 docs/acceptance/2026-10-22-gitea-branding/contrast-probe.py # 对比度探针(含仪器自证)
|
||||
bash infra/cicd/gitea-custom/verify-branding.sh # 生产只读断言(0/1/2/3 分档)
|
||||
```
|
||||
|
||||
`contrast-probe.py` 从 `infra/cicd/gitea-custom/upstream/` 里 28.2.0 内嵌主题 CSS 读实测底色,不写死值。
|
||||
|
||||
## 结论摘要
|
||||
|
||||
| 判据 | 结果 |
|
||||
|---|---|
|
||||
| 升级停服时长 | 8s(`up -d` → healthz 200) |
|
||||
| 备份可读回 | dump 61,402,034 B → 探针库还原 exit 0,116 表 / 20 仓库 / 8 用户与现网逐项相等 |
|
||||
| 装饰层生产断言 | 13 项全绿(7 项内容 sha256 相等 + 5 项模板/表单契约 + 标题去出厂串)+ 1 项负对照(不存在的路径必须 404) |
|
||||
| 浅档主色 | `#C41E3A`:按钮白字 5.84:1、链接对白 5.84:1、焦点环 5.84:1 ⇒ 全过 AA |
|
||||
| 深档主色 | `#E13C58` × `#0D0D0D`(甲方裁定黑字朱底)= 4.62:1 过 AA;链接 on `#1e1f20` = 3.92:1 **未达正文 AA**,已登记让步(上游蓝同位 4.14,本就不达标) |
|
||||
| 色阶作用域 | OS 浅 + auto → `#C41E3A`;OS 浅但显式选 `gitea-dark` → `#E13C58`;显式 `gitea-light` → `#C41E3A`;色弱变体 `gitea-auto-tritanopia` → `#C41E3A`(纯 media query 会在第二种情形判错,故必须带 `[data-theme]` 作用域) |
|
||||
| 朱砂条 | `#navbar` 计算样式 `3px solid rgb(196,30,58)`(浅)/ `rgb(225,60,88)`(深);375@2x 下 3 CSS px = 6 设备 px,不破手册「<1px 即禁用」 |
|
||||
| 页头图标 | 实测槽 30×30,服务的是 `seal-master.svg`(简标主刻版);字标 viewBox 255.6×119.82 放不进该槽 |
|
||||
| 登录页字标 | 渲染 220×103(高 > 手册安全档 64px),浅档显示墨版、深档显示反白版,另一版 `display:none` |
|
||||
| 蓝残留 | 登录页与 /explore 全量遍历 `color`/`backgroundColor`,命中 `rgb(65,131,196)` 的元素数 = 0 |
|
||||
| git 链路 | HTTPS `git ls-remote` exit 0(dev 头 = 03be1c9e);SSH 2222 端口可达;`EGRESS_MODE=strict` 生效且启动日志无 invalid host-list 告警 |
|
||||
|
||||
## 截图(chrome-devtools 真实仿真,非人工浏览)
|
||||
|
||||
- `login-1440-light.png` / `login-1440-dark.png` — 1440×900 @1x
|
||||
- `login-375-light.png` — 375×812 @2x
|
||||
- `explore-1440-light.png` — 匿名可见的完整页头(简标 + 朱砂条 + 「官网」导航项)
|
||||
|
||||
## 未覆盖 / 待办
|
||||
|
||||
1. **登录后内页**(仓库、issue、后台)未做浏览器取证:需要真实账号口令,本轮不把凭据喂进自动化。
|
||||
装饰层是令牌级覆盖 + 一条 `#navbar` 规则,理论上全站生效,但**这是推断不是实测**。
|
||||
2. **strict egress 的负对照未做**(「白名单外的出站 git 必须被拒」需要造一个 mirror 仓库 = 写生产数据)。
|
||||
现网 mirror 数为 0,故本轮只验证了「配置生效 + 启动无告警」。
|
||||
3. 匿名可浏览 `/explore` 是否收口为 `REQUIRE_SIGNIN_VIEW=true` —— 属策略裁定,不在本轮范围。
|
||||
4. `SSH_PORT=22` 与宿主 `2222:22` 的克隆地址错配仍在(改动影响所有人已存 remote)。
|
||||
@@ -0,0 +1,134 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Gitea 品牌色对比度探针(2026-10-22 · gitea-branding)
|
||||
|
||||
背景:品牌手册 §3 钉了两档朱砂 —— 纸底 #C41E3A / 深底 #E13C58,并留了一句警示
|
||||
「#E13C58 对白只有 4.44」。Gitea 侧要同时喂浅色与深色两套主题,按钮文字是
|
||||
--color-primary-contrast(实测两档都是 #ffffff),链接文字直接用 --color-primary。
|
||||
⇒ 不能照抄手册色值就收工,必须按 Gitea 实测底色量一遍。
|
||||
|
||||
口径:WCAG 2.1 相对亮度与对比度公式(与 scripts/accessibility 一致)。
|
||||
判据:正文/链接 4.5:1(AA);按钮文字同为 4.5:1;非文本 UI(描边/焦点环/朱砂条)3:1。
|
||||
|
||||
仪器自证:已知好/坏的两对必须先验证公式本身 —— 判据不敏感时后面的表全是废纸。
|
||||
用 /usr/bin/python3 运行(本机只有它有 Pillow;本脚本其实不需要,但口径统一)。
|
||||
"""
|
||||
import re
|
||||
import sys
|
||||
|
||||
UP = "infra/cicd/gitea-custom/upstream/public/assets/css"
|
||||
LIGHT = f"{UP}/theme-gitea-light.CcrYmZOI.css"
|
||||
DARK = f"{UP}/theme-gitea-dark.n17NpZ-u.css"
|
||||
|
||||
|
||||
def srgb_lin(c):
|
||||
c = c / 255.0
|
||||
return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4
|
||||
|
||||
|
||||
def lum(hexstr):
|
||||
h = hexstr.lstrip("#")
|
||||
if len(h) == 3:
|
||||
h = "".join(ch * 2 for ch in h)
|
||||
r, g, b = (int(h[i:i + 2], 16) for i in (0, 2, 4))
|
||||
return 0.2126 * srgb_lin(r) + 0.7152 * srgb_lin(g) + 0.0722 * srgb_lin(b)
|
||||
|
||||
|
||||
def ratio(a, b):
|
||||
la, lb = lum(a), lum(b)
|
||||
hi, lo = max(la, lb), min(la, lb)
|
||||
return (hi + 0.05) / (lo + 0.05)
|
||||
|
||||
|
||||
def token(path, name):
|
||||
s = open(path, encoding="utf-8").read()
|
||||
m = re.search(r"--%s:\s*(#[0-9a-fA-F]{3,8})" % re.escape(name), s)
|
||||
if not m:
|
||||
raise SystemExit("FATAL: %s 里找不到 --%s(口径变了,别接着算)" % (path, name))
|
||||
return m.group(1)
|
||||
|
||||
|
||||
def selftest_instrument():
|
||||
"""仪器自证:公式必须把已知的好/坏分开。"""
|
||||
checks = [
|
||||
(ratio("#000000", "#ffffff") >= 20.9, "黑对白应≈21:1"),
|
||||
(ratio("#ffffff", "#ffffff") < 1.01, "白对白应≈1:1(若判合格说明仪器坏)"),
|
||||
(ratio("#777777", "#ffffff") < 4.6, "中灰对白应刚掉出 4.5"),
|
||||
(abs(ratio("#C41E3A", "#ffffff") - 5.84) < 0.05, "#C41E3A 对白实测≈5.84"),
|
||||
]
|
||||
bad = [msg for ok, msg in checks if not ok]
|
||||
if bad:
|
||||
print("FATAL 仪器自证失败:", "; ".join(bad))
|
||||
sys.exit(2)
|
||||
print("仪器自证 4/4 通过(含一对必须判失败的负对照)\n")
|
||||
|
||||
|
||||
def tune(fg, other, need, toward):
|
||||
"""把 fg 朝 toward 插值,返回首个满足「与 other 的对比度 ≥ need」的色与偏移量。
|
||||
|
||||
方向不能只朝背景插值 —— 按钮文字是白色时,把朱砂往白里提只会更糟,必须往黑走。
|
||||
所以调用方两个方向都试,取位移小的那个。
|
||||
"""
|
||||
def split(x):
|
||||
x = x.lstrip("#")
|
||||
return [int(x[i:i + 2], 16) for i in (0, 2, 4)]
|
||||
f, t = split(fg), split(toward)
|
||||
for step in range(0, 101):
|
||||
k = step / 100.0
|
||||
c = "#%02X%02X%02X" % tuple(round(f[i] + (t[i] - f[i]) * k) for i in range(3))
|
||||
if ratio(c, other) >= need:
|
||||
return c, step
|
||||
return None, None
|
||||
|
||||
|
||||
def main():
|
||||
selftest_instrument()
|
||||
|
||||
l_body, l_text, l_primary = token(LIGHT, "color-body"), token(LIGHT, "color-text"), token(LIGHT, "color-primary")
|
||||
d_body, d_text, d_primary = token(DARK, "color-body"), token(DARK, "color-text"), token(DARK, "color-primary")
|
||||
print("Gitea 实测底色(从 28.2.0 内嵌主题 CSS 读出,非推断)")
|
||||
print(" 浅色 --color-body=%s --color-text=%s 上游 --color-primary=%s" % (l_body, l_text, l_primary))
|
||||
print(" 深色 --color-body=%s --color-text=%s 上游 --color-primary=%s\n" % (d_body, d_text, d_primary))
|
||||
|
||||
WHITE, INK = "#ffffff", "#26221E"
|
||||
PAPER, SEAL_DEEP = "#C41E3A", "#E13C58"
|
||||
|
||||
rows = [
|
||||
("上游蓝 按钮文字(白)", l_primary, WHITE, 4.5),
|
||||
("上游蓝 链接 on 浅底", l_primary, l_body, 4.5),
|
||||
("上游蓝 按钮文字(白)·深", d_primary, WHITE, 4.5),
|
||||
("上游蓝 链接 on 深底", d_primary, d_body, 4.5),
|
||||
("纸底朱砂 #C41E3A 按钮文字(白)", PAPER, WHITE, 4.5),
|
||||
("纸底朱砂 链接 on 浅底", PAPER, l_body, 4.5),
|
||||
("纸底朱砂 焦点环 on 浅底", PAPER, l_body, 3.0),
|
||||
("深底朱砂 #E13C58 按钮文字(白)", SEAL_DEEP, WHITE, 4.5),
|
||||
("深底朱砂 链接 on 深底", SEAL_DEEP, d_body, 4.5),
|
||||
("深底朱砂 焦点环/描边 on 深底", SEAL_DEEP, d_body, 3.0),
|
||||
]
|
||||
print("%-38s %-22s %8s %s" % ("场景", "组合", "实测", "AA 判据"))
|
||||
reds = []
|
||||
for name, fg, bg, need in rows:
|
||||
r = ratio(fg, bg)
|
||||
ok = "过" if r >= need else "红"
|
||||
if r < need:
|
||||
reds.append((name, fg, bg, need, r))
|
||||
print("%-38s %-22s %7.2f:1 ≥%.1f %s" % (name, "%s/%s" % (fg, bg), r, need, ok))
|
||||
|
||||
print("\n需要裁决的红项(不自动改色,先给候选):")
|
||||
for name, fg, bg, need, r in reds:
|
||||
opts = []
|
||||
for toward in ("#FFFFFF", "#000000"):
|
||||
cand, step = tune(fg, bg, need, toward)
|
||||
if cand:
|
||||
opts.append((step, cand, toward))
|
||||
print(" ✗ %s 实测 %.2f(差 %.2f)" % (name, r, need - r))
|
||||
for step, cand, toward in sorted(opts)[:2]:
|
||||
print(" %s 移 %.0f%% → %s,实测 %.2f"
|
||||
% ("提亮" if toward == "#FFFFFF" else "压暗", step, cand, ratio(cand, bg)))
|
||||
|
||||
print("\n结论口径:上游蓝在深底做链接文字本身只有 %.2f:1,"
|
||||
"「比上游更差」不是可接受的辩护,但「与上游同档」也不是通过。" % ratio(d_primary, d_body))
|
||||
return 1 if reds else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 114 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 60 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 92 KiB |
Reference in new issue
Block a user