Make a trail's length one end-to-end walk, and put the map and the trails in the first screen
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

Lengths and what belongs:
- A trail's length is now the end-to-end length of its canonical path: one
  branch at a split, no side trails, no system totals. A holder's larger
  figure and the built length of an unfinished trail are separate fields
  (`system_km`, `system_note`, `built_km`), shown under the length.
- Corrected: Florida Trail 1,500 to 1,130 mi, American Discovery Trail
  6,800 to 5,008 mi, Ozark Trail to 230 mi, General Crook Trail to 138 mi,
  Sheltowee Trace to 343 mi, Allegheny Trail to 316 mi, Great Eastern
  Trail to 1,800 mi.
- The Florida Trail's and the Ice Age Trail's main tracks are re-cut as
  one walk; the other branches are alternates.
- A trail must be walkable from end to end today. Nine trails that are
  not, are a network, or fall under the floor move to the "Considered and
  left out" list. The Bayou State Trail is added. 196 trails.

Pages:
- The trail page puts the map and At a glance directly under the title;
  the home page drops its oversized hero and shows the trails and the map
  at once. Place and list pages put the list beside the map.
- Every map starts by itself once the page is ready, over a drawing of
  the tracks that is in the page from the first paint.
- Lists is in the header. The home page shows ten lists chosen in
  `collections.toml`. Tables have equal columns and stack on a phone.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-16 18:57:21 -07:00
1 parent f2d3b71810
commit 8637181a2b
145 files changed
+2178 -1455

No files matched your search

