Give the Routes page one count of authors
Mirror to forge / mirror (push) Canceled after 0s
Validate / validate (push) Canceled after 0s
Validate / history (push) Canceled after 0s
Validate / site (push) Canceled after 0s
Validate / deploy (push) Canceled after 0s

The meta description counted distinct credit lines (43) while the page
counted authors with a page (45). Both now use the number of authors
listed on /authors/, and a test holds them equal.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-17 07:14:31 -07:00
1 parent 298f1b9fd9
commit 51a393ec40
3 files changed
+28 -2

No files matched your search

+3 -2
View File
@@ -214,10 +214,11 @@ def routes_page(records, site, repo_root=None, after="", author_pages=None, n_au
groups = [(f"By {author_pages[a]}" if a in author_pages else f"By {esc(a)}", sorted(by_author[a], key=home.sort_name), route_guides)
for a in sorted(by_author, key=str.lower)]
n_gpx = _gpx_count(routes)
n_authors_said = n_authors or len(by_author) # one figure for the intro, the head and the description
intro = f"""<p>Every other trail on this site is an official trail. Being a route says who looks after it, not
how rough it is: some routes are on maintained trail all the way, and some official trails have
long road walks. The Walking line on each trail&rsquo;s page says what the walking is.</p>
<p>{_plural(len(routes), "route")}, by {n_authors or len(by_author)} authors. {n_gpx} {"has" if n_gpx == 1 else "have"} a GPX here; for the rest,
<p>{_plural(len(routes), "route")}, by {n_authors_said} authors. {n_gpx} {"has" if n_gpx == 1 else "have"} a GPX here; for the rest,
each route&rsquo;s page says whether its author gives the track away, sells it, or does not publish it.
<a href="/?kind=route">Narrow them with the filters</a>.</p>"""
head_count = (f'\n <p class="page-head__lede">{_plural(len(routes), "route")} by <a href="/authors/">{_plural(n_authors, "author")}</a></p>'
@@ -234,7 +235,7 @@ def routes_page(records, site, repo_root=None, after="", author_pages=None, n_au
{after}
<nav class="region-nav" aria-label="Other lists">{'<a href="/authors/">Route authors</a> · ' if linked else ""}<a href="/lists/">All lists</a> · <a href="/">Every trail</a></nav>
</div>"""
description = (f"{_plural(len(routes), 'route')} in the United States and Canada by {len(by_author)} authors, "
description = (f"{_plural(len(routes), 'route')} in the United States and Canada by {n_authors_said} authors, "
f"with their guides{f' and {n_gpx} with a GPX here' if n_gpx else ''}.")
return (browse.by_key("routes").search_title(len(routes)), common.cut_at_word(description, common.DESCRIPTION_LIMIT),
Markup(body), home.has_overview_map(routes))
+20
View File
@@ -68,6 +68,26 @@ class ExtraPagesTest(unittest.TestCase):
self.assertIn(f'href="/trails/{r["id"]}/"', page, r["id"])
self.assertIn(r["route"]["creator"], text, r["id"])
def test_routes_page_author_count_is_the_one_on_the_authors_page(self):
"""The Routes page's visible line, its meta description and its intro say the same number of
authors, and it is the number of authors listed on /authors/ (one page each)."""
import html as _html
from olt import authors
n = len(authors.author_pages(self.records, ROOT))
page = read_out("routes/index.html")
visible = re.search(r'<p class="page-head__lede">\d+ routes? by <a href="/authors/">(\d+) authors?</a>', page)
meta = re.search(r'<meta name="description" content="([^"]*)"', page)
intro = re.search(r"by (\d+) authors\. ", _html.unescape(re.sub(r"<[^>]+>", "", page)))
self.assertTrue(visible and meta and intro)
described = re.search(r"by (\d+) authors", _html.unescape(meta.group(1)))
self.assertEqual(int(visible.group(1)), n)
self.assertEqual(int(described.group(1)), n)
self.assertEqual(int(intro.group(1)), n)
index = read_out("authors/index.html")
self.assertIn(f"worked out by {n} authors", index)
listed = {m for m in re.findall(r'href="(/authors/[^/"]+/)"', index)}
self.assertEqual(len(listed), n)
def test_ways_into_the_authors_pages_are_routes(self):
"""A route's row names its author as a link to their page (each named person who has one);
the Routes page head counts routes and authors and links /authors/; /lists/ lists Route