💃 Free CC0 mannequin pose reference library for AI image tools (Nano Banana, ChatGPT, ComfyUI, Midjourney) — 250+ poses × 5 angles in line art, names in ja/zh/en/ko
Python ai-artai-image-generationart-referencecc0comfyuicontrolnetdatasetdrawing-referencefigure-drawingline-artmannequinmidjourneymultilingualnano-bananapose-referencereference-imagesstable-diffusion
feat(tools): library item pages and share cards for items and library pages
wquguru4b203ed6e46e
diff --git a/tools/build_site.py b/tools/build_site.pyindex 897adcf6..005ccd81 100755--- a/tools/build_site.py+++ b/tools/build_site.py@@ -1,8 +1,9 @@#!/usr/bin/env python3"""Build the static site into site/ from web/, data/catalog.json and web/changelog.yaml.-Writes, per language (zh unprefixed, ja/ en/ ko/): the gallery home, one page per pose, the changelog and its Atom-feed; plus share cards (og/), sitemap.xml, robots.txt, 404.html, manifest and icons. Fails on a bad changelog entry,+Writes, per language (zh unprefixed, ja/ en/ ko/): the gallery home, one page per pose, each library page and one+page per general-rated library item (<lib>/<ID>/), the changelog and its Atom feed; plus share cards (og/; the library+ones on the image host with --media), sitemap.xml, robots.txt, 404.html, manifest and icons. Fails on a bad changelog entry,a page without its share tags, or a relative link that points nowhere.Usage: python3 tools/build_site.py [--site URL] [--repo URL] [--link-images] [--no-og] [--out site]@@ -245,7 +246,7 @@ class Refs(HTMLParser):self.links[a["rel"]] = a.get("href")-def check_site(out, site):+def check_site(out, site, media=None):bad = []for f in out.rglob("*.html"):if f.name == "404.html":@@ -259,8 +260,10 @@ def check_site(out, site):bad.append(f"{where}: no {need}")if not (r.links.get("canonical") or "").startswith(site):bad.append(f"{where}: canonical missing or not on {site}")- if (r.meta.get("og:image") or "") and not r.meta["og:image"].startswith(site):- bad.append(f"{where}: og:image is not absolute on {site}")+ # Library pages' cards live on the image host (--media) beside the library images.+ hosts = (site,) + ((media,) if media else ())+ if (r.meta.get("og:image") or "") and not r.meta["og:image"].startswith(hosts):+ bad.append(f"{where}: og:image is not absolute on {' or '.join(hosts)}")for ref in r.refs:if re.match(r"^(?:[a-z]+:|#|//|__)", ref):continue@@ -292,6 +295,8 @@ STAMPED = ("app.css", "app.js", "common.js", "i18n.js", "tray.js", "library.js")MEDIA_HEADERS = """/images/*Access-Control-Allow-Origin: *Cache-Control: public, max-age=604800, stale-while-revalidate=86400+/og/*+ Cache-Control: public, max-age=86400, stale-while-revalidate=86400"""@@ -378,7 +383,12 @@ def main() -> None:fresh = og_cards.render(jobs, chrome)print(f"share cards: {len(jobs)} ({fresh} rendered, {len(jobs) - fresh} cached)")- site = Site(site_url, args.repo.rstrip("/"), ver, S, poses, og=bool(chrome))+ # Library images and library share cards go to the image host when there is one (DESIGN.md, 素材库与搭配).+ media = args.media.rstrip("/") + "/" if args.media else None+ libs = {lib: library_data(lib) for lib in LIBS}+ # Item pages and cards: general-rated items only, as for poses (D-06; the lingerie category is all suggestive, D-11).+ general = {lib: [c for c in D["items"] if c["r"] != "suggestive"] for lib, D in libs.items()}+ site = Site(site_url, args.repo.rstrip("/"), ver, S, poses, og=bool(chrome), media=media)write = lambda page, doc: ((out / page).mkdir(parents=True, exist_ok=True), (out / page / "index.html").write_text(doc))# Gallery home per language@@ -389,7 +399,6 @@ def main() -> None:packs = json.loads(packs_file.read_text()) if packs_file.exists() else Noneif packs and packs["version"] != ver:print(f"warning: data/packs.json is for v{packs['version']}, the site is v{ver}", file=sys.stderr)- libs = {lib: library_data(lib) for lib in LIBS}nav = nav_data(libs, catalog)ltpl = (ROOT / "web/library.html").read_text()for loc in LOCS:@@ -422,8 +431,10 @@ def main() -> None:lrel = Site.rel(PREFIX[loc] + key)n, L = len(D["items"]), T["libs"][lib]meta = dict(name=L["name"], n=n, unit=L["unit"], sub=L["sub"])+ first = general[lib][0]lhead = site.head(loc, key, fill(T["libTitle"], **meta), fill(T["libDesc"], **meta),- site.og_image(loc, "home"), T["ogAlt"], None)+ site.lib_card(loc, f"lib-{lib}", f"images/{D['dir']}/w900/{first['v'][first['m']]}"),+ fill(T["libTitle"], **meta), None)lnoscript = "<noscript><ul class=\"wrap\">" + "".join(f'<li>{c["id"]} {esc(c["n"][loc])}</li>' for c in D["items"]) + "</ul></noscript>"ldoc = (ltpl.replace("__HEAD__", lhead).replace("__HTMLLANG__", HTML_LANG[loc]).replace("__LOC__", loc)@@ -433,6 +444,8 @@ def main() -> None:.replace("__LIBDATA__", json.dumps(D, ensure_ascii=False, separators=(",", ":")).replace("</", "<\\/")).replace("__REPO__", site.repo).replace("__VERSION__", ver))write(PREFIX[loc] + key, ldoc)+ for i in range(len(general[lib])):+ write(*site.item_page(loc, lib, D, general[lib], i))for i in range(len(poses)):write(*site.pose_page(loc, i))@@ -479,7 +492,38 @@ def main() -> None:for f in sorted({f for i in D["items"] for f in i["v"] if f}):shutil.copy2(ROOT / "images" / D["dir"] / tier / f, d / f)# Every page gets the menu and tray data, and where library images live, before its scripts run.- media = args.media.rstrip("/") + "/" if args.media else None+ # Library share cards, after the image host is laid out (it is rebuilt from scratch above): one per general item+ # and language, and one per library page. They sit beside the library images so site/ stays under the file cap.+ if chrome:+ croot = (ROOT / args.media_out) if media else out+ jobs = []+ for loc in LOCS:+ T = S[loc]+ for lib, D in libs.items():+ L = T["libs"][lib]+ cats = {k["key"]: k["name"][loc] for k in D["cats"]}+ vn = [T["libViews"][v] for v in D["views"]]+ # One main-view image from each of the first categories, so the card shows the library's range.+ picks, seen = [], set()+ for c in general[lib]:+ if c["cat"] not in seen:+ seen.add(c["cat"]); picks.append(c["v"][c["m"]])+ for c in general[lib]:+ if len(picks) >= 5:+ break+ if c["v"][c["m"]] not in picks:+ picks.append(c["v"][c["m"]])+ n = len(D["items"])+ jobs.append((og_cards.lib_card(loc, L["name"], fill(T["libOgLine"], n=n, unit=L["unit"]), L["sub"], picks[:5],+ D["kind"], D["dir"]), croot / f"og/{loc}/lib-{lib}.png", 1200, 630))+ for c in general[lib]:+ have = [vn[k] for k, f in enumerate(c["v"]) if f]+ meta = " · ".join(x for x in (c["id"], cats.get(c["cat"], ""), c["sub"][loc] if c.get("sub") else "") if x)+ item = {"id": c["id"], "name": c["n"][loc], "files": c["v"], "main": c["v"][c["m"]]}+ jobs.append((og_cards.item_card(loc, item, L["name"], meta, [fill(T["viewsN"], n=len(have))] + have,+ D["kind"], D["dir"]), croot / f"og/{loc}/{c['id']}.png", 1200, 630))+ fresh = og_cards.render(jobs, chrome)+ print(f"library share cards: {len(jobs)} ({fresh} rendered, {len(jobs) - fresh} cached) in {croot.relative_to(ROOT)}/og")for f in out.rglob("*.html"):doc = f.read_text()m = re.search(r'<script src="([./]*)i18n\.js', doc)@@ -502,10 +546,12 @@ def main() -> None:# sitemap.xml with hreflang alternates and the line art as image entries; robots.txtcat_day, cl_day = git_day("data/catalog.json"), entries[0]["date"]+ lib_day = {lib: git_day(f"data/{LIBS[lib]['data']}.json") for lib in LIBS}rows = []for key, day, imgs in ([("", cat_day, []), ("changelog/", cl_day, [])] +- [(lib + "/", git_day(f"data/{LIBS[lib]['data']}.json"), []) for lib in LIBS] +- [(f"pose/{p['id']}/", cat_day, [f for f in p["line"] if f]) for p in poses]):+ [(lib + "/", lib_day[lib], []) for lib in LIBS] ++ [(f"pose/{p['id']}/", cat_day, [f for f in p["line"] if f]) for p in poses] ++ [(f"{lib}/{c['id']}/", lib_day[lib], []) for lib in LIBS for c in general[lib]]):alts = "".join(f'<xhtml:link rel="alternate" hreflang="{HTML_LANG[l]}" href="{esc(site.abs(PREFIX[l] + key))}"/>'for l in LOCS) + f'<xhtml:link rel="alternate" hreflang="x-default" href="{esc(site.abs(key))}"/>'im = "".join(f"<image:image><image:loc>{esc(site.abs('images/line/w900/' + f))}</image:loc></image:image>" for f in imgs)@@ -516,11 +562,11 @@ def main() -> None:+ "\n".join(rows) + "\n</urlset>\n")(out / "robots.txt").write_text(f"User-agent: *\nAllow: /\n\nSitemap: {site.abs('sitemap.xml')}\n")- bad = check_site(out, site_url)+ bad = check_site(out, site_url, media)if bad:sys.exit("site check failed:\n " + "\n ".join(bad[:40]) + (f"\n … {len(bad) - 40} more" if len(bad) > 40 else ""))print(f"built {out.relative_to(ROOT)}/ v{ver} for {site_url}{' (public)' if args.public else ''}: "- f"{len(catalog)} gallery poses, {len(poses)} pose pages × {len(LOCS)} languages, "+ f"{len(catalog)} gallery poses, {len(poses)} pose pages and {sum(map(len, general.values()))} item pages × {len(LOCS)} languages, "f"{len(entries)} changelog entries, {len(rows)} sitemap URLs")diff --git a/tools/og_cards.py b/tools/og_cards.pyindex ca8ee7c2..9d65cc78 100644--- a/tools/og_cards.py+++ b/tools/og_cards.py@@ -2,8 +2,8 @@Chrome is the only compositor this repo can count on (no PIL, no ImageMagick), and a card is just HTML: line artmultiplied onto its category colour, the same look as the gallery. Renders are cached in build/og-cache/ under a-hash of the card's HTML and the image files it uses, so a rebuild only renders what changed. Only line art goes on-cards (photo renders wait on docs/DECISIONS.md D-03).+hash of the card's HTML and the image files it uses, so a rebuild only renders what changed. Pose cards carry line art+only; library cards (item and library page) carry that library's own images, the same files its page shows."""import concurrent.futures, hashlib, html, os, pathlib, shutil, subprocess, tempfile@@ -29,8 +29,9 @@ def find_chrome():return next((c for c in cands if c and pathlib.Path(c).exists()), None)-def _img(f):- return (ROOT / "images/line/w900" / f).as_uri()+def _img(f, d="line"):+ """d: the image folder under images/ (line art, or a library's dir such as costume/grey)."""+ return (ROOT / "images" / d / "w900" / f).as_uri()def _page(loc, body, w=W, h=H):@@ -49,6 +50,9 @@ html,body{{margin:0;width:{w}px;height:{h}px;overflow:hidden;background:#F5F2ED;.r{{position:absolute;right:56px;top:56px;bottom:56px;width:584px;display:grid;gap:14px}}.t{{border-radius:28px;overflow:hidden;display:flex;align-items:center;justify-content:center}}.t img{{width:100%;height:100%;object-fit:contain;mix-blend-mode:multiply}}+.t.grey{{background:#D9D9D9}} .t.grey img{{mix-blend-mode:normal}}+.t.photo{{background:#ECE7DF}} .t.photo img{{object-fit:cover;mix-blend-mode:normal}}+.tag{{margin-left:4px;padding:8px 14px;border-radius:999px;background:#18181B;color:#F5F2ED;font-size:18px;font-weight:600;letter-spacing:0}}.big{{font:800 92px/1 'Helvetica Neue',sans-serif;letter-spacing:-0.05em;text-shadow:3px 4px 0 #EDB79C;margin-top:auto}}.line{{margin-top:22px;font-size:40px;font-weight:800;letter-spacing:-0.01em}}.sub{{margin-top:14px;font-size:24px;line-height:1.45;color:#55534E}}@@ -80,6 +84,39 @@ def home_card(loc, T, picks):return _page(loc, body)+def _tile(kind, f, d, extra=""):+ """A library tile by how the library's images look: grey product shots and photos as they are, animal line art+ multiplied on the paper tint like the poses."""+ cls = kind if kind in ("grey", "photo") else ""+ style = ("" if cls else "background:#ECE7DF;") + extra+ return f'<div class="t {cls}"' + (f' style="{style}"' if style else "") + f'><img src="{_img(f, d)}"></div>'+++def item_card(loc, item, lib_name, meta, chips, kind, d):+ """A library item's card, laid out like pose_card: item = {id, name, files} with files the item's views in the+ library's order (None for a gap); chips = the names of the views it has."""+ have = [f for f in item["files"] if f]+ big = item["main"] if item.get("main") else have[0]+ small = [f for f in have if f != big][:2]+ tiles = _tile(kind, big, d, "grid-row:1/3") + "".join(_tile(kind, f, d) for f in small)+ chip_html = f'<span class="chip y">{html.escape(chips[0])}</span>' + "".join(+ f'<span class="chip">{html.escape(c)}</span>' for c in chips[1:])+ body = (f'<div class="l"><div class="brand">{LOGO.format(s=52)}Shisei<span class="tag">{html.escape(lib_name)}</span></div>'+ f'<div class="meta">{html.escape(meta)}</div>'+ f'<h1 class="name">{html.escape(item["name"])}</h1><div class="chips">{chip_html}</div></div>'+ f'<div class="r" style="grid-template-columns:388px 182px;grid-template-rows:1fr 1fr">{tiles}</div>')+ return _page(loc, body)+++def lib_card(loc, name, line, sub, files, kind, d):+ """A library page's card: the library's name big, its count and blurb, five of its images (one tall, four small)."""+ tiles = _tile(kind, files[0], d, "grid-row:1/3") + "".join(_tile(kind, f, d) for f in files[1:5])+ body = (f'<div class="l"><div class="brand">{LOGO.format(s=52)}Shisei</div><div class="big" style="font-size:80px;font-family:inherit">{html.escape(name)}</div>'+ f'<div class="line">{html.escape(line)}</div><div class="sub" style="word-break:keep-all">{html.escape(sub)}</div></div>'+ f'<div class="r" style="grid-template-columns:repeat(3,1fr);grid-template-rows:1fr 1fr">{tiles}</div>')+ return _page(loc, body)++def icon_page(size):# Full-bleed square: iOS and Android round the corners themselves.return (f'<!doctype html><style>html,body{{margin:0;width:{size}px;height:{size}px;overflow:hidden;background:#18181B}}'diff --git a/tools/site_pages.py b/tools/site_pages.pyindex f1a74e99..37929c32 100644--- a/tools/site_pages.py+++ b/tools/site_pages.py@@ -66,10 +66,23 @@ def list_join(loc, items):class Site:"""Build context: absolute site URL, strings, catalog, version, and where each page's files live."""- def __init__(self, site, repo, version, strings, poses, og):+ def __init__(self, site, repo, version, strings, poses, og, media=None):self.site = site.rstrip("/")self.repo, self.version, self.S, self.poses, self.og = repo, version, strings, poses, ogself.by_id = {p["id"]: p for p in poses}+ # Library images, and the library share cards, live on the image host when there is one (--media): a Pages+ # deployment holds 20,000 files and the site alone is near that. Absolute, with a trailing slash; None = here.+ self.media = media++ def lib_abs(self, path):+ """Absolute URL of a library image or library card: on the image host when there is one."""+ return (self.media or self.site + "/") + path++ def lib_card(self, loc, key, fallback):+ """(url, w, h) of a library card (an item id, or lib-<lib>); without cards, the given w900 image."""+ if self.og:+ return self.lib_abs(f"og/{loc}/{key}.png"), 1200, 630+ return self.lib_abs(fallback), 900, 1200def abs(self, path):return f"{self.site}/{path}"@@ -362,6 +375,96 @@ class Site:</feed>"""+ # ---- library item page: one per general-rated item (D-06, D-11), the page a library lightbox shares+ def item_page(self, loc, lib, D, items, i):+ """D: the library as its page reads it (build_site.library_data); items: its general-rated items, in order."""+ T = self.S[loc]+ c = items[i]+ key = f"{lib}/{c['id']}/"+ page = PREFIX[loc] + key+ rel = self.rel(page)+ home = rel + PREFIX[loc]+ L = T["libs"][lib]+ cats = {k["key"]: k["name"][loc] for k in D["cats"]}+ cat = cats.get(c["cat"], "")+ sub = c["sub"][loc] if c.get("sub") else ""+ name = c["n"][loc]+ names = [(T["libViews"][v], f, v) for v, f in zip(D["views"], c["v"]) if f]+ views = list_join(loc, [n for n, _, _ in names])+ n = len(names)+ title = fill(T["itemTitle"], name=name, lib=L["name"], id=c["id"])+ desc = fill(T["itemDesc"], name=name, lib=L["name"], cat=cat, n=n, views=views)+ alt = fill(T["itemOgAlt"], id=c["id"], name=name, views=views)+ base = self.media or rel+ img = lambda tier, f: f"{base}images/{D['dir']}/{tier}/{f}"+ absimg = lambda f: self.lib_abs(f"images/{D['dir']}/w900/{f}")+ main = c["v"][c["m"]]+ ld = {"@context": "https://schema.org", "@graph": [+ {"@type": "ImageGallery", "@id": self.abs(page), "url": self.abs(page), "name": title, "description": desc,+ "inLanguage": HTML_LANG[loc], "isPartOf": {"@type": "WebSite", "name": "Shisei", "url": self.abs(PREFIX[loc])},+ "primaryImageOfPage": absimg(main),+ "associatedMedia": [{"@type": "ImageObject", "contentUrl": absimg(f), "width": 900, "height": 1200,+ "name": f"{c['id']} {name} · {vn}", **({"caption": c["desc"]} if c.get("desc") else {}),+ "license": LICENSE, "acquireLicensePage": self.repo + "/blob/main/LICENSE-images",+ "creditText": "Shisei", "copyrightNotice": COPYRIGHT, "creator": {"@type": "Organization", "name": "Shisei"}}+ for vn, f, _ in names]},+ {"@type": "BreadcrumbList", "itemListElement": [+ {"@type": "ListItem", "position": 1, "name": "Shisei", "item": self.abs(PREFIX[loc])},+ {"@type": "ListItem", "position": 2, "name": L["name"], "item": self.abs(PREFIX[loc] + lib + "/")},+ {"@type": "ListItem", "position": 3, "name": f"{c['id']} {name}", "item": self.abs(page)}]}]}+ head = self.head(loc, key, title, desc, self.lib_card(loc, c["id"], f"images/{D['dir']}/w900/{main}"), alt, ld,+ page_type="article")+ others = "".join(f'<dt>{l.upper()}</dt><dd lang="{HTML_LANG[l]}">{esc(c["n"][l])}</dd>' for l in LOCS if l != loc)+ lib_home = f"{home}{lib}/"+ eager = lambda f: ' fetchpriority="high"' if f == main else ' loading="lazy"'+ figs = "".join(+ f'<figure class="pp-view"><a class="pp-tile" href="{lib_home}#{c["id"]}-{v}">'+ f'<img src="{img("w900", f)}" srcset="{img("w300", f)} 300w, {img("w600", f)} 600w, {img("w900", f)} 900w" sizes="(max-width: 720px) 50vw, 280px" '+ f'width="900" height="1200" alt="{esc(c["id"] + " " + name + " · " + vn)}"{eager(f)} decoding="async"></a>'+ f'<figcaption><span>{esc(vn)}</span><a href="{img("w900", f)}" download="shisei_{c["id"]}_{v}.webp">'+ f'{esc(T["downloadView"])}</a></figcaption></figure>' for vn, f, v in names)+ prev, nxt = items[i - 1], items[(i + 1) % len(items)]+ pn = lambda q, label, cls: (f'<a class="pp-pn-{cls}" href="../{q["id"]}/" rel="{"prev" if cls == "l" else "next"}">'+ f'<span>{esc(label)}</span><b>{q["id"]} · {esc(q["n"][loc])}</b></a>')+ same = [q for q in items if q["cat"] == c["cat"] and q["id"] != c["id"]][:8]+ rel_cards = "".join(+ f'<a class="pp-rel" href="../{q["id"]}/"><span class="pp-rel-t">'+ f'<img src="{img("w300", q["v"][q["m"]])}" alt="" width="300" height="400" loading="lazy" decoding="async"></span>'+ f'<span class="pp-rel-n"><b>{esc(q["n"][loc])}</b><span class="mono">{q["id"]}</span></span></a>' for q in same)+ related = (f"""+ <section class="pp-sec" aria-labelledby="rel-h">+ <h2 id="rel-h">{esc(T["relatedItems"])}</h2>+ <div class="pp-rels">{rel_cards}</div>+ </section>""" if same else "")+ share = (f'<button type="button" class="pill light small" data-share data-share-url="./" '+ f'data-share-heading="{esc(T["itemShareTitle"])}" '+ f'data-share-text="{esc(fill(T["itemShareText"], name=name, lib=L["name"]))}" data-share-image="{esc(absimg(main))}">'+ f'{SHARE_ICON}<span>{esc(T["share"])}</span></button>')+ meta = " · ".join(x for x in (c["id"], cat, sub, fill(T["viewsN"], n=n)) if x)+ desc_box = (f"""+ <section class="lb-desc pp-desc" aria-label="{esc(T["itemDescLabel"])}">+ <div class="lb-desc-h"><span>{esc(T["itemDescLabel"])}</span><button type="button" class="pill light tiny" data-copy="{esc(c["desc"])}">{esc(T["copy"])}</button></div>+ <p lang="en">{esc(c["desc"])}</p>+ </section>""" if c.get("desc") else "")+ body = f"""<main id="main" class="wrap page pose-page">+ <nav class="crumbs" aria-label="{esc(T["crumb"])}"><a href="{home}">Shisei</a><span aria-hidden="true">/</span><a href="{lib_home}">{esc(L["name"])}</a><span aria-hidden="true">/</span><a href="{lib_home}?cat={c["cat"]}#all">{esc(cat)}</a><span aria-hidden="true">/</span><span aria-current="page">{c["id"]}</span></nav>+ <header class="pp-head">+ <p class="pp-meta mono">{esc(meta)}</p>+ <h1>{esc(name)}</h1>+ <dl class="lb-names" aria-label="{esc(T["otherNames"])}">{others}</dl>+ <div class="pp-actions">+ <a class="pill dark small" href="{lib_home}#{c["id"]}-{D["views"][c["m"]]}">{esc(T["openInLibrary"])}</a>+ {share}+ </div>+ </header>{desc_box}+ <section class="pp-sec" aria-labelledby="angles-h">+ <h2 id="angles-h">{esc(T["viewsTitle"])}</h2>+ <div class="pp-views">{figs}</div>+ </section>+ <nav class="pp-pn" aria-label="{esc(T["prevItem"])} / {esc(T["nextItem"])}">{pn(prev, T["prevItem"], "l")}{pn(nxt, T["nextItem"], "r")}</nav>{related}+</main>"""+ return page, self.shell(loc, key, head, body, cls=f"item-page ip-{D['kind']}")+def not_found(self):"""One 404 for every language: hosts serve it at any depth, so links and assets are root-absolute."""root = "/" + self.site.split("://", 1)[1].split("/", 1)[1] + "/" if self.site.count("/") > 2 else "/"