diff --git a/.github/scripts/site.py b/.github/scripts/site.py index 4410381..0191f70 100644 --- a/.github/scripts/site.py +++ b/.github/scripts/site.py @@ -1,9 +1,10 @@ """Writes the mods' site into site/: the index page, which browses the mods by category, with each mod's thumbnail, name, version, author, what it needs, its description and the download of its latest release; a page for each mod, mods//, with its pictures, what it is, its download, its -total downloads and its releases; updates/, every mod's releases, newest first; and mods.json, the +total downloads and its releases; updates/, every mod's releases, newest first; mods.json, the released mods as data, which OpenReliant's GET MODS screen reads to list and install them from the -game. +game; and sitemap.xml, the pages for search engines, which robots.txt at the root of +openreliant.github.io names. python3 .github/scripts/site.py """ @@ -22,8 +23,16 @@ SITE = ROOT / "site" # The site's address. mods.json uses absolute links, since the game reads it from anywhere. SITE_URL = "https://openreliant.github.io/openreliant-mods/" -# OpenReliant's icon, which OpenReliant's own site publishes: the pages' favicon. +# OpenReliant's icon, which OpenReliant's own site publishes: the pages' favicon, and the picture a +# link to a page without one of its own shows. ICON_URL = "https://openreliant.github.io/openreliant/icon/" +# The site's name, which every page's title ends with, so that a search for StarLancer's mods +# finds it. +SITE_NAME = "StarLancer mods for OpenReliant" +# The longest description of a page, about what a search result shows, and the shortest that is +# cut at the end of a sentence rather than at a word. +LONGEST_DESCRIPTION = 160 +SHORTEST_DESCRIPTION = 80 # The format number of mods.json. Raise it when a key changes meaning. Adding a key doesn't need # it: OpenReliant ignores keys it doesn't know. INDEX_FORMAT = 1 @@ -302,7 +311,7 @@ how.textContent = "Here's how to send it in"; emptyText.append(how, "."); } else emptyText.append("No mods here match the search."); - document.title = here.path ? `${here.name}: OpenReliant mods` : "OpenReliant mods"; + document.title = here.path ? `${here.name}: ${document.body.dataset.site}` : document.body.dataset.site; } search.addEventListener("input", () => { state.q = search.value.trim(); history.replaceState(null, "", address(state.category)); show(); }); @@ -332,18 +341,33 @@ """ -def page(title: str, description: str, current: str, base: str, body: str, scripts: list[str]) -> str: - """A page of the site, with the top bar's `current` link lit: `body` under it, then `scripts`. - `base` leads from the page back to the site's top, such as ../ from updates/.""" +def page(title: str, description: str, path: str, current: str, base: str, body: str, scripts: list[str], image: str = "") -> str: + """The page of the site at `path` from its top, such as updates/, with the top bar's `current` + link lit: `body` under it, then `scripts`. `base` leads from the page back to the site's top, + such as ../ from updates/. The title ends with the site's name, and the description is cut to + fit a search result (`shortened`). `image`, a picture's address, is what a link to the page + shows in chats and on social sites, and OpenReliant's icon without one.""" lit = lambda name: ' current' if name == current else '' script_tags = "".join(f"" for script in scripts) + text = html.escape + full_title = f"{title}: {SITE_NAME}" if title else SITE_NAME + summary = shortened(description) + address = SITE_URL + path return f""" -{html.escape(title)} - +{text(full_title)} + + + + + + + + + @@ -352,7 +376,7 @@ def page(title: str, description: str, current: str, base: str, body: str, scrip - +