Add searchable wiki catalogue and biology material navigation
This commit is contained in:
@@ -421,6 +421,33 @@ def build_biolog(output: Path, pack_tool: Path):
|
||||
return {"stages": 13, "item_templates": 29, "pack": "biolog", "first_priority": True}
|
||||
|
||||
|
||||
|
||||
def build_wiki(output: Path, pack_tool: Path):
|
||||
"""A versioned public server catalogue; original script and proto packs stay intact."""
|
||||
source = REPO / "data/wiki/catalogue.txt"
|
||||
manifest = json.loads((source.parent / "manifest.json").read_text())
|
||||
import hashlib
|
||||
raw = source.read_bytes()
|
||||
header, payload = raw.split(b"\n", 1)
|
||||
if hashlib.sha256(payload).hexdigest() != manifest["catalogue_sha256"]:
|
||||
raise ValueError("wiki catalogue checksum mismatch; regenerate from server tables")
|
||||
if header != ("MTWIKI\t1\t" + manifest["catalogue_sha256"]).encode("ascii"):
|
||||
raise ValueError("unsupported wiki catalogue header")
|
||||
stage = output.parent / "wiki"
|
||||
assets = stage / "assets/wiki"
|
||||
assets.mkdir(parents=True, exist_ok=True)
|
||||
shutil.copy2(source, assets / "catalogue.txt")
|
||||
subprocess.run([str(pack_tool.resolve()), str(stage / "wiki"), str(assets.parent), ""], check=True)
|
||||
for extension in ("eix", "epk"):
|
||||
shutil.copy2(stage / ("wiki." + extension), output / "pack" / ("wiki." + extension))
|
||||
index = output / "pack/Index"
|
||||
lines = index.read_bytes().replace(b"\r\n", b"\n").splitlines()
|
||||
if b"wiki" not in lines:
|
||||
lines[1:1] = [b"*", b"wiki"]
|
||||
index.write_bytes(b"\r\n".join(lines) + b"\r\n")
|
||||
return manifest
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--english", type=Path, default=DEFAULT_EN)
|
||||
@@ -435,6 +462,7 @@ def main():
|
||||
args.proto_tool, args.name_tables, args.pack_tool)
|
||||
report = json.loads(report_path.read_text())
|
||||
report["biolog"] = build_biolog(args.output, args.pack_tool)
|
||||
report["wiki"] = build_wiki(args.output, args.pack_tool)
|
||||
report_path.write_text(json.dumps(report, ensure_ascii=False, indent=2)+"\n", encoding="utf-8")
|
||||
print(f"Built {args.output / 'pack/locale_zh.eix'} (.epk), registered in pack/Index")
|
||||
print(f"Report: {report_path}")
|
||||
|
||||
Reference in New Issue
Block a user