From 2a56815f3439a84ee8b05d9c454138a2f8c6615e Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Fri, 20 Nov 2026 12:29:57 -0700 Subject: [PATCH] Show a trail's park, range and wilderness links at the foot of its page on a phone, where the glance hides them Co-Authored-By: Claude Sonnet 5.5 --- web/assets/style.css | 4 ++++ web/olt/trail.py | 13 +++++++++++++ web/tests/test_place_links.py | 13 +++++++++++++ 3 files changed, 30 insertions(+) diff --git a/web/assets/style.css b/web/assets/style.css index 342659e..5ec7c69 100644 --- a/web/assets/style.css +++ b/web/assets/style.css @@ -2108,7 +2108,11 @@ td .linklist a { font-weight: 400; } /* Below the two-column page the panel shows its first facts, so the map is on the first screen; a button opens the rest. Without JavaScript every fact shows and the button is not offered. */ .glance__toggle { display: none; } +/* The place links also stand alone at the foot of the page on a narrow screen, where the glance + keeps the Where row behind its button; on a wide one the glance shows them. */ +.trail-places { display: none; margin-block-start: 0; margin-block-end: var(--space-6); } @media (max-width: 63.99rem) { + html.js .trail-places { display: block; } html.js .glance:not([data-all]) .glance__facts > div:nth-child(n+5), html.js .glance:not([data-all]) > .note { display: none; } html.js .glance__toggle { diff --git a/web/olt/trail.py b/web/olt/trail.py index 5dc34c2..678bbd3 100644 --- a/web/olt/trail.py +++ b/web/olt/trail.py @@ -92,6 +92,18 @@ def place_links(rec, infos): return Markup(", ".join(f'{esc(i["name"])}' for i in mine)) +def places_nav(rec, infos): + """The same place links as the glance's Where row, as a line at the foot of the page. On a + phone the glance shows only its first facts until "All the facts" is tapped, and the Where + row is not among them; this line is shown there (style.css, .trail-places) so the links are + on the page without a tap. "" when the trail is in no place that has a page.""" + links = place_links(rec, infos) + if not links: + return "" + return Markup(f'') + + _ORG_CUT = re.compile(r", who |, with | publishes |; (?=[a-z])| \((?=[a-z])| \((?=[^)]*geometry)") @@ -1879,6 +1891,7 @@ def render(rec, site, records=None, author_links=None, place_infos=()): {profile}
+ {places_nav(rec, place_infos)} {onward(rec, records, place_infos)} {page_foot(rec, site)} {about_data(rec, site, author_links)} diff --git a/web/tests/test_place_links.py b/web/tests/test_place_links.py index b8dbfc3..e67d258 100644 --- a/web/tests/test_place_links.py +++ b/web/tests/test_place_links.py @@ -126,6 +126,19 @@ class TrailLinkTest(unittest.TestCase): self.assertNotIn("/parks/small/", body) self.assertIn("More in the Wind River Range", body) # the ways onward + def test_the_place_links_are_also_on_the_page_for_a_phone_outside_the_glance(self): + body = str(trail.render(self.rec, S, self.records, place_infos=self.infos)[2]) + foot = body[body.index('class="container trail-more"'):] + self.assertIn('")]) + self.assertLess(foot.index("trail-places"), foot.index('class="onward"')) + css = open(os.path.join(WEB, "assets", "style.css"), encoding="utf-8").read() + narrow = css[css.index("@media (max-width: 63.99rem)", css.index(".trail-places")):] + self.assertIn("html.js .trail-places { display: block; }", narrow[:200]) + plain = str(trail.render(self.rec, S, self.records)[2]) + self.assertNotIn("trail-places", plain) + def test_a_trail_with_no_place_page_is_unchanged(self): plain = str(trail.render(self.rec, S, self.records)[2]) self.assertNotIn("/ranges/wind-river-range/", plain)