Give every page that lists trails the search box and the filters that have something to offer, however few trails it holds

The cutoff of ten trails is gone, so 48 of the 60 state and province pages, the small lists and each route author's page now have the bar. A set that nothing can narrow gets the search box alone, and an option no trail has is not written. In the state-pages golden file only the hashes of the ten pages that differ changed, each by the added bar and nothing else.
This commit is contained in:
swaits committed 2026-11-20 13:48:07 -07:00
1 parent fd2e6fc6c7
commit a806522ee1
6 files changed
+53 -41

No files matched your search

+1 -1
View File
@@ -312,7 +312,7 @@ def author_page(g, records, site, all_pages):
+ " · ".join(f'<a href="{esc(path(x))}">{esc(x["name"])}</a> ({len(x["routes"])})' for x in nav_items) + "</nav>") if nav_items else ""
more = str(summary.facts(routes, records, by_authors=False)) if n >= 3 else ""
briefs = "".join(f'<h3><a href="{esc(common.trail_path(r))}">{esc(common.plain_name(r))}</a></h3>\n{trail.brief(r)}\n' for r in routes)
listing = home.results(groups=[(None, routes, regions.route_guides)], routes_list=True, top=2,
listing = home.listing(groups=[(None, routes, regions.route_guides)], routes_list=True, top=2,
by=lambda r: with_html(g, r, by_name))
route_title = "About the route" if n == 1 else "About each route"
bio = about_html(g)
+8 -14
View File
@@ -239,17 +239,13 @@ def entry(rec, *, level=3, extra="", routes_list=False, hidden=False, eager=Fals
# The filters ------------------------------------------------------------------
# One bar and one set of panels, on the home page and on every other page that shows a set of at
# least FILTER_MIN trails (listing()), and on every park, range and wilderness page whatever its
# size (the owner's rule: every set of trails gets the bar). Everything is built from the page's own trails: a facet that
# One bar and one set of panels, on the home page and on every other page that shows a set of
# trails (listing()), whatever its size (the owner's rule: every set of trails gets the bar). Everything is built from the page's own trails: a facet that
# cannot narrow them is left out, and an option none of them has is not written. The numbers written
# here are for the whole set; app.js counts again from the rows on the page every time anything
# changes, and hides an option that would show nothing (its counting is facetCounts(), which
# web/tests/test_filter_counts.py runs under node against counts made here from the records).
FILTER_MIN = 10
def _length_options(steps, selected_any_last, unit="mi"):
opts = [f'<option value="{step_value(n, unit)}">{step_label(n, unit)}</option>' for n in steps]
if selected_any_last:
@@ -443,15 +439,13 @@ def finder_form(records, c=None, steps=None, where="all", bare_if_empty=False):
</form>"""
def listing(recs=None, *, where="all", groups=None, always=False, **kw):
"""The rows of a page that shows a set of trails, with the filter bar over them when the set
has at least FILTER_MIN trails (else results() alone); with always, whatever its size (the
bar then holds only the filters that have something to offer). where: the Where filter's
scope (finder_form). The other arguments are results()'s."""
def listing(recs=None, *, where="all", groups=None, **kw):
"""The rows of a page that shows a set of trails, with the filter bar over them whatever the size
of the set (the bar holds only the filters that have something to offer, and the search box
alone where nothing can narrow the set). where: the Where filter's scope (finder_form). The
other arguments are results()'s."""
trails = [r for g in groups for r in g[1]] if groups is not None else list(recs)
if len(trails) < FILTER_MIN and not always:
return results(recs, groups=groups, **kw)
return Markup(f"""<div class="finder__bar">{finder_form(trails, where=where, bare_if_empty=always)}</div>
return Markup(f"""<div class="finder__bar">{finder_form(trails, where=where, bare_if_empty=True)}</div>
{results(recs, groups=groups, finder=True, **kw)}""")
+1 -1
View File
@@ -75,7 +75,7 @@ def _kind():
kicker=_kicker, crumbs=_crumbs, lede=_lede, where="all", wholly=False,
facts_place=lambda info: (_in_name(info), ()), title_options=_title_options,
description=_description, box=lambda info: info.get("box"), nav=_nav,
in_name=_in_name, phrase=_phrase, always_filters=True)
in_name=_in_name, phrase=_phrase)
PARK = _kind()
+1 -2
View File
@@ -309,7 +309,6 @@ class PageKind:
nav: object
in_name: object = None
phrase: object = None
always_filters: bool = False # the filter bar whatever the number of trails
def _state_kicker(info):
@@ -433,7 +432,7 @@ def place_page(info, records, site, kind, *, facet_pages=(), place_links=""):
</div></header>
</div></div>
<div class="container section place">
{home.browse_view(home.listing(recs, top=2, where=kind.where, wholly=wholly, always=kind.always_filters), home.overview_map(recs, f"Map of the trails {phrase}", place=kind.box(info)),
{home.browse_view(home.listing(recs, top=2, where=kind.where, wholly=wholly), home.overview_map(recs, f"Map of the trails {phrase}", place=kind.box(info)),
about=f"{summary.facts(recs, records, place=place)}{summary.details(recs)}",
about_title=f"About the trails {phrase}")}
{nav}{place_links}