Add 19 trails and 20 tracks, record stated permission, and remove the C&O Canal Towpath
A deeper, region-by-region search of the web added 14 official trails and 4 routes. The Hoosier Heritage Trail was added at its association's request (issue 2) with the association's own track, shared by written permission. - New licence value `stated-permission`, with the quoted words, who gave them, when and where as fields of the record, shown on the trail page and carried in the GPX description. - Tracks from OpenStreetMap or the Forest Service's open trail data for eleven of the new trails and seven existing ones. `tools/osm_track.py` can join several relations and leave ways out by name. - The C&O Canal Towpath is removed: the rule leaves out canal towpaths. - The Grand Enchantment Trail is recorded as a route by its author, with no track. - Corrections to the Finger Lakes, Ozark Highlands, Eastern Continental and Knobstone records, checked against the pages they cite. - Site: the list pages' own units switch is gone in favour of the header one; the map switch and a swapped length range stay in step with the page. - CHANGELOG.md brought up to date from the site's opening to today. 204 trails: 147 official trails and 57 routes; 126 have a track. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
c11a72a7dd
commit
d34a9617cd
127 files changed
+2612
-358
No files matched your search
@@ -60,7 +60,7 @@ class ExtraPagesTest(unittest.TestCase):
|
||||
|
||||
def test_all_routes_on_routes_page(self):
|
||||
routes = [r for r in self.records if r["derived"]["kind"] == "route"]
|
||||
self.assertEqual(len(routes), 52)
|
||||
self.assertEqual(len(routes), 57)
|
||||
page = read_out("routes/index.html")
|
||||
import html as _html
|
||||
text = _html.unescape(page)
|
||||
@@ -137,8 +137,9 @@ class ExtraPagesTest(unittest.TestCase):
|
||||
doc = read_out(rel)
|
||||
results = doc[doc.index('<div class="results"'):]
|
||||
for part in ('<div class="list-head" aria-hidden="true">', '<ol class="entries"',
|
||||
'name="units-list"', '<ul class="key"', "Sort by", 'data-sort-select'):
|
||||
'<ul class="key"', "Sort by", 'data-sort-select'):
|
||||
self.assertIn(part, results, f"{rel}: {part}")
|
||||
self.assertNotIn('name="units-list"', doc, rel) # the header's switch is the only one
|
||||
scale = re.search(r'<div class="list-head".*?</div>', results, re.S).group(0)
|
||||
self.assertEqual(scale.count('class="len__km"'), 3, rel)
|
||||
self.assertEqual(scale.count('class="len__mi"'), 3, rel)
|
||||
@@ -232,7 +233,9 @@ class ExtraPagesTest(unittest.TestCase):
|
||||
for lic in {r["source"]["licence"] for r in lines}:
|
||||
n = sum(1 for r in lines if r["source"]["licence"] == lic)
|
||||
label = html.escape(words.label(words.LICENCES, lic), quote=True)
|
||||
self.assertIn(f"Tracks licensed {label}: {n} record", page, lic)
|
||||
what = (f"Tracks shared with permission: {n} record" if lic == "stated-permission"
|
||||
else f"Tracks licensed {label}: {n} record")
|
||||
self.assertIn(what, page, lic)
|
||||
for name in ("trails.json", "overview.geojson"):
|
||||
self.assertRegex(page, rf'<a href="/data/{re.escape(name)}">')
|
||||
for name in ("all-gpx.zip", "all-geojson.zip"):
|
||||
|
||||
@@ -394,7 +394,7 @@ class RealDocumentsTest(unittest.TestCase):
|
||||
counter = TableCounter()
|
||||
counter.feed(md.render(read_doc("README.md")))
|
||||
counter.close()
|
||||
self.assertEqual(counter.counts, [134, 52])
|
||||
self.assertEqual(counter.counts, [147, 57])
|
||||
|
||||
def test_readme_num_class_present(self):
|
||||
self.assertIn('class="num"', md.render(read_doc("README.md")))
|
||||
|
||||
@@ -90,7 +90,7 @@ class BuiltSiteTest(unittest.TestCase):
|
||||
def test_one_detail_page_per_record(self):
|
||||
found = [d for d in os.listdir(os.path.join(OUT, "trails"))
|
||||
if os.path.isfile(os.path.join(OUT, "trails", d, "index.html"))]
|
||||
self.assertEqual(len(self.records), 186)
|
||||
self.assertEqual(len(self.records), 204)
|
||||
self.assertEqual(sorted(found), sorted(r["id"] for r in self.records))
|
||||
self.assertTrue(os.path.isfile(os.path.join(OUT, "index.html")))
|
||||
|
||||
@@ -175,7 +175,7 @@ class BuiltSiteTest(unittest.TestCase):
|
||||
v = raw.get("verification", {})
|
||||
if raw["source"].get("line_file") and v.get("verified") and abs(v.get("difference_percent", 0)) > 15:
|
||||
expected.add(rec["id"])
|
||||
self.assertEqual(len(expected), 20)
|
||||
self.assertEqual(len(expected), 25)
|
||||
self.assertIn("voyageur", expected)
|
||||
for rec in self.records:
|
||||
page = self.pages[rec["id"]]
|
||||
|
||||
@@ -13,10 +13,10 @@ class RecordsTest(unittest.TestCase):
|
||||
cls.recs = records.load_records()
|
||||
|
||||
def test_counts(self):
|
||||
self.assertEqual(len(self.recs), 186)
|
||||
self.assertEqual(sum(r["derived"]["kind"] == "route" for r in self.recs), 52)
|
||||
self.assertEqual(sum(r["derived"]["kind"] == "designated" for r in self.recs), 134)
|
||||
self.assertEqual(sum(r["derived"]["has_line"] for r in self.recs), 107)
|
||||
self.assertEqual(len(self.recs), 204)
|
||||
self.assertEqual(sum(r["derived"]["kind"] == "route" for r in self.recs), 57)
|
||||
self.assertEqual(sum(r["derived"]["kind"] == "designated" for r in self.recs), 147)
|
||||
self.assertEqual(sum(r["derived"]["has_line"] for r in self.recs), 126)
|
||||
|
||||
def test_sorted_by_id(self):
|
||||
ids = [r["id"] for r in self.recs]
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
"""The wording for the stated-permission licence on trail pages and the sources page."""
|
||||
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__)))
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from olt import docs, geo, 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."
|
||||
|
||||
|
||||
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
|
||||
|
||||
|
||||
def flat(html_text):
|
||||
return re.sub(r"\s+", " ", html.unescape(re.sub(r"<[^>]+>", " ", html_text)))
|
||||
|
||||
|
||||
class StatedPermissionWordsTest(unittest.TestCase):
|
||||
def test_label_and_note(self):
|
||||
self.assertEqual(words.LICENCES["stated-permission"], "Shared with permission")
|
||||
note = words.LICENCE_NOTES["stated-permission"]
|
||||
self.assertTrue(note.startswith("Shared with permission. The holder has said in writing"))
|
||||
self.assertIn("not a Creative Commons licence", note)
|
||||
|
||||
def test_trail_page_says_it_in_plain_words(self):
|
||||
body = flat(trail.render(permission_record(), S)[2])
|
||||
self.assertGreaterEqual(body.count("Shared with permission. The holder has said in writing"), 2)
|
||||
self.assertIn("Licence: Shared with permission", body)
|
||||
self.assertIn(QUOTE, body)
|
||||
for wrong in ("CC BY", "Public domain", "US public domain", "ODbL"):
|
||||
self.assertNotIn(wrong, body)
|
||||
|
||||
def test_trail_page_shows_the_quotation_who_when_and_a_link(self):
|
||||
raw = trail.render(permission_record(), S)[2]
|
||||
self.assertIn('<blockquote cite="https://github.com/o/r/issues/2"><p>It's completely public and free to share.</p></blockquote>', raw)
|
||||
self.assertIn("Said by the association's president on 2026-11-16.", raw)
|
||||
self.assertIn('<a href="https://github.com/o/r/issues/2">https://github.com/o/r/issues/2</a>', raw)
|
||||
|
||||
def test_no_quotation_for_other_licences(self):
|
||||
rec = permission_record()
|
||||
rec["source"]["licence"] = "CC-BY-4.0"
|
||||
raw = trail.render(rec, S)[2]
|
||||
self.assertNotIn("Said by", raw)
|
||||
self.assertNotIn("<blockquote", raw)
|
||||
|
||||
def test_gpx_description_carries_the_quote_and_address(self):
|
||||
src = permission_record()["source"]
|
||||
fields = {k: src[k] for k in ("permission_quote", "permission_by", "permission_date", "permission_url")}
|
||||
text = geo.gpx_text([[[0, 0], [1, 1]]], "N", licence=src["licence"], licence_text=src["licence_text"],
|
||||
permission=fields)
|
||||
desc = ET.fromstring(text).find("{http://www.topografix.com/GPX/1/1}metadata/"
|
||||
"{http://www.topografix.com/GPX/1/1}desc").text
|
||||
self.assertIn(f'Permission: "{QUOTE}"', desc)
|
||||
self.assertIn("Said by the association's president on 2026-11-16.", desc)
|
||||
self.assertIn("https://github.com/o/r/issues/2", desc)
|
||||
plain = ET.fromstring(geo.gpx_text([[[0, 0], [1, 1]]], "N", licence="ODbL-1.0", licence_text="ODbL"))
|
||||
self.assertNotIn("Permission", plain.find("{http://www.topografix.com/GPX/1/1}metadata/"
|
||||
"{http://www.topografix.com/GPX/1/1}desc").text)
|
||||
|
||||
def test_other_licences_get_no_note(self):
|
||||
rec = permission_record()
|
||||
rec["source"]["licence"] = "CC-BY-4.0"
|
||||
self.assertNotIn("has said in writing", flat(trail.render(rec, S)[2]))
|
||||
|
||||
def test_data_page_row(self):
|
||||
rows = docs.line_licence_rows([permission_record()], os.path.dirname(WEB))
|
||||
what, terms, url = rows[0]
|
||||
self.assertIn("Tracks shared with permission: 1 record", str(what))
|
||||
self.assertIn("The holder has said in writing", str(terms))
|
||||
self.assertEqual(url, "/sources/")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,40 @@
|
||||
"""The page's controls, its address, the stored choices and what is drawn must
|
||||
say the same thing. These pin the script's answers to the faults found by
|
||||
driving the pages in a browser (the script itself has no unit tests)."""
|
||||
import os
|
||||
import re
|
||||
import unittest
|
||||
|
||||
WEB = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
|
||||
def read(*parts):
|
||||
with open(os.path.join(WEB, *parts), encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
class ScriptSyncTest(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.js = read("assets", "app.js")
|
||||
|
||||
def test_basemap_follows_a_choice_made_while_the_map_loaded(self):
|
||||
# Another tab, or Back, may change the base map before the map is ready; the
|
||||
# change event is then ignored, so the map catches up once it is ready and
|
||||
# the switch (which shows the choice) is added.
|
||||
self.assertRegex(self.js, re.compile(r"map\.addControl\(switcher, 'top-left'\);\s*/\*.*?\*/\s*applyBasemap\(\);", re.S))
|
||||
|
||||
def test_lengths_the_wrong_way_round_in_the_address_show_in_order(self):
|
||||
# apply() writes the shorter length first; the controls must say the same.
|
||||
self.assertIn("if (stepKm(el.min.value) > stepKm(el.max.value) && stepKm(el.max.value)) {", self.js)
|
||||
|
||||
def test_the_header_switch_is_the_only_units_switch(self):
|
||||
css = read("assets", "style.css")
|
||||
for text in (self.js, css, read("olt", "home.py")):
|
||||
self.assertNotIn("units-list", text)
|
||||
self.assertNotIn("results-units", text)
|
||||
self.assertNotIn("UNITS_TOGGLE", read("olt", "home.py"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -42,8 +42,6 @@ class DefaultOrderTest(unittest.TestCase):
|
||||
self.assertIn('value="mi" checked><span aria-hidden="true">mi</span><span class="vh">Miles and feet</span>', prefs)
|
||||
self.assertLess(prefs.index('value="mi"'), prefs.index('value="km"'))
|
||||
self.assertNotIn('value="km" checked', prefs)
|
||||
self.assertIn('value="mi" checked><span>mi</span>', home.UNITS_TOGGLE)
|
||||
self.assertLess(home.UNITS_TOGGLE.index(">mi<"), home.UNITS_TOGGLE.index(">km<"))
|
||||
|
||||
|
||||
class StoredChoiceTest(unittest.TestCase):
|
||||
|
||||
Reference in new issue
Block a user