diff --git a/scripts/generate_site.py b/scripts/generate_site.py index 99f15f80a..c222ba787 100644 --- a/scripts/generate_site.py +++ b/scripts/generate_site.py @@ -4887,6 +4887,8 @@ def generate_files_page() -> str: "`scph5501.bin`, the PlayStation BIOS v3.0. " "To look a file up by its name, use the search at the top of the page.", "", + "Have a file the collection lacks? [See if it is wanted](../wanted.md).", + "", "## Permanent links", "", "A file's card lives on its manufacturer's page, and a file refiled " diff --git a/scripts/sitewanted.py b/scripts/sitewanted.py index 206283fc6..4753cba01 100644 --- a/scripts/sitewanted.py +++ b/scripts/sitewanted.py @@ -336,7 +336,9 @@ def page(known: int) -> str: "3. A check reads the file and says if it fits. Then we add it.", "", (f"The page knows {known:,} wanted files by their hash, a fingerprint of the contents. " - "The rest are listed on [the gaps page](gaps.md). " + "The rest are listed on [the gaps page](gaps.md)."), + "", + ("To look up any file, use [Find or check a file](files/index.md). " "More ways to help are on [Contributing](contributing.md)."), "", ]) diff --git a/tests/test_site_components.py b/tests/test_site_components.py index a3521afde..513974d5e 100644 --- a/tests/test_site_components.py +++ b/tests/test_site_components.py @@ -189,6 +189,38 @@ class SectionTabsInTheHeader(unittest.TestCase): self.assertRegex(nav.group(1), r'aria-current="true"[^>]*>\s*Start here') +class TheWantedPageIsInTheBar(unittest.TestCase): + """The wanted page is the site's call to contribute: in the bar on every + page, beside the search and menu buttons on a phone, where the section + tabs fold into the menu.""" + + LINK = re.compile(r']*)>Wanted files') + + def test_the_bar_holds_it_outside_the_tabs(self): + header = _read(COMPONENTS / "Header.astro") + bar = header[header.index('
")] + self.assertIn('class="rb-wanted-link print:hidden"', bar) + self.assertIn("aria-current={onWanted ? 'page' : undefined}", bar) + # Theme colours only, the same in both themes' variables. + style = header[header.index(".rb-wanted-link {"):header.index("@media")] + self.assertNotRegex(style, r"#[0-9a-fA-F]{3,6}\b") + # At 360 px the name was cut to "Retr": the logo stays, the name is + # kept for screen readers only. + narrow = header[header.index("@media (max-width: 26.99rem)"):] + self.assertIn(".site-title span {", narrow[:200]) + self.assertIn("clip-path: inset(50%);", narrow[:400]) + + def test_built_on_every_page_current_on_its_own(self): + for page in ("which-pack", "files", "systems"): + with self.subTest(page=page): + found = self.LINK.search(_built(page)) + self.assertIsNotNone(found) + self.assertNotIn("aria-current", found.group(1)) + own = self.LINK.search(_built("wanted")) + self.assertIsNotNone(own) + self.assertIn('aria-current="page"', own.group(1)) + + def _title_block(html: str) -> str: """What PageTitle draws: from the main column to the h1.""" end = html.index('id="_top"') diff --git a/tests/test_site_wanted.py b/tests/test_site_wanted.py index 307063c97..c41a5386a 100644 --- a/tests/test_site_wanted.py +++ b/tests/test_site_wanted.py @@ -300,6 +300,15 @@ class ThePageReadsTheListAsTheResolverDoes(_World): self.assertEqual(self._page(WANTED, "b.bin")["issue"], validate_pr.large_file_issue_url(result)) +class TheTwoPagesLinkEachOther(unittest.TestCase): + """files/ checks any file, wanted/ the ones the collection lacks: each + sends a reader to the other in one line.""" + + def test_links(self): + self.assertIn("[See if it is wanted](../wanted.md)", generate_site.generate_files_page()) + self.assertIn("[Find or check a file](files/index.md)", sitewanted.page(1)) + + class ThePublishedList(unittest.TestCase): """The list generate_site.py wrote, against the collection: nothing it holds, every folder by validate_pr, and light enough for a phone.""" diff --git a/website/src/components/Header.astro b/website/src/components/Header.astro index b8d5299b4..4dd6f1ca5 100644 --- a/website/src/components/Header.astro +++ b/website/src/components/Header.astro @@ -3,12 +3,20 @@ // tabs: the funnel (Start here to Contribute) is the site's structure, so it // sits where every docs site puts its sections. On a phone the tabs stay the // first row of the menu, where the sidebar lists them. +// The wanted page is the one call to contribute, in the bar on every page +// and every width: on a phone it sits beside the search and menu buttons. import Default from '@astrojs/starlight/components/Header.astro'; const topics = Astro.locals.starlightSidebarTopics?.topics ?? []; +const base = import.meta.env.BASE_URL.replace(/\/?$/, '/'); +const wanted = `${base}wanted/`; +const onWanted = Astro.url.pathname.replace(/\/?$/, '/') === wanted; --- - + { topics.length > 0 && (