Show each trail's own emblem, keep a history on every record, and list what was left out
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

- 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:
swaitsandClaude Fable 5.2 committed 2026-11-16 13:40:03 -07:00
1 parent d34a9617cd
commit 24bfbb2fa8
374 files changed
+7796 -703

No files matched your search

+3 -1
View File
@@ -145,7 +145,9 @@ class BuildTreeTest(unittest.TestCase):
f.write("x")
os.remove(os.path.join(self.root, "avon", "line.geojson"))
self.build()
self.assertEqual(sorted(os.listdir(tdir)), ["index.html", "release.txt", "trail.toml"])
# The trail's own logo file, where the record has one, is copied beside its page.
logo = [f for f in ("shield.png", "shield.svg") if os.path.exists(os.path.join(self.root, "avon", f))]
self.assertEqual(sorted(os.listdir(tdir)), sorted(["index.html", "release.txt", "trail.toml"] + logo))
def test_removed_trail_directory_is_pruned(self):
self.build()
+179
View File
@@ -0,0 +1,179 @@
"""The "History of this record" section of a trail page, and the permission block in the credit box."""
import html
import os
import re
import sys
import unittest
WEB = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, WEB)
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from olt import records, site, trail, words # noqa: E402
from test_hike import with_line # noqa: E402
from test_pages import sample_record # noqa: E402
S = site.Site("N", "T", repo_url="https://github.com/o/r")
QUOTE = "It's completely public and free to share."
ADDED = {"date": "2026-11-01", "change": "The record was added.", "fields": ["record"],
"basis": "The record's own source entry: Example Trail Association.",
"asked_by": "the dataset's own check", "outcome": "applied"}
CHANGED = {"date": "2026-11-12", "change": "The length was changed to 160 miles (257 km).",
"fields": ["length_km", "length_note"], "basis": "The association's page for the trail gives 160 miles.",
"basis_url": "https://example.org/trail?a=1&b=2", "asked_by": "the trail association's president",
"outcome": "applied"}
DECLINED = {"date": "2026-11-14", "change": "A request to shorten it to 150 miles (241 km) was not applied.",
"fields": ["length_km"], "basis": "The association's own page still says 160 miles.",
"basis_url": "https://github.com/o/r/issues/9", "asked_by": "a hiker", "outcome": "declined"}
def with_history(*entries):
rec = sample_record("Example Trail")
rec["history"] = [dict(e) for e in entries]
return rec
def flat(text):
return re.sub(r"\s+", " ", html.unescape(re.sub(r"<[^>]+>", " ", text)))
def permission_record():
rec = with_line(sample_record("Example Trail"))
rec["source"].update({"licence": "stated-permission", "attribution": "Example Trail Association",
"licence_text": "The association's president answered a form on the issue tracker.",
"permission_quote": QUOTE, "permission_by": "the association's president",
"permission_date": "2026-11-16",
"permission_url": "https://github.com/o/r/issues/2"})
return rec
class HistorySectionTest(unittest.TestCase):
def section(self, *entries):
return trail.history_section(with_history(*entries))
def test_collapsed_section_beside_about_this_data(self):
body = trail.render(with_history(ADDED, CHANGED), S)[2]
self.assertIn('<details class="about-data about-data--history" id="record-history">', body)
self.assertNotIn("<details class=\"about-data about-data--history\" id=\"record-history\" open", body)
self.assertIn("<h2 id=\"record-history-title\">History of this record</h2>", body)
self.assertLess(body.index('<details class="about-data" id="about-data">'), body.index("History of this record"))
self.assertEqual(body.count("History of this record"), 1)
def test_one_entry(self):
part = self.section(ADDED, CHANGED)
self.assertIn('<li class="history__entry history__entry--applied">', part)
self.assertIn('<time datetime="2026-11-12">2026-11-12</time>', part)
self.assertIn('<p class="history__change">The length was changed to 160 miles (257 km).</p>', part)
self.assertIn('<p class="history__basis"><span class="history__label">Basis:</span> '
"The association&#x27;s page for the trail gives 160 miles. "
'<a href="https://example.org/trail?a=1&amp;b=2">https://example.org/trail?a=1&amp;b=2</a></p>', part)
self.assertIn('<p class="history__who"><span class="history__label">Asked by:</span> '
"the trail association&#x27;s president</p>", part)
self.assertIn("<li><code>length_km</code></li><li><code>length_note</code></li>", part)
def test_entries_run_oldest_first_as_the_record_has_them(self):
part = self.section(ADDED, CHANGED, DECLINED)
self.assertLess(part.index("2026-11-01"), part.index("2026-11-12"))
self.assertLess(part.index("2026-11-12"), part.index("2026-11-14"))
self.assertIn("3 entries", part)
self.assertIn("1 entry", self.section(ADDED))
def test_declined_request_has_a_plain_label_and_applied_has_none(self):
part = self.section(ADDED, DECLINED)
self.assertIn('<li class="history__entry history__entry--declined">', part)
self.assertEqual(part.count("Request declined"), 1)
declined = part[part.index("history__entry--declined"):]
self.assertIn('<strong class="history__outcome">Request declined</strong>', declined)
self.assertNotIn("Request declined", part[:part.index("history__entry--declined")])
def test_no_address_means_no_link(self):
part = self.section(ADDED)
self.assertNotIn("<a ", part)
self.assertIn("The record&#x27;s own source entry: Example Trail Association.", part)
def test_text_is_escaped(self):
bad = dict(CHANGED, change="<script>alert(1)</script>", asked_by='"a" & <b>')
part = self.section(ADDED, bad)
self.assertNotIn("<script>", part)
self.assertIn("&lt;script&gt;", part)
self.assertIn("&amp; &lt;b&gt;", part)
def test_a_record_with_no_history_has_no_section(self):
rec = sample_record("Example Trail")
self.assertEqual(trail.history_section(rec), "")
self.assertNotIn("History of this record", trail.render(rec, S)[2])
def test_it_is_generated_from_the_record_alone(self):
words_in_page = flat(self.section(ADDED, CHANGED, DECLINED))
for label in ("History of this record", "Basis:", "Asked by:", "Request declined"):
self.assertIn(label, words_in_page)
self.assertEqual(self.section(ADDED, CHANGED), self.section(ADDED, CHANGED))
def test_the_source_block_is_not_changed_by_it(self):
self.assertNotIn("record-history", trail.about_data(with_history(ADDED), S))
def test_real_records_all_show_their_history(self):
recs = records.load_records()
self.assertEqual(len(recs), 204)
for rec in recs:
part = trail.history_section(rec)
self.assertIn("History of this record", part, rec["id"])
self.assertEqual(part.count('<li class="history__entry '), len(rec["history"]), rec["id"])
def test_hoosier_heritage_trail_history(self):
rec = next(r for r in records.load_records() if r["id"] == "hoosier-heritage-trail")
part = trail.history_section(rec)
self.assertEqual(part.count("history__entry--applied"), len(rec["history"]))
self.assertGreaterEqual(len(rec["history"]), 2)
self.assertIn("the trail association&#x27;s president", part)
self.assertIn('<a href="https://github.com/swaits/longhikes/issues/2">', part)
class CreditBoxPermissionTest(unittest.TestCase):
def credit_box(self, rec):
page = trail.render(rec, S)[2]
start = page.index('<div class="credit">')
return page[start:page.index("</section>", start)]
def test_the_credit_box_shows_the_quotation_who_when_and_a_link(self):
box = self.credit_box(permission_record())
self.assertIn('<blockquote cite="https://github.com/o/r/issues/2"><p>It&#x27;s completely public and free to share.</p></blockquote>', box)
self.assertIn("Said by the association&#x27;s president on 2026-11-16.", box)
self.assertIn('<a href="https://github.com/o/r/issues/2">https://github.com/o/r/issues/2</a>', box)
def test_the_sentence_is_true_where_it_stands(self):
box = self.credit_box(permission_record())
self.assertIn("The statement is quoted below.", box)
self.assertLess(box.index("The statement is quoted below."), box.index("<blockquote"))
self.assertNotIn("quoted below", words.LICENCE_NOTES["stated-permission"])
def test_the_about_block_still_shows_it_too(self):
page = trail.render(permission_record(), S)[2]
self.assertEqual(page.count("<blockquote"), 2)
self.assertEqual(page.count("The statement is quoted below."), 2)
def test_no_claim_without_a_quotation(self):
rec = permission_record()
del rec["source"]["permission_quote"]
page = trail.render(rec, S)[2]
self.assertNotIn("quoted below", page)
self.assertNotIn("<blockquote", page)
def test_other_licences_get_no_block(self):
rec = permission_record()
rec["source"]["licence"] = "CC-BY-4.0"
box = self.credit_box(rec)
self.assertNotIn("<blockquote", box)
self.assertNotIn("Said by", box)
def test_the_real_record(self):
rec = next(r for r in records.load_records() if r["id"] == "hoosier-heritage-trail")
rec["derived"].setdefault("downloads", [{"role": "main", "format": "GPX", "file": "x.gpx", "bytes": 1000}])
box = self.credit_box(rec)
self.assertIn("completely public and free to share", box)
self.assertIn("Said by the association&#x27;s president on 2026-11-16.", box)
self.assertIn("https://github.com/swaits/longhikes/issues/2", box)
if __name__ == "__main__":
unittest.main()
+106
View File
@@ -0,0 +1,106 @@
"""Tests for the Considered and left out page (web/olt/leftout.py).
Run from the repository root:
python3 -m unittest discover -s web/tests
"""
import os
import sys
import unittest
WEB = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ROOT = os.path.dirname(WEB)
sys.path.insert(0, WEB)
from olt import leftout, seo, site # noqa: E402
ENTRIES = [
{
"id": "waiting-trail",
"name": "Waiting Trail",
"country": "US",
"regions": ["KY"],
"length_mi": 120,
"length_km": 193,
"length_note": "120 miles planned",
"reason": "waiting",
"note": "Only part of it is built.",
"source_url": "https://example.org/waiting",
"decided": "2026-11-16",
"was_listed": False,
"waiting_for": "Enough of it is built to walk through.",
},
{
"id": "example-trail",
"name": "Example & Trail",
"country": "US",
"regions": ["PA", "MD"],
"length_mi": 42.0,
"length_km": 68,
"reason": "below-floor",
"note": "The holder gives it as 42 miles.",
"source_url": "https://example.org/example?a=1&b=2",
"decided": "2026-11-14",
"was_listed": True,
},
]
class PageTest(unittest.TestCase):
def setUp(self):
self.site = site.Site(name="Long Hikes", tagline="Tagline",
base_url="https://example.org",
repo_url="https://github.com/swaits/longhikes")
self.title, self.description, self.body = leftout.left_out_page(
ENTRIES, self.site, ROOT)
self.text = str(self.body)
def test_title(self):
self.assertEqual(self.title, "Considered and left out")
def test_opening_is_generated_from_the_entries(self):
self.assertIn("lists 2 trails and routes", self.text)
self.assertIn("1 of them was listed here once", self.text)
self.assertIn("open an issue", self.text)
def test_grouped_by_reason_in_order(self):
self.assertLess(self.text.index("Below the 50 mile floor"),
self.text.index("Waiting"))
def test_entry_facts_and_escaping(self):
self.assertIn("Example &amp; Trail", self.text)
self.assertIn("Pennsylvania", self.text)
self.assertIn("Maryland", self.text)
self.assertIn("42 mi", self.text)
self.assertIn("68 km", self.text)
self.assertIn("The holder gives it as 42 miles.", self.text)
self.assertIn('datetime="2026-11-14"', self.text)
self.assertIn('href="https://example.org/example?a=1&amp;b=2"', self.text)
def test_once_listed_mark(self):
self.assertIn("Once listed here", self.text)
self.assertEqual(self.text.count("Once listed here"), 1)
def test_waiting_shows_what_would_change_it(self):
self.assertIn("Enough of it is built to walk through.", self.text)
self.assertIn("120 miles planned", self.text)
def test_no_length_shows_nothing_made_up(self):
entries = [dict(ENTRIES[1])]
del entries[0]["length_mi"], entries[0]["length_km"]
_, _, body = leftout.left_out_page(entries, self.site, ROOT)
self.assertNotIn("len__mi", str(body))
def test_sitemap_includes_the_page(self):
self.assertIn("/left-out/", seo.all_paths([], []))
def test_the_real_file_loads_sorted(self):
entries = leftout.load_entries(ROOT)
self.assertGreaterEqual(len(entries), 30)
names = [e["name"].lower() for e in entries]
self.assertEqual(names, sorted(names))
reasons = {e["reason"] for e in entries}
self.assertTrue(reasons <= set(leftout.REASON_ORDER))
if __name__ == "__main__":
unittest.main()
+41
View File
@@ -0,0 +1,41 @@
"""What a trail page says for each state of [shield], from the record alone."""
import html
import os
import sys
import unittest
WEB = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.insert(0, WEB)
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from olt import trail, words # noqa: E402
from test_pages import sample_record # noqa: E402
def logo_text(status, note):
rec = sample_record("Example Trail")
rec["shield"].update({"status": status, "note": note})
return html.unescape(str(trail.logo_block(rec)))
class LogoStatesTest(unittest.TestCase):
def test_no_emblem_of_its_own(self):
text = logo_text("no-logo-exists", "Looked at the association's site.")
self.assertIn("No emblem of its own", text)
self.assertIn("Looked at the association's site.", text)
self.assertNotIn("Emblem not found", text)
def test_emblem_not_found(self):
text = logo_text("logo-not-found", "A sign shows one.")
self.assertIn("Emblem not found", text)
self.assertIn("exists or may exist", text)
self.assertIn("A sign shows one.", text)
self.assertNotIn("No emblem of its own", text)
def test_words_agree_with_the_block(self):
self.assertEqual(words.label(words.SHIELD_STATUS, "no-logo-exists"), "No emblem of its own")
self.assertEqual(words.label(words.SHIELD_STATUS, "logo-not-found"), "Emblem not found")
if __name__ == "__main__":
unittest.main()
+5 -4
View File
@@ -494,13 +494,14 @@ class RenderUnitTest(unittest.TestCase):
def test_logo_source_without_a_logo_file_is_not_called_taken_from(self):
# A record can name where its logo is held without including the logo.
rec = sample_record("X Trail")
rec["shield"] = {"status": "use-real-logo", "logo_source": "https://holder.example/", "contact": "Holder",
rec["shield"] = {"status": "logo-not-found", "logo_source": "https://holder.example/", "contact": "Holder",
"note": "No policy found.", "logo_file": "", "logo_owner": "Holder & Co"}
_, _, body, _ = trail.render(rec, site.Site("N", "T"))
self.assertIn('href="https://holder.example/"', body)
self.assertNotIn("logo was taken from", body)
self.assertIn("the logo is not included here", body)
self.assertIn("The trail has a logo, held by Holder &amp; Co, but no copy of it is in this dataset.", body)
self.assertIn("Emblem not found.", body)
self.assertIn("An emblem exists or may exist, but no usable artwork of it was found at a source the dataset allows.", body)
def test_trail_correction_links_github_branch(self):
gh = site.Site("N", "T", repo_url="https://github.com/o/r/", repo_branch="dev")
@@ -549,8 +550,8 @@ class RenderUnitTest(unittest.TestCase):
rec = sample_record(name="A & B")
n = pages.render_site([rec], out, repo, site=site.Site("N", "T"))
# trail page + home + 404 + places hub + 1 place + lists hub + routes,
# sources, logos, about, data, schema, changelog, saved (no list holds MIN_SIZE trails)
self.assertEqual(n, 14)
# sources, logos, about, data, schema, changelog, left out, saved (no list holds MIN_SIZE trails)
self.assertEqual(n, 15)
with open(os.path.join(out, "trails", "x", "index.html"), encoding="utf-8") as f:
self.assertIn("A &amp; B", f.read())
with open(os.path.join(out, "index.html"), encoding="utf-8") as f: