站点:纯静态 HTML + CSS + 原生 JS,零框架零构建
页面:首页 / 合作品牌 / 荣誉资质 / 客户案例 / 关于我们
内容:
- site/ 站点本体(含已压缩 webp 图片,约 4.8 MB)
- deploy/ Docker Compose / Caddy / Apache 部署配置
- _tools/ 开发自检脚本与部署脚本
- Dockerfile 自建 nginx 镜像方案
- README.md 项目文档
设计:品牌黄 #ffc107 + 白,深蓝仅用于页脚;菜单长期置顶;
交互动效只加在关键词与区块级元素上。
素材说明:原始素材(背景图/老网站/方案/荣誉资质/合作品牌,约 290 MB)
未纳入版本控制,站点使用的是 site/assets 内已处理压缩的图片。
122 lines
4.3 KiB
Python
122 lines
4.3 KiB
Python
# 最终自检:编码 / 路径 / 导航完整性
|
||
# 注意:所有文件写入必须使用 UTF-8(Python 默认即是),不要用 PowerShell 的 Set-Content 覆盖 HTML/TXT。
|
||
import os
|
||
import re
|
||
import sys
|
||
import json
|
||
|
||
sys.stdout.reconfigure(encoding="utf-8")
|
||
|
||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||
SITE = os.path.join(ROOT, "site")
|
||
PAGES = ["index.html", "brands.html", "honors.html", "cases.html", "about.html"]
|
||
|
||
problems = []
|
||
|
||
|
||
def fail(msg):
|
||
problems.append(msg)
|
||
print(" x " + msg)
|
||
|
||
|
||
def ok(msg):
|
||
print(" - " + msg)
|
||
|
||
|
||
print("=== 1. 导航与路径完整性 ===")
|
||
for page in PAGES:
|
||
html = open(os.path.join(SITE, page), encoding="utf-8").read()
|
||
# 不允许出现上级目录引用或根绝对路径
|
||
up = re.findall(r'(?:href|src|data-bg|data-full|data-src)="(\.\./[^"]*)"', html)
|
||
if up:
|
||
fail("%s 存在上级目录引用:%s" % (page, up[:3]))
|
||
rootabs = re.findall(r'(?:href|src|data-bg|data-full|data-src)="(/[^"/][^"]*)"', html)
|
||
if rootabs:
|
||
fail("%s 存在根绝对路径:%s" % (page, rootabs[:3]))
|
||
# 五个页面导航链接是否齐全
|
||
navs = re.findall(r'class="nav__link"[^>]*href="([^"]+)"', html)
|
||
expect = ["index.html", "brands.html", "honors.html", "cases.html", "about.html"]
|
||
missing = [e for e in expect if e not in navs]
|
||
if missing:
|
||
fail("%s 主导航缺少:%s" % (page, missing))
|
||
else:
|
||
ok("%s 导航五项齐全,路径均为同级相对路径" % page)
|
||
|
||
print()
|
||
print("=== 2. 页面互相可达性 ===")
|
||
for page in PAGES:
|
||
html = open(os.path.join(SITE, page), encoding="utf-8").read()
|
||
links = set(re.findall(r'href="([a-z]+\.html)', html))
|
||
others = [p for p in PAGES if p != page]
|
||
miss = [p for p in others if p not in links]
|
||
if miss:
|
||
fail("%s 没有链接到:%s" % (page, miss))
|
||
else:
|
||
ok("%s 可跳转到其余全部页面" % page)
|
||
|
||
print()
|
||
print("=== 3. 资源引用存在性 ===")
|
||
for page in PAGES:
|
||
html = open(os.path.join(SITE, page), encoding="utf-8").read()
|
||
refs = set()
|
||
for m in re.finditer(r'(?:href|src)="(assets/[^"]+)"', html):
|
||
refs.add(m.group(1))
|
||
for m in re.finditer(r'data-(?:bg|full|src)="(assets/[^"]+)"', html):
|
||
refs.add(m.group(1))
|
||
bad = [r for r in refs if not os.path.exists(os.path.join(SITE, r))]
|
||
if bad:
|
||
fail("%s 缺失资源:%s" % (page, bad[:5]))
|
||
else:
|
||
ok("%s %d 个资源引用全部存在" % (page, len(refs)))
|
||
|
||
print()
|
||
print("=== 4. 编码与乱码检查 ===")
|
||
for page in PAGES:
|
||
raw = open(os.path.join(SITE, page), "rb").read()
|
||
if raw[:3] == b"\xef\xbb\xbf":
|
||
fail("%s 存在 UTF-8 BOM" % page)
|
||
try:
|
||
s = raw.decode("utf-8")
|
||
except UnicodeDecodeError as e:
|
||
fail("%s 不是合法 UTF-8:%s" % (page, e))
|
||
continue
|
||
if "\ufffd" in s:
|
||
fail("%s 含替换字符 U+FFFD" % page)
|
||
pua = re.findall(r"[\ue000-\uf8ff]", s)
|
||
if pua:
|
||
fail("%s 含私用区字符 %d 个" % (page, len(pua)))
|
||
if re.search(r"[閭鍏鎴鏈璁鐢鍦涓鏄銆]", s):
|
||
fail("%s 含 UTF-8/GBK 乱码特征" % page)
|
||
if not pua and "\ufffd" not in s:
|
||
ok("%s 编码干净(%d 个字符)" % (page, len(s)))
|
||
|
||
print()
|
||
print("=== 5. 首页结构(按需求:无轮播 / 单一背景) ===")
|
||
home = open(os.path.join(SITE, "index.html"), encoding="utf-8").read()
|
||
if "hero__slide" in home or "hero__dot" in home:
|
||
fail("首页仍存在轮播结构(hero__slide / hero__dot)")
|
||
else:
|
||
ok("首页已无轮播结构")
|
||
if home.count("hero__bg") >= 1 and "hero/hero-1.webp" in home:
|
||
ok("首页使用固定单张背景 hero-1.webp")
|
||
if "data-count" in home:
|
||
ok("首页含数字滚动面板")
|
||
|
||
print()
|
||
print("=== 6. 老网站英文占位文案残留检查 ===")
|
||
BAD_WORDS = ["BizMax", "lorem", "Intrinsicly", "reCAPTI", "Read More", "Read Details",
|
||
"Professionally", "Credibly", "Successful Projects", "Happy Clients"]
|
||
for page in PAGES:
|
||
html = open(os.path.join(SITE, page), encoding="utf-8").read()
|
||
hits = [w for w in BAD_WORDS if w in html]
|
||
if hits:
|
||
fail("%s 残留模板文案:%s" % (page, hits))
|
||
else:
|
||
ok("%s 无模板占位文案" % page)
|
||
|
||
print()
|
||
if problems:
|
||
print("共发现 %d 个问题" % len(problems))
|
||
sys.exit(1)
|
||
print("全部通过 OK")
|