From 3997c7286ed42b51ec069538b19368fc04cdf15f Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Fri, 20 Nov 2026 13:49:40 -0700 Subject: [PATCH] Put a row of jump links at the very top of the Places page: States and provinces, Parks, Mountain ranges and Wilderness areas, each with its number of pages The row shows at every screen size on one compact line that wraps on a phone, and a kind with no pages is left out. The strip of regional groups below the heading no longer repeats the three kinds. --- web/assets/style.css | 6 ++++++ web/olt/regions.py | 14 ++++++++++---- web/tests/test_place_links.py | 28 +++++++++++++++++----------- 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/web/assets/style.css b/web/assets/style.css index c4222d2..de55663 100644 --- a/web/assets/style.css +++ b/web/assets/style.css @@ -2298,6 +2298,12 @@ td .linklist a { font-weight: 400; } .lists-row li { flex: none; } .lists-row a { min-block-size: 2.75rem; } } +/* The Places hub's jump row: one compact line at the very top, States and provinces and each kind of + place with its number of pages; it wraps on a phone rather than scrolling. */ +.places-jump { margin-block-end: var(--space-1); } +.places-jump ul { display: flex; flex-wrap: wrap; gap: 0 var(--space-4); padding: 0; list-style: none; font: 600 0.85rem/1.3 var(--font-sans); } +.places-jump a { display: inline-flex; align-items: center; min-block-size: 2.25rem; color: var(--link); } +.places-jump__n { margin-inline-start: 0.35em; color: var(--ink-2); font-weight: 400; font-variant-numeric: tabular-nums; } .section--finder { padding-block-start: var(--space-4); } .pills { display: flex; flex-wrap: wrap; gap: var(--space-2); } .pills .check { grid-template-columns: auto auto; padding: 0.15rem var(--space-2); border: 1px solid var(--rule-strong); border-radius: 999px; } diff --git a/web/olt/regions.py b/web/olt/regions.py index 48bd3c5..f164d8b 100644 --- a/web/olt/regions.py +++ b/web/olt/regions.py @@ -166,8 +166,9 @@ def regions_index_page(records, site, infos=()): a page (olt/places.py collect); each kind that has any gets a section of its own.""" by_slug, across = collect_regions(records) place_infos = list(infos.values()) if isinstance(infos, dict) else list(infos or ()) - blocks = "" + blocks = '' jump = [] + kinds = [] for g, name, keys in facets.PLACE_GROUPS: infos = sorted((by_slug[k.lower()] for k in keys if k.lower() in by_slug), key=lambda i: i["name"]) if not infos: @@ -200,7 +201,7 @@ def regions_index_page(records, site, infos=()): f'
  • {esc(i["name"])}' f'{_plural(len(i["records"]))}
  • ' for i in mine) - jump.append(f'
  • {esc(kind.hub_title)}{len(mine)}
  • ') + kinds.append(f'
  • {esc(kind.hub_title)} {len(mine)}
  • ') blocks += f"""

    {esc(kind.hub_title)}

    @@ -214,12 +215,17 @@ def regions_index_page(records, site, infos=()): foot = f'\n

    Places with no listed trail: {links}.

    ' n_us = sum(1 for r in records if "US" in common.countries(r)) n_ca = sum(1 for r in records if "CA" in common.countries(r)) - body = f"""
    + # One compact row at the very top, whatever the screen: the states and provinces and each kind of + # place that has pages, each with its exact number of pages. + row = (f'') if kinds else "" + body = f"""
    {row}

    Places

    The {len(records)} trails by state and province, grouped into parts of the United States ({n_us}) and Canada ({n_ca}). A trail that crosses several states is on each one’s page.{lede_more}

    -
    +
    {blocks}
    {foot}""" description = (f"Where the {len(records)} long trails and routes are: {n_us} in the United States and {n_ca} in Canada, " f"by state and province, with the number in each.") diff --git a/web/tests/test_place_links.py b/web/tests/test_place_links.py index 4e66214..7cf065a 100644 --- a/web/tests/test_place_links.py +++ b/web/tests/test_place_links.py @@ -48,18 +48,24 @@ class HubTest(unittest.TestCase): self.assertIn("Parks, mountain ranges and wilderness areas with three or more " "trails have pages too.", re.sub(r"\s+", " ", body)) - def test_the_shortcut_strip_links_each_kind_that_has_pages(self): + def test_a_jump_row_tops_the_hub_with_exact_counts_of_pages(self): _, _, body = regions.regions_index_page(self.records, S, infos=self.infos) - strip = str(body)[str(body).index('