164 lines
6.3 KiB
Python
Executable File
164 lines
6.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
build_gallery_manifest.py — Deterministic Catalog Compiler for the Read-Only Memetic Gallery (/gallery/).
|
|
Scans the 35 existing visual/memetic artifacts across /workspace/memes, Zoology, and Knowledge Graph,
|
|
copies/stages the meme images into /workspace/hyperstitionstudio-core/site/gallery/media/ so they
|
|
deploy automatically with hyperstitionstudio-core, and writes site/gallery/gallery-data.js.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import shutil
|
|
from pathlib import Path
|
|
from PIL import Image
|
|
|
|
CORE_ROOT = Path(__file__).resolve().parents[1]
|
|
WS_ROOT = CORE_ROOT.parent
|
|
MEMES_DIR = WS_ROOT / "memes"
|
|
ZOOLOGY_DIR = WS_ROOT / "technocapital-singularity-zoology"
|
|
KG_DIR = WS_ROOT / "encyclopedia-knowledge-graph"
|
|
GALLERY_DIR = CORE_ROOT / "site" / "gallery"
|
|
MEDIA_DIR = GALLERY_DIR / "media"
|
|
|
|
|
|
def human_title(stem: str) -> str:
|
|
s = stem
|
|
for pref in ("meme_1_custom_", "meme_2_memegen_", "meme_3_memegen_", "meme_3_supermeme_", "meme_1_memegen_", "meme_1_makeameme_", "meme_1_imgflip_"):
|
|
if s.startswith(pref):
|
|
s = s[len(pref) :]
|
|
break
|
|
return s.replace("_", " ").title()
|
|
|
|
|
|
def main() -> int:
|
|
MEDIA_DIR.mkdir(parents=True, exist_ok=True)
|
|
items = []
|
|
|
|
# 1. Scan /workspace/memes/*.png and /workspace/memes/demos/*.png
|
|
meme_files = sorted(MEMES_DIR.glob("*.png")) + sorted((MEMES_DIR / "demos").glob("*.png"))
|
|
for p in meme_files:
|
|
is_demo = p.parent.name == "demos"
|
|
rel_sub = f"demos/{p.name}" if is_demo else p.name
|
|
dst = MEDIA_DIR / rel_sub
|
|
dst.parent.mkdir(parents=True, exist_ok=True)
|
|
shutil.copy2(p, dst)
|
|
|
|
pdf_pair = p.with_suffix(".pdf")
|
|
has_pdf = pdf_pair.is_file()
|
|
if has_pdf:
|
|
shutil.copy2(pdf_pair, MEDIA_DIR / pdf_pair.name)
|
|
|
|
with Image.open(p) as im:
|
|
w, h = im.size
|
|
|
|
low = p.stem.lower()
|
|
if "pokedex" in low or "technocapital" in low or "ants_assets" in low:
|
|
cat = "zoology"
|
|
cat_label = "Pokedex & Technocapital Zoology"
|
|
elif is_demo:
|
|
cat = "classic_demos"
|
|
cat_label = "Classic Template Demos"
|
|
else:
|
|
cat = "philosophy_comedy"
|
|
cat_label = "Stand-Up & Philosophical Exegesis"
|
|
|
|
title = human_title(p.stem)
|
|
if "pokedex" in low:
|
|
title = "Gen IV INFO Pokedex: M7_candidate_2026_11_28 (129 / 125 / 193 / 191)"
|
|
elif "gta6_huawei" in low:
|
|
title = "Technocapital Singularity: GTA 6 / Huawei (260 == teknohkapital == kiler rohbots)"
|
|
elif "bergson_russell" in low:
|
|
title = "Bergson & Russell Philosophical Exegesis (IASIP Template)"
|
|
|
|
sha12 = hashlib.sha256(p.read_bytes()).hexdigest()[:12]
|
|
items.append({
|
|
"id": f"meme:{rel_sub}",
|
|
"title": title,
|
|
"category": cat,
|
|
"category_label": cat_label,
|
|
"filename": p.name,
|
|
"width": w,
|
|
"height": h,
|
|
"bytes": p.stat().st_size,
|
|
"sha256_12": sha12,
|
|
"img_src": f"./media/{rel_sub}",
|
|
"pdf_src": f"./media/{pdf_pair.name}" if has_pdf else None,
|
|
})
|
|
|
|
# 2. Add the 4 High-Resolution Tier-List & Knowledge Graph Visual Atlas Boards
|
|
atlas_boards = [
|
|
(
|
|
ZOOLOGY_DIR / "tier-list-technocapital-assemblage-builds.png",
|
|
"Assemblage Builds ETI (0-100) Tier List Scorecard (S+ to D/F)",
|
|
"/zoology/tier-list-technocapital-assemblage-builds.png",
|
|
"../../../technocapital-singularity-zoology/tier-list-technocapital-assemblage-builds.png",
|
|
"/zoology/tier-list-technocapital-assemblage-builds.pdf",
|
|
"../../../technocapital-singularity-zoology/tier-list-technocapital-assemblage-builds.pdf",
|
|
),
|
|
(
|
|
KG_DIR / "atlas-mode2-concentric-eti-radar.png",
|
|
"Knowledge Graph Atlas Mode 2: Concentric ETI Tier-Ring Radar (S+ Center -> D Periphery)",
|
|
"/graph/atlas-mode2-concentric-eti-radar.png",
|
|
"../../../encyclopedia-knowledge-graph/atlas-mode2-concentric-eti-radar.png",
|
|
"/graph/OPERATORS-MANUAL-ENCYCLOPEDIA-KNOWLEDGE-GRAPH.pdf",
|
|
"../../../encyclopedia-knowledge-graph/OPERATORS-MANUAL-ENCYCLOPEDIA-KNOWLEDGE-GRAPH.pdf",
|
|
),
|
|
(
|
|
KG_DIR / "atlas-mode1-trophic-food-web.png",
|
|
"Knowledge Graph Atlas Mode 1: Trophic Food-Web & 13 Flex-Pivot Topology",
|
|
"/graph/atlas-mode1-trophic-food-web.png",
|
|
"../../../encyclopedia-knowledge-graph/atlas-mode1-trophic-food-web.png",
|
|
None,
|
|
None,
|
|
),
|
|
(
|
|
KG_DIR / "atlas-mode3-bipartite-g1-funnel.png",
|
|
"Knowledge Graph Atlas Mode 3: Bipartite Gen 0 -> Gen 1 Variance-Collapse Funnel",
|
|
"/graph/atlas-mode3-bipartite-g1-funnel.png",
|
|
"../../../encyclopedia-knowledge-graph/atlas-mode3-bipartite-g1-funnel.png",
|
|
None,
|
|
None,
|
|
),
|
|
]
|
|
for p, title, http_img, file_img, http_pdf, file_pdf in atlas_boards:
|
|
if p.is_file():
|
|
with Image.open(p) as im:
|
|
w, h = im.size
|
|
sha12 = hashlib.sha256(p.read_bytes()).hexdigest()[:12]
|
|
items.append({
|
|
"id": f"board:{p.name}",
|
|
"title": title,
|
|
"category": "atlas_boards",
|
|
"category_label": "Tier-List & Atlas Boards",
|
|
"filename": p.name,
|
|
"width": w,
|
|
"height": h,
|
|
"bytes": p.stat().st_size,
|
|
"sha256_12": sha12,
|
|
"img_src": http_img,
|
|
"img_src_file": file_img,
|
|
"pdf_src": http_pdf,
|
|
"pdf_src_file": file_pdf,
|
|
})
|
|
|
|
manifest = {
|
|
"version": "2.0.30",
|
|
"namespace_urn": "urn:io:hyperstitionstud:gallery:2.0.30",
|
|
"total_items": len(items),
|
|
"items": items,
|
|
}
|
|
js_out = GALLERY_DIR / "gallery-data.js"
|
|
js_out.write_text(
|
|
"window.HyperstitionStudio = window.HyperstitionStudio || {};\n"
|
|
f"window.HyperstitionStudio.GalleryData = {json.dumps(manifest, indent=2)};\n",
|
|
encoding="utf-8",
|
|
)
|
|
print(f"Wrote {len(items)} gallery items to {js_out}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|