diff --git a/scripts/sitegen/config.py b/scripts/sitegen/config.py index dff26ae42..95b5a5d59 100644 --- a/scripts/sitegen/config.py +++ b/scripts/sitegen/config.py @@ -19,12 +19,19 @@ yaml = require_yaml() STARLIGHT_DIR = "website" STARLIGHT_CONTENT = "src/content/docs" SITE_NAME = "RetroBIOS" -REPO_URL = "https://github.com/Abdess/retrobios" +REPO_SLUG = "Abdess/retrobios" +REPO_URL = f"https://github.com/{REPO_SLUG}" RELEASE_URL = f"{REPO_URL}/releases/latest" +# A release asset's address is this, its tag, a slash and the asset name. +RELEASE_DOWNLOAD = f"{REPO_URL}/releases/download/" +# The upload page of a folder is this followed by the folder. +UPLOAD_ROOT = f"{REPO_URL}/upload/main/" # What LICENSE grants over the published data: its MIT terms name the # metadata. The BIOS files themselves are under NOTICE, never this. DATA_LICENSE = "MIT (LICENSE: scripts, tooling, schemas, documentation and metadata)" -SITE_URL = "https://abdess.github.io/retrobios/" +SITE_ORIGIN = "https://abdess.github.io" +BASE = "/retrobios/" +SITE_URL = SITE_ORIGIN + BASE GENERATED_DIRS = ["platforms", "systems", "emulators", "wiki", "api", "downloads", "files", releaserecord.GET_DIR] # Generated directories of files served as they are, not pages. diff --git a/scripts/sitegen/measurements.py b/scripts/sitegen/measurements.py index 7dd5bf051..fd399a3d7 100644 --- a/scripts/sitegen/measurements.py +++ b/scripts/sitegen/measurements.py @@ -36,8 +36,9 @@ from sitegen import markup from core.artifacts import json_text, write_if_changed from sitegen.render import escape_tags from core.paths import REPO_ROOT +from sitegen.config import REPO_URL -REPO = "https://github.com/Abdess/retrobios" +REPO = REPO_URL EXPLORER_PAGE = "measurements.md" METHOD_PAGE = "wiki/measurements.md" HOSTS_MARKER = "" diff --git a/scripts/sitegen/pagemarkdown.py b/scripts/sitegen/pagemarkdown.py index f6a94612c..6b5a72050 100644 --- a/scripts/sitegen/pagemarkdown.py +++ b/scripts/sitegen/pagemarkdown.py @@ -12,11 +12,10 @@ from pathlib import Path from typing import ClassVar from core.paths import REPO_ROOT -from sitegen.config import build_commit +from sitegen.config import BASE, SITE_ORIGIN, build_commit -SITE = "https://abdess.github.io" -BASE = "/retrobios/" +SITE = SITE_ORIGIN # Elements whose content is never words a reader needs. SKIPPED = frozenset({"script", "style", "svg", "button", "nav", "template", "noscript", "video"}) HEADINGS = {f"h{n}": n for n in range(1, 7)} diff --git a/scripts/sitegen/readme.py b/scripts/sitegen/readme.py index e837cda93..c5b8b158c 100644 --- a/scripts/sitegen/readme.py +++ b/scripts/sitegen/readme.py @@ -30,6 +30,7 @@ from model.systems import system_index from packs.coverage import verify_platform from resolve.cores import resolve_platform_cores from resolve.review import LARGE_FILE_ISSUE_URL +from sitegen.config import REPO_SLUG, REPO_URL, SITE_URL, UPLOAD_ROOT from sitegen.install import display_name, has_release_pack, platform_display @@ -432,15 +433,14 @@ def collection_line(total_files: int, comp: dict) -> str: ) -SITE_URL = "https://abdess.github.io/retrobios/" # The installer demo (scripts/make_demo.py): the recording and what it shows. DEMO_DIR = REPO_ROOT / "docs_assets" / "demo" DEMO_GIF = "docs_assets/demo/install.gif" REPO_PATH = "../.." -REPO = "Abdess/retrobios" +REPO = REPO_SLUG # GitHub's "Add file > Upload files" page for bios/: a browser upload by # someone without write access lands on a fork and opens a pull request. -UPLOAD_URL = f"https://github.com/{REPO}/upload/main/bios" +UPLOAD_URL = f"{UPLOAD_ROOT}bios" def clone_line(db: dict) -> str: @@ -556,8 +556,8 @@ def _catalog_matched_line(db: dict) -> list[str]: BADGES = ( ("PyPI version", "https://img.shields.io/pypi/v/retrobios", "https://pypi.org/project/retrobios/"), ("Validation", - "https://github.com/Abdess/retrobios/actions/workflows/validate.yml/badge.svg?branch=main", - "https://github.com/Abdess/retrobios/actions/workflows/validate.yml"), + f"{REPO_URL}/actions/workflows/validate.yml/badge.svg?branch=main", + f"{REPO_URL}/actions/workflows/validate.yml"), ) diff --git a/scripts/sitegen/starlight.py b/scripts/sitegen/starlight.py index 53a82fdf6..cac4229b2 100644 --- a/scripts/sitegen/starlight.py +++ b/scripts/sitegen/starlight.py @@ -22,9 +22,8 @@ from pathlib import Path, PurePosixPath from core.paths import REPO_ROOT from core.anchors import unique_anchor, toc_slug +from sitegen.config import BASE, SITE_URL -BASE = "/retrobios/" -SITE_URL = "https://abdess.github.io/retrobios/" # Components a page body may use, and where each comes from. COMPONENTS = { diff --git a/scripts/sitegen/validate.py b/scripts/sitegen/validate.py index 5f5e876fb..d9ddf900b 100644 --- a/scripts/sitegen/validate.py +++ b/scripts/sitegen/validate.py @@ -11,6 +11,8 @@ from html.parser import HTMLParser from pathlib import Path from urllib.parse import unquote, urlsplit +from sitegen.config import BASE, RELEASE_DOWNLOAD, SITE_NAME + @dataclass @@ -352,7 +354,7 @@ def _jsonld_issues(page: Page, is_404: bool) -> list[str]: return messages -def description_template(page: Page, site_name: str = "RetroBIOS") -> str: +def description_template(page: Page, site_name: str = SITE_NAME) -> str: """A page's description with its own names taken out: its h1 and its window title. What is left is the text it shares with its template.""" text = page.descriptions[0] if page.descriptions else "" @@ -405,9 +407,6 @@ def _check_links(pages: dict, site: Path, base_path: str) -> list[str]: return issues -RELEASE_DOWNLOAD = "https://github.com/Abdess/retrobios/releases/download/" - - def _check_get_pages( pages: dict, site: Path, platforms_dir: Path, record_path: Path, ) -> list[str]: @@ -451,7 +450,7 @@ def _check_get_pages( def validate_site( - site: Path, base_path: str = "/retrobios/", platforms_dir: Path | None = None, + site: Path, base_path: str = BASE, platforms_dir: Path | None = None, record_path: Path | None = None, ) -> list[str]: site = site.resolve() diff --git a/scripts/sitegen/versions.py b/scripts/sitegen/versions.py index 8af23562b..5f2f97e03 100644 --- a/scripts/sitegen/versions.py +++ b/scripts/sitegen/versions.py @@ -11,7 +11,7 @@ from model import siteinputs from model.composition import count_catalog_matched from model.platforms import load_platform_config from model.profiles import unique_emulator_profiles -from sitegen.config import RELEASE_URL, REPO_URL +from sitegen.config import RELEASE_DOWNLOAD, RELEASE_URL, REPO_URL from sitegen.install import display_name @@ -72,7 +72,7 @@ def release_line(platform_name: str, record: dict) -> list[str]: pack_name = releaserecord.pack_name_for(platform_name, record) if not tag or not pack_name: return [] - base = f"{REPO_URL}/releases/download/{tag}" + base = f"{RELEASE_DOWNLOAD}{tag}" built = _release_date(tag) lines = [ f"Pack {tag}{f', built {built}' if built else ''}. " diff --git a/scripts/sitegen/wanted.py b/scripts/sitegen/wanted.py index eb0cb17df..687c16680 100644 --- a/scripts/sitegen/wanted.py +++ b/scripts/sitegen/wanted.py @@ -29,13 +29,12 @@ from packs.crossref import first_hash from core.hashing import cut_md5_owner, parse_hash_list from resolve.review import LARGE_FILE_ISSUE_URL, Placement, placement from resolve.validation import deliverable, filter_files_by_mode, installed_with_emulator +from sitegen.config import UPLOAD_ROOT ALGORITHMS = ("sha1", "sha256", "md5", "crc32") # GitHub's upload page takes 25 MB per file. A larger file goes in by a # push or, past 100 MB, through the issue form (CONTRIBUTING.md). BROWSER_UPLOAD_LIMIT = 25 * 1024 * 1024 -# The upload page of a folder is this followed by the folder. -UPLOAD_ROOT = "https://github.com/Abdess/retrobios/upload/main/" # Under the site's public folder, read by WantedFiles.astro. DATA_FILE = "data/wanted.json"