Show each trail's own emblem, keep a history on every record, and list what was left out
- Emblems for 81 trails, up from 41. Each is the trail's own crest, badge or roundel alone, cropped out of a larger logo where need be and made transparent where that could be done cleanly. Records without one say where an emblem was looked for. The validator checks the logo state. - Every record has a `[[history]]` list: what changed or was asked for, on what basis, who asked and whether it was applied or declined. `tools/check_history.py` fails a changed fact with no history entry and prints earlier entries about a changed field. It runs in CI before the site deploys. Each trail page shows the history. - A new page, "Considered and left out", built from `left-out.toml`: 35 trails and routes with the reason, the deciding fact and its source. - The Hoosier Heritage Trail has its ends, its free map set and its emblem from its association (issue 2). Any trail may list its holder's own guide or map set. - A stated permission is quoted in the download credit box. - `tools/gpx_track.py` turns a GPX file from a holder or a hiker into a record's track files. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
d34a9617cd
commit
24bfbb2fa8
374 files changed
+7796
-703
No files matched your search
@@ -0,0 +1,144 @@
|
||||
"""The Considered and left out page (/left-out/): built from left-out.toml.
|
||||
|
||||
left-out.toml holds the trails and routes that were looked at and left out
|
||||
of the dataset, with the reason, the deciding fact, the page that shows it
|
||||
and the date the decision was made. Its fields are in docs/schema.md.
|
||||
Everything on this page comes from that file and from web/site.toml.
|
||||
"""
|
||||
import os
|
||||
import tomllib
|
||||
|
||||
from . import words
|
||||
from .markup import Markup, esc
|
||||
|
||||
FILE_NAME = "left-out.toml"
|
||||
PATH = "/left-out/"
|
||||
REAL_ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
# reason -> (heading, one plain sentence on what the heading means).
|
||||
# Ordered as the inclusion rule states them; the page follows this order.
|
||||
REASONS = {
|
||||
"below-floor": ("Below the 50 mile floor",
|
||||
"The floor for this list is 50 miles (80 km), apart from a few well known shorter trails."),
|
||||
"rail-trail-or-towpath": ("Rail trails and canal towpaths",
|
||||
"Paths made mainly for cycling, such as gravel rail trails and canal towpaths, are not listed."),
|
||||
"driving-route": ("Mainly driving or motor routes",
|
||||
"Historic trails that are mainly driving routes with short walkable pieces are not listed."),
|
||||
"not-mainly-walking": ("Mainly for bikes, horses or motor vehicles",
|
||||
"A trail made mainly for other users is not a walking trail for this list."),
|
||||
"network": ("Networks, not one trail",
|
||||
"This list holds one named trail or route at a time, not a whole network of trails."),
|
||||
"cannot-be-walked-through": ("Cannot be walked through",
|
||||
"A listed trail can be walked as one continuous walk, road links allowed."),
|
||||
"mostly-unbuilt": ("Mostly unbuilt or still proposed",
|
||||
"A trail that does not yet exist on the ground cannot be listed."),
|
||||
"not-published-as-route": ("Not published as a route by its author",
|
||||
"A route is listed when its author has published it as a route, with a stated length."),
|
||||
"waiting": ("Waiting",
|
||||
"Not left out for good. Each entry says what would change the decision."),
|
||||
}
|
||||
REASON_ORDER = tuple(REASONS)
|
||||
|
||||
|
||||
def load_entries(repo_root):
|
||||
"""The [[trail]] entries of left-out.toml, or [] when the file is not there."""
|
||||
for base in (repo_root, REAL_ROOT):
|
||||
path = os.path.join(base, FILE_NAME)
|
||||
if os.path.isfile(path):
|
||||
with open(path, "rb") as f:
|
||||
doc = tomllib.load(f)
|
||||
return doc.get("trail") or []
|
||||
return []
|
||||
|
||||
|
||||
def _where(entry):
|
||||
names = [words.region_name(str(c)) for c in entry.get("regions", [])]
|
||||
return ", ".join(names)
|
||||
|
||||
|
||||
def _length(entry):
|
||||
"""The length as the holder or author states it: length_note in words,
|
||||
else both units with miles first, else nothing (no page states one)."""
|
||||
note = entry.get("length_note")
|
||||
if note:
|
||||
return esc(note)
|
||||
km = entry.get("length_km")
|
||||
mi = entry.get("length_mi")
|
||||
if km is None and mi is not None:
|
||||
km = mi * words.KM_PER_MI
|
||||
if km is None:
|
||||
return Markup("")
|
||||
return words.length(km, mi=mi)
|
||||
|
||||
|
||||
def _opening(entries, site):
|
||||
n = len(entries)
|
||||
gone = sum(1 for e in entries if e.get("was_listed"))
|
||||
second = ("Every one of them is a good walk in its own right and was left "
|
||||
"out only because it does not meet the rule this list uses")
|
||||
if gone:
|
||||
second += (f", and {gone} of them {'were' if gone != 1 else 'was'} "
|
||||
"listed here once and later removed")
|
||||
parts = [
|
||||
f"This page lists {n} trails and routes that were considered for this "
|
||||
"dataset and left out, with the reason, the deciding fact and the date "
|
||||
"for each one.",
|
||||
second + ".",
|
||||
]
|
||||
ask = "open an issue"
|
||||
if site.issues_url:
|
||||
ask = f'<a href="{esc(site.issues_url)}">open an issue</a>'
|
||||
parts.append(
|
||||
f"If the facts behind a decision have changed, {ask} and give a page "
|
||||
"that shows the change, and the decision will be looked at again.")
|
||||
return Markup(" ".join(parts))
|
||||
|
||||
|
||||
def left_out_page(entries, site, repo_root):
|
||||
"""(title, description, body) for /left-out/, from left-out.toml entries."""
|
||||
bread = Markup('<nav class="breadcrumb" aria-label="Breadcrumb"><ol>'
|
||||
'<li><a href="/about/">About</a></li>')
|
||||
groups = ""
|
||||
for reason in REASON_ORDER:
|
||||
listed = [e for e in entries if e.get("reason") == reason]
|
||||
if not listed:
|
||||
continue
|
||||
heading, meaning = REASONS[reason]
|
||||
rows = ""
|
||||
for e in listed:
|
||||
mark = ""
|
||||
if e.get("was_listed"):
|
||||
mark = '<br><span class="tag">Once listed here</span>'
|
||||
why = f"<p>{esc(e.get('note', ''))}</p>"
|
||||
if e.get("waiting_for"):
|
||||
why += (f"<p>It would be listed if this changes: "
|
||||
f"{esc(e['waiting_for'])}</p>")
|
||||
source = ""
|
||||
if e.get("source_url"):
|
||||
source = (f'<a href="{esc(e["source_url"])}">Source page</a>')
|
||||
rows += (
|
||||
f"<tr><td>{esc(e.get('name', ''))}{mark}</td>"
|
||||
f"<td>{esc(_where(e))}</td>"
|
||||
f"<td>{_length(e)}</td>"
|
||||
f"<td>{why}</td>"
|
||||
f'<td><time datetime="{esc(e.get("decided", ""))}">'
|
||||
f"{esc(e.get('decided', ''))}</time></td>"
|
||||
f"<td>{source}</td></tr>")
|
||||
groups += f"""<section aria-labelledby="left-out-{esc(reason)}">
|
||||
<div class="section-head"><h2 id="left-out-{esc(reason)}">{esc(heading)}</h2>
|
||||
<p>{esc(meaning)}</p></div>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th scope="col">Trail</th><th scope="col">Where</th><th scope="col">Length</th><th scope="col">Why it is left out</th><th scope="col">Decided</th><th scope="col">Source</th></tr></thead>
|
||||
<tbody>{rows}</tbody></table></div>
|
||||
</section>"""
|
||||
body = f"""<div class="page-head"><div class="container">{bread}<li aria-current="page">Considered and left out</li></ol></nav><header class="titleblock">
|
||||
<div class="titleblock__text"><h1>Considered and left out</h1>
|
||||
<p class="page-head__lede">Trails and routes that were looked at for this dataset and left out, and why.</p>
|
||||
</div></header></div></div>
|
||||
<div class="container section">
|
||||
<p class="prose">{_opening(entries, site)}</p>
|
||||
{groups}
|
||||
</div>"""
|
||||
description = ("Trails and routes considered for this dataset and left out: "
|
||||
"the reason, the deciding fact and its source page for each one.")
|
||||
return "Considered and left out", description, Markup(body)
|
||||
Reference in new issue
Block a user