+49 -1
View File
@@ -2,6 +2,7 @@
glossary.toml [[term]] id, term, definition, optional source_url, see
collections.toml [[collection]] id, name, members, definition, source_url, source_publisher
[[list]] key, home (the lists the home page shows, and their order)
authors.toml [[author]] name, credits, optional kind
Each function appends one message per problem to `errors`. Used by tools/validate.py, which passes
@@ -9,12 +10,26 @@ the records it has read. Python 3 standard library only. Fields are in docs/sche
"""
import os
import re
import sys
import tomllib
ID_RE = re.compile(r"[a-z0-9]+(-[a-z0-9]+)*")
DASH_RE = re.compile(r"[–—]| - ")
def built_in_list_keys():
"""The keys of the lists defined in web/olt/browse.py, or None when the generator cannot be read."""
web = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "web")
sys.path.insert(0, web)
try:
from olt import browse
return {lst.key for lst in browse.LISTS}
except Exception: # noqa: BLE001 - without the generator the keys are not checked
return None
finally:
sys.path.remove(web)
def _load(root, name, errors):
path = os.path.join(root, name)
if not os.path.isfile(path):
@@ -120,6 +135,38 @@ def check_collection_entries(entries, trail_ids, errors, where="collections.toml
errors.append(f"{who} member {m} is not a trail in the dataset")
def check_list_entries(entries, list_keys, errors, where="collections.toml"):
"""The [[list]] entries: a list's key and its place on the home page. Optional.
list_keys: the keys of the lists defined in web/olt/browse.py."""
if entries is None:
return
if not isinstance(entries, list):
errors.append(f"{where}: [[list]] must be an array of tables")
return
seen_keys, seen_home = set(), {}
for i, e in enumerate(entries, 1):
if not isinstance(e, dict):
errors.append(f"{where}: [[list]] entry {i} must be a table")
continue
who = f"{where}: [[list]] {e.get('key') or 'entry ' + str(i)}"
check_unknown(e, {"key", "home"}, who, errors)
key = _text(e, "key", who, errors)
if key and list_keys is not None and key not in list_keys:
errors.append(f"{who} is not the key of a list in web/olt/browse.py")
if key in seen_keys:
errors.append(f"{who} appears twice")
seen_keys.add(key)
home = e.get("home")
if home is None:
continue
if isinstance(home, bool) or not isinstance(home, int) or home < 1:
errors.append(f"{who} home must be a whole number from 1")
elif home in seen_home:
errors.append(f"{who} home {home} is also the place of {seen_home[home]}")
else:
seen_home[home] = key
def check_author_entries(entries, routes, errors, where="authors.toml"):
"""routes: [(trail id, route.creator)] for every route in the dataset."""
if not isinstance(entries, list) or not entries:
@@ -162,9 +209,10 @@ def check_datafiles(root, trails, errors):
check_glossary_entries(doc.get("term"), errors)
doc = _load(root, "collections.toml", errors)
if doc is not None:
for name in sorted(set(doc) - {"collection"}):
for name in sorted(set(doc) - {"collection", "list"}):
errors.append(f"collections.toml: unknown top level field {name}")
check_collection_entries(doc.get("collection"), {r.get("id") for r in trails}, errors)
check_list_entries(doc.get("list"), built_in_list_keys(), errors)
doc = _load(root, "authors.toml", errors)
if doc is not None:
for name in sorted(set(doc) - {"author"}):
+100
View File
@@ -0,0 +1,100 @@
"""Tests for system_km, system_note and built_km in tools/validate.py.
Run from the repository root:
python3 -m unittest discover tools/tests
"""
import os
import sys
import unittest
sys.dont_write_bytecode = True
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import trail_history as H # noqa: E402
import validate as V # noqa: E402
def check(**fields):
rec = {"length_km": 1818, "hike": {"unfinished": "About 290 miles are built."}}
rec.update(fields)
errors = []
V.check_length_facts("t", rec, errors)
return errors
class SystemFigureTest(unittest.TestCase):
def test_a_larger_figure_with_its_note_passes(self):
self.assertEqual(check(system_km=2549, system_note="both corridors and the connectors"), [])
def test_a_record_without_them_passes(self):
self.assertEqual(check(), [])
def test_the_figure_must_be_larger_than_the_length(self):
for km in (1818, 1000):
errors = check(system_km=km, system_note="the whole system")
self.assertEqual(len(errors), 1, km)
self.assertIn("greater than length_km", errors[0])
def test_the_figure_needs_its_note(self):
for note in (None, "", " "):
fields = {"system_km": 2549}
if note is not None:
fields["system_note"] = note
errors = check(**fields)
self.assertEqual(len(errors), 1, repr(note))
self.assertIn("system_note", errors[0])
def test_a_note_alone_is_refused(self):
errors = check(system_note="the whole system")
self.assertEqual(len(errors), 1)
self.assertIn("system_km is not", errors[0])
def test_the_note_does_not_repeat_the_word_the_page_adds(self):
errors = check(system_km=2549, system_note="Counting both corridors")
self.assertEqual(len(errors), 1)
self.assertIn("counting", errors[0])
def test_the_figure_is_a_whole_number_of_kilometres(self):
for bad in (2549.5, "2549", True, 0, -5):
errors = check(system_km=bad, system_note="the whole system")
self.assertEqual(len(errors), 1, repr(bad))
self.assertIn("whole number", errors[0])
class BuiltFigureTest(unittest.TestCase):
def test_a_built_length_on_an_unfinished_trail_passes(self):
self.assertEqual(check(built_km=467), [])
def test_it_cannot_exceed_the_length(self):
errors = check(built_km=1819)
self.assertEqual(len(errors), 1)
self.assertIn("cannot exceed length_km", errors[0])
self.assertEqual(check(built_km=1818), [])
def test_it_belongs_only_on_an_unfinished_trail(self):
for hike in ({}, {"unfinished": " "}):
errors = check(built_km=467, hike=hike)
self.assertEqual(len(errors), 1)
self.assertIn("hike.unfinished", errors[0])
rec = {"length_km": 500, "built_km": 400}
errors = []
V.check_length_facts("t", rec, errors)
self.assertEqual(len(errors), 1)
def test_it_is_a_whole_number_of_kilometres(self):
for bad in (290.5, "290", False, 0):
errors = check(built_km=bad)
self.assertEqual(len(errors), 1, repr(bad))
self.assertIn("whole number", errors[0])
class HistoryFieldsTest(unittest.TestCase):
def test_the_new_fields_are_known_to_the_history_and_are_facts(self):
for name in ("system_km", "system_note", "built_km"):
self.assertIn(name, H.SCHEMA_FIELDS)
self.assertTrue(H.is_fact(name), name)
self.assertIn(name, H.FACTS_TEXT)
if __name__ == "__main__":
unittest.main()
+3 -3
View File
@@ -19,7 +19,7 @@ URL_RE = re.compile(r"^https?://[^\s/]+\S*$")
# names these. A table name on its own ("source", "hike.source") names every field in it.
_TABLES = {
"": ("id", "name", "common_name", "short_name", "short_name_url", "country", "regions", "length_km",
"length_note", "kind", "tier", "designation", "wave", "wave_note", "inclusion"),
"length_note", "system_km", "system_note", "built_km", "kind", "tier", "designation", "wave", "wave_note", "inclusion"),
"source": ("status", "publisher", "publisher_url", "url", "discovery", "format", "crs",
"licence", "licence_text", "permission_quote", "permission_by",
"permission_date", "permission_url", "attribution", "osm_only", "mainline",
@@ -62,8 +62,8 @@ NOT_FACTS = (
"wave", "wave_note", # the dataset's own bookkeeping
)
FACTS_TEXT = (
"name, common_name, short_name, short_name_url, country, regions, length_km, length_note, kind, tier, designation, "
"inclusion; source.* (status, publisher, publisher_url, url, licence, licence_text, "
"name, common_name, short_name, short_name_url, country, regions, length_km, length_note, system_km, system_note, built_km, kind, tier, "
"designation, inclusion; source.* (status, publisher, publisher_url, url, licence, licence_text, "
"permission_*, attribution, osm_only, line_source, line_file, line_absent_reason, "
"decision, decision_text, redistributable); osm.relation; shield.* except note; "
"hike.* except summary, checked and source (start, end, official_url, days, season, terrain, "
+43
View File
@@ -461,6 +461,48 @@ def check_elevation(tid, tdir, rec, errors):
errors.append(f"{where}: source.computed must be a date (YYYY-MM-DD)")
def _whole_km(value):
"""True for a positive whole number of kilometres (not a boolean)."""
return isinstance(value, int) and not isinstance(value, bool) and value > 0
def check_length_facts(tid, rec, errors):
"""system_km, system_note and built_km (docs/schema.md, "What length_km counts").
system_km is the larger figure a holder publishes for a whole system or a planned total:
a whole number of kilometres, greater than length_km, and it must say what it counts in
system_note. system_note has no use without system_km. built_km is the built length of an
unfinished trail: a whole number of kilometres, no more than length_km, and only on a record
whose hike.unfinished says so."""
length = rec.get("length_km")
comparable = isinstance(length, (int, float)) and not isinstance(length, bool) and length > 0
if "system_km" in rec:
system = rec["system_km"]
if not _whole_km(system):
errors.append(f"{tid}: system_km must be a positive whole number of kilometres")
elif comparable and system <= length:
errors.append(f"{tid}: system_km {system} must be greater than length_km {length}: "
"it is the larger figure, a system total or a planned total")
note = rec.get("system_note")
if not isinstance(note, str) or not note.strip():
errors.append(f"{tid}: system_km is present but system_note, what it counts, is not")
elif note.strip().lower().startswith("counting"):
errors.append(f"{tid}: system_note must not begin with the word 'counting': "
"the page adds it")
elif "system_note" in rec:
errors.append(f"{tid}: system_note is present but system_km is not")
if "built_km" in rec:
built = rec["built_km"]
if not _whole_km(built):
errors.append(f"{tid}: built_km must be a positive whole number of kilometres")
elif comparable and built > length:
errors.append(f"{tid}: built_km {built} cannot exceed length_km {length}")
hike = rec.get("hike") if isinstance(rec.get("hike"), dict) else {}
if not str(hike.get("unfinished", "")).strip():
errors.append(f"{tid}: built_km is present but hike.unfinished is not: "
"built_km belongs only on an unfinished trail")
def check_common_name(tid, rec, errors):
"""common_name is optional; where present it is the name hikers use, so it is a clean string that differs from name."""
if "common_name" not in rec:
@@ -711,6 +753,7 @@ def main():
errors.append(f"{tid}: missing required field {field}")
check_short_name(tid, rec, errors)
check_common_name(tid, rec, errors)
check_length_facts(tid, rec, errors)
if rec.get("id") != tid:
errors.append(f"{tid}: id {rec.get('id')!r} does not match directory name")
if rec.get("country") not in ("US", "CA"):