Show a trail's other links, and the lists the site was checked against
A trail's page lists its [[link]] entries under the main buttons, as "More about this trail": the page's title, then who publishes it. The official site stays the main button. A trail with no official site gets its first link in that place, named by its publisher, and that link is not repeated in the list. The About page shows the README's new "Other lists of long trails" section. Tests updated for the new trail counts, and for there being no trail left that spans a whole country. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c716c3c62
commit
94015cd86b
8 files changed
+108
-14
No files matched your search
+1
-1
@@ -288,7 +288,7 @@ def about_page(records, site, repo_root):
|
||||
|
||||
what = quoted("What this is, and what it is not", "The dataset’s own words")
|
||||
rule = quoted("Inclusion rule", "The rule as the dataset states it")
|
||||
rest = link_requests(render_sections(readme, site, ["How to use it", "Licences", "Report an error"]), site)
|
||||
rest = link_requests(render_sections(readme, site, ["How to use it", "Other lists of long trails", "Licences", "Report an error"]), site)
|
||||
contrib = render_doc(read_doc(repo_root, "CONTRIBUTING.md"), site, heading_offset=1)
|
||||
cards = "".join(
|
||||
f'<li><a href="{esc(href)}">{esc(title)}</a><small>{esc(what_)}</small></li>'
|
||||
|
||||
@@ -169,6 +169,11 @@ def page_head(rec):
|
||||
official = official_link(rec)
|
||||
if official:
|
||||
actions.append(f'<a class="button button--link" href="{esc(official[0])}">{esc(official[1])} {common.ICON_EXTERNAL}</a>')
|
||||
elif more_links(rec):
|
||||
# No page of its own: the first of the pages about the trail stands in, named by its publisher.
|
||||
first = more_links(rec)[0]
|
||||
actions.append(f'<a class="button button--link" href="{esc(first["url"])}">'
|
||||
f'{esc(first["publisher"])} {common.ICON_EXTERNAL}</a>')
|
||||
if rec["derived"].get("downloads"):
|
||||
actions.append(f'<a class="button button--primary" href="#download">{common.ICON_DOWNLOAD}Download the GPX</a>')
|
||||
else:
|
||||
@@ -191,6 +196,7 @@ def page_head(rec):
|
||||
</header>
|
||||
<p class="trail-lede">{lede}</p>
|
||||
<p class="cluster trail-actions">{"".join(actions)}</p>
|
||||
{links_panel(rec)}
|
||||
</div>
|
||||
</div>"""
|
||||
|
||||
@@ -608,6 +614,27 @@ def guide_card(g, i):
|
||||
</li>"""
|
||||
|
||||
|
||||
def more_links(rec):
|
||||
return [l for l in rec.get("link", []) if isinstance(l, dict) and l.get("url")]
|
||||
|
||||
|
||||
def links_panel(rec):
|
||||
"""Other pages about this trail, under the buttons at the head of the page and quieter than them."""
|
||||
links = more_links(rec)
|
||||
# With no official site, the first link stands in for that button and is not repeated here.
|
||||
if not official_link(rec):
|
||||
links = links[1:]
|
||||
if not links:
|
||||
return ""
|
||||
items = "".join(
|
||||
f'<li><a href="{esc(l["url"])}">{esc(l.get("title", ""))} {common.ICON_EXTERNAL}</a>'
|
||||
f' <span class="morelinks__by">{esc(l.get("publisher", ""))}</span>'
|
||||
+ (f'<small>{esc(l["note"])}</small>' if l.get("note") else "") + "</li>"
|
||||
for l in links)
|
||||
return (f'<section class="morelinks" aria-labelledby="morelinks-title">'
|
||||
f'<h2 id="morelinks-title">More about this trail</h2><ul>{items}</ul></section>')
|
||||
|
||||
|
||||
def guides_panel(rec):
|
||||
guides = rec.get("guide", [])
|
||||
if not guides:
|
||||
|
||||
Reference in new issue
Block a user