Invite corrections: links on every page, issue forms, site checks
Validate / validate (push) Canceled after 0s
Validate / site (push) Canceled after 0s

Each trail's page now offers "Report a problem" (a GitHub form with the
record filled in), "Edit this record" and "History". The footer, the
home page and About link to the forms for a wrong record and a missing
trail, and Logos links to a form for a steward or creator who wants a
track or logo removed or re-credited. The links are built only when
repo_url in web/site.toml is a github.com repository.

.github/ has the three issue forms and a pull request checklist, and
the workflow also runs the site's tests and a build, on Python 3.12.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-13 13:17:20 -07:00
1 parent 1760ae4da9
commit 30c306ecc6
13 files changed
+377 -12

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
blank_issues_enabled: true
contact_links:
- name: Long Hikes website
url: https://longhikes.org
about: Browse the trails and routes, each record, its source, and its track where it may be shared.
+49
View File
@@ -0,0 +1,49 @@
name: Correction
description: A record is wrong or out of date
title: "Correction: "
body:
- type: markdown
attributes:
value: |
Thank you for helping correct this dataset. You do not need to use git:
fill in this form and a maintainer can make the change.
Every record is a text file, `<id>/trail.toml`. A correction needs a
source it can be checked against, so please give one below.
- type: input
id: trail
attributes:
label: Trail
description: The record id (shown on the trail's page, for example `arizona`), or the trail's name.
placeholder: "arizona"
validations:
required: true
- type: textarea
id: wrong
attributes:
label: What is wrong?
description: The fact, length, link, track, licence or other detail that is wrong or out of date.
validations:
required: true
- type: textarea
id: should
attributes:
label: What should it be?
description: The corrected information, as exactly as you can give it.
validations:
required: true
- type: input
id: source
attributes:
label: Where can it be checked?
description: A source page, map or other page where the correct information can be checked. For a corrected track, name where the track came from and its licence as well.
placeholder: "https://"
validations:
required: true
- type: textarea
id: notes
attributes:
label: Notes
description: Anything else that would help (optional).
validations:
required: false
+83
View File
@@ -0,0 +1,83 @@
name: Suggest a trail
description: A trail or route that is missing
title: "New trail: "
body:
- type: markdown
attributes:
value: |
Thank you for suggesting a trail or route. You do not need to use git:
fill in this form and a maintainer can add the record.
The inclusion rule (see README.md): a named, continuous walking route,
or a named loop, of at least 50 miles (80 km) — a few well-known
multi-day trails of 60–80 km are also listed — in the United States or
Canada. It is either a trail that a land agency or a trail association
designates, maintains and publishes as one trail, or a person-defined
route that a person or a small group worked out and published (a high
route, a traverse, or a loop of linked trails).
A trail can be listed as a record only, with no track, when no track
for it may be shared. A track is included only where its source's
terms allow it to be passed on.
- type: input
id: name
attributes:
label: Name
description: The trail's or route's published name.
validations:
required: true
- type: textarea
id: where
attributes:
label: Where is it?
description: Country, and the states, provinces or territories it passes through.
validations:
required: true
- type: input
id: length
attributes:
label: Length
description: The published length, in miles or kilometres, and where that figure comes from if you know it. The floor is 50 miles (80 km), apart from a few well-known trails of 60–80 km.
placeholder: "e.g. 120 miles (193 km)"
validations:
required: true
- type: input
id: steward
attributes:
label: Steward or creator
description: The land agency or trail association that designates, maintains and publishes it as one trail — or, for a person-defined route, the person or small group who worked it out and published it.
validations:
required: true
- type: input
id: official-page
attributes:
label: Official page
description: The steward's or creator's own page for the trail or route (for a route, where it is got from the creator — the guidebook, map set or page, and whether it is free or sold).
placeholder: "https://"
validations:
required: true
- type: dropdown
id: track-exists
attributes:
label: Is there a track?
description: A GPX, GeoJSON or other track of the route published by the steward or creator, or an OpenStreetMap route relation.
options:
- "Yes"
- "No"
- "I don't know"
validations:
required: false
- type: textarea
id: track-terms
attributes:
label: Track terms
description: If there is a track, where is it, and on what terms may it be passed on? A track is included only where its source's terms allow passing it on. For a person-defined route whose creator sells the route or chooses not to publish a track, the record will hold no track and will point to the creator instead.
validations:
required: false
- type: textarea
id: notes
attributes:
label: Notes
description: Anything else that would help (optional).
validations:
required: false
+58
View File
@@ -0,0 +1,58 @@
name: Removal or credit request
description: Ask for a track or logo to be removed or replaced, or its credit changed
title: "Removal: "
body:
- type: markdown
attributes:
value: |
For stewards, route creators and rights holders. If you want a track
or a logo removed or replaced, or its credit changed, please say so
here and it will be acted on: the file will be removed or replaced
and the record updated to say so. Logos are shown only to identify
each trail and belong to their holders. A route's creator can also
ask for the route's record to be corrected or removed.
Issues in this repository are public, so please do not post a
private email address or phone number here unless you are content
for it to be public.
- type: input
id: trail
attributes:
label: Trail
description: The record id (shown on the trail's page, for example `arizona`), or the trail's name.
placeholder: "arizona"
validations:
required: true
- type: input
id: relation
attributes:
label: Who are you in relation to the trail?
description: For example the trail's steward, the route's creator, the logo's holder, or the track's publisher.
validations:
required: true
- type: dropdown
id: kind
attributes:
label: What is the request about?
options:
- "A track"
- "A logo"
- "A credit"
- "The record itself"
- "Something else"
validations:
required: false
- type: textarea
id: request
attributes:
label: What should be removed or changed?
description: Say which file or credit, and what you would like done — removed, replaced, or credited differently (and with what wording). If you can, give the page that states your terms.
validations:
required: true
- type: input
id: contact
attributes:
label: How may we contact you?
description: Replies to this issue reach you through GitHub. Say here only if you would prefer another way, and only with details you are content to have public.
validations:
required: false
+12
View File
@@ -0,0 +1,12 @@
## What changed
<!-- Which trail (its record id), which fields or files, and why. -->
## Checklist
- [ ] One trail per pull request, where practical, and only that trail's directory changed.
- [ ] The validator passes: `python3 tools/build_index.py`, then `python3 tools/validate.py` prints `OK <n> trails`.
- [ ] The source for each changed fact is named (where it can be checked: a source page, a map, or a measured track).
- [ ] A track is included only where its source's terms allow it to be passed on (`redistributable` is `true` for every included file; see `docs/schema.md`). OpenStreetMap tracks carry the credit "© OpenStreetMap contributors" under the ODbL. Where a publisher's track may not be passed on, no track is included and the record says why (`source.line_absent_reason`).
- [ ] For a person-defined route, the track follows the creator's choice (`route.line_policy`): no track is included from any source, OpenStreetMap included, where the creator sells the route, withholds the track, or the position is not settled.
- [ ] `release.txt` is updated where track files changed (source, licence, date read), and any logo names its holder (`shield.logo_owner`) and where the art came from (`shield.logo_source`).
+14 -1
View File
@@ -11,5 +11,18 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
python-version: "3.12"
- run: python3 tools/validate.py
site:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
# Standard library only: no packages to install, and no ImageMagick.
# web/tools/make_thumbs.py is a manual tool; web/thumbs/ is committed
# and the build only copies those thumbnails (see web/olt/thumbs.py).
- run: python3 -m unittest discover -s web/tests
- run: python3 web/build.py --out _site
+7 -3
View File
@@ -54,7 +54,7 @@ def _classify(href, site):
if key.startswith("licenses/") and key.endswith(".txt"):
return "/licences/" + norm.split("/", 1)[1] + (f"#{frag}" if frag else "")
if site.repo_url:
return f"{site.repo_url}/blob/main/{norm}" + (f"#{frag}" if frag else "")
return site.blob_url(norm) + (f"#{frag}" if frag else "")
return None
@@ -228,7 +228,7 @@ def logos_page(records, site, repo_root):
<div class="titleblock__text"><p class="kicker">Marks</p><h1>Logos</h1>
<p class="page-head__lede">Logos are shown only to identify each trail. They belong to their holders.</p>
</div></header></div></div>
<div class="container section"><div class="prose doc">{notice_html}</div></div>
<div class="container section"><div class="prose doc">{notice_html}{f'<p><a href="{esc(site.removal_url)}">Ask for a track or logo to be removed, or its credit changed</a>.</p>' if site.is_github else ""}</div></div>
<div class="container section"><div class="section-head"><h2>Every logo in the dataset</h2>
<p>{len(with_logo)} records include a logo file.</p></div>
<ul class="logo-grid">{cards}</ul>
@@ -246,7 +246,11 @@ def about_page(records, site, repo_root):
"How to use it", "Report an error", "Licences", "Sources"]), site)
contrib = render_doc(read_doc(repo_root, "CONTRIBUTING.md"), site, heading_offset=1)
extra = ""
if site.issues_url:
if site.repo_url and site.is_github:
extra = (f'<p><a href="{esc(site.correction_url())}">Report a problem</a> with a record, or '
f'<a href="{esc(site.new_trail_url)}">suggest a trail</a> that is missing: '
f'short forms, no git needed. Or fix or add a trail yourself in the source repository.</p>')
elif site.issues_url:
extra = f'<p><a href="{esc(site.issues_url)}">Open an issue</a> to report an error.</p>'
if site.repo_url:
extra += f'<p>Source repository: <a href="{esc(site.repo_url)}">{esc(site.repo_url)}</a>.</p>'
+7
View File
@@ -311,12 +311,19 @@ def render(records, site):
lede = (f"A record for each of {total} long trails and routes, as a rule 50 miles (80&nbsp;km) or more: "
"what it is, how long it is, who publishes it, and on what terms its track may be passed on. "
"Where the terms allow, download the track as GPX or GeoJSON.")
contribute = ""
if site.repo_url:
contribute = (f'<p class="hero__caveat">Something wrong, or a trail missing? '
f'<a href="{esc(site.correction_url())}">Report a problem</a> or '
f'<a href="{esc(site.new_trail_url)}">suggest a trail</a>; '
f'the records are text files <a href="{esc(site.repo_url)}">anyone can fix or add to</a>.</p>')
return f"""<section class="hero" aria-labelledby="hero-title">
<div class="container hero__inner">
<p class="kicker">A public dataset &middot; United States and Canada</p>
<h1 id="hero-title">{esc(site.tagline)}</h1>
<p class="hero__lede">{lede}</p>
<p class="hero__caveat">This is a dataset, not a navigation product. Tracks vary in quality, some trails are unfinished, and some records have no track at all; each of those says why.</p>
{contribute}
<p><a class="button button--primary hero__cta" href="#q">Find a trail</a></p>
<div class="hero__counts">
<dl class="tally">
+5 -2
View File
@@ -60,8 +60,11 @@ def header(path, site):
def footer(site):
report = (f'<li><a href="{esc(site.issues_url)}">Report an error in a record</a></li>'
if site.issues_url else "")
report = ""
if site.repo_url:
report = (f'<li><a href="{esc(site.correction_url())}">Report an error in a record</a></li>'
f'<li><a href="{esc(site.new_trail_url)}">Suggest a trail</a></li>'
f'<li><a href="{esc(site.repo_url)}">Fix or add a trail</a></li>')
return Markup(f"""<footer class="site-footer">
<div class="container site-footer__grid">
<div class="site-footer__about">
+69 -2
View File
@@ -1,7 +1,8 @@
"""Site-wide settings from web/site.toml (name, tagline, base_url, repo_url, contact_url, name_lang)."""
"""Site-wide settings from web/site.toml (name, tagline, base_url, repo_url, repo_branch, contact_url, name_lang)."""
import functools
import os
import tomllib
import urllib.parse
WEB_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SITE_TOML = os.path.join(WEB_DIR, "site.toml")
@@ -10,13 +11,15 @@ SITE_TOML = os.path.join(WEB_DIR, "site.toml")
class Site:
"""The settings every page needs. Build one with load()."""
def __init__(self, name, tagline, base_url="", repo_url="", contact_url="", name_lang=None):
def __init__(self, name, tagline, base_url="", repo_url="", repo_branch="main",
contact_url="", name_lang=None):
if not name:
raise ValueError("site.toml: name must not be empty")
self.name = name
self.tagline = tagline
self.base_url = base_url.rstrip("/")
self.repo_url = repo_url.rstrip("/")
self.repo_branch = (repo_branch or "main").strip() or "main"
self.contact_url = contact_url.strip()
# record id -> language tag of its name ("fr"), for names that are not English
self.name_lang = dict(name_lang or {})
@@ -30,12 +33,76 @@ class Site:
"""Where to report an error, or "" when repo_url is unset."""
return self.repo_url + "/issues" if self.repo_url else ""
@property
def is_github(self):
"""True when repo_url is a github.com repository (the only host whose
edit/history/issue-form URL shapes the site builds)."""
return (urllib.parse.urlsplit(self.repo_url).hostname or "").lower() == "github.com"
def _github_issue_form_url(self, template, params=()):
query = urllib.parse.urlencode([("template", template), *params])
return f"{self.repo_url}/issues/new?{query}"
def correction_url(self, trail_id="", name=""):
"""Report-a-problem URL: the GitHub correction form prefilled with the
trail (fields are prefilled by their form id), else the issues list,
else "" when repo_url is unset."""
if not self.repo_url:
return ""
if not self.is_github:
return self.issues_url
params = []
if trail_id:
title = f"Correction: {name} ({trail_id})" if name else f"Correction: {trail_id}"
params = [("title", title), ("trail", trail_id)]
return self._github_issue_form_url("correction.yml", params)
@property
def new_trail_url(self):
"""Suggest-a-trail URL: the GitHub new-trail form, else the issues list, else ""."""
if not self.repo_url:
return ""
if not self.is_github:
return self.issues_url
return self._github_issue_form_url("new-trail.yml")
@property
def removal_url(self):
"""Track/logo removal URL: the GitHub removal form, else the issues list, else ""."""
if not self.repo_url:
return ""
if not self.is_github:
return self.issues_url
return self._github_issue_form_url("removal.yml")
def edit_url(self, trail_id):
"""GitHub edit URL for <id>/trail.toml, or "" for any other host / no repo."""
if not self.is_github:
return ""
branch = urllib.parse.quote(self.repo_branch, safe="/")
return f"{self.repo_url}/edit/{branch}/{urllib.parse.quote(trail_id, safe='')}/trail.toml"
def history_url(self, trail_id):
"""GitHub commit-history URL for <id>/, or "" for any other host / no repo."""
if not self.is_github:
return ""
branch = urllib.parse.quote(self.repo_branch, safe="/")
return f"{self.repo_url}/commits/{branch}/{urllib.parse.quote(trail_id, safe='')}"
def blob_url(self, path):
"""Repository URL of a file at repo_branch, or "" when repo_url is unset."""
if not self.repo_url:
return ""
branch = urllib.parse.quote(self.repo_branch, safe="/")
return f"{self.repo_url}/blob/{branch}/{path.lstrip('/')}"
def from_file(path):
with open(path, "rb") as f:
data = tomllib.load(f)
return Site(name=data.get("name", ""), tagline=data.get("tagline", ""),
base_url=data.get("base_url", ""), repo_url=data.get("repo_url", ""),
repo_branch=data.get("repo_branch", "main"),
contact_url=data.get("contact_url", ""), name_lang=data.get("name_lang", {}))
+12 -2
View File
@@ -653,8 +653,18 @@ def correction_block(rec, site):
<h3>If you made this route</h3>
<p>A route&rsquo;s creator can ask for its record to be corrected or removed, and the record will be corrected or removed. Say which route: {code(rec["id"])}. See <a href="/about/">About</a>.</p>
</div>""")
if site.issues_url:
parts.append(f"""<p class="prose">Found an error? <a href="{esc(site.issues_url)}">Open an issue</a> with the record ID ({code(rec["id"])}), what is wrong, and where the correct information can be checked: a source page, a map, or a measured line.</p>""")
if site.is_github:
report = esc(site.correction_url(rec["id"], rec.get("name", "")))
edit = esc(site.edit_url(rec["id"]))
history = esc(site.history_url(rec["id"]))
parts.append(f"""<p class="prose">This record is a text file anyone can correct. Please say where a correction can be checked: a source page, a map, or a measured track.</p>
<ul class="linklist">
<li><a href="{report}">Report a problem</a><small>No git needed: a short form, with this record ({code(rec["id"])}) filled in</small></li>
<li><a href="{edit}">Edit this record</a><small>The record file (trail.toml) on GitHub</small></li>
<li><a href="{history}">History</a><small>Changes to this record on GitHub</small></li>
</ul>""")
elif site.repo_url:
parts.append(f"""<p class="prose">Found an error? Report it in the <a href="{esc(site.repo_url)}">source repository</a>, with the record ID ({code(rec["id"])}), what is wrong, and where the correct information can be checked: a source page, a map, or a measured track.</p>""")
if not parts:
return ""
return block("correct-title", "Corrections", Markup("".join(parts)))
+5 -1
View File
@@ -14,7 +14,11 @@ base_url = "https://longhikes.org"
# Home of the source repository, for example "https://github.com/owner/repo".
# When set, pages link to it for reporting an error. Empty: those links are left out.
repo_url = ""
# This repository is public on GitHub; that is where issues and pull requests happen.
repo_url = "https://github.com/swaits/longhikes"
# Default branch of the source repository, for edit/history/blob links.
repo_branch = "main"
# Where to write to the maintainers (a contact page or a mailto: address), for
# logo removal requests and other questions. When this or repo_url is set, the
+51 -1
View File
@@ -17,7 +17,7 @@ WEB = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ROOT = os.path.dirname(WEB)
sys.path.insert(0, WEB)
from olt import layout, pages, records, site, trail, words # noqa: E402
from olt import home, layout, pages, records, site, trail, words # noqa: E402
OUT = os.path.join(WEB, ".cache", "test-site")
@@ -412,6 +412,56 @@ class RenderUnitTest(unittest.TestCase):
self.assertNotIn("/issues", layout.footer(site.Site("N", "T")))
self.assertIn("https://example.org/repo/issues", layout.footer(site.Site("N", "T", repo_url="https://example.org/repo")))
def test_trail_correction_links_github(self):
gh = site.Site("N", "T", repo_url="https://github.com/swaits/longhikes")
_, _, body, _ = trail.render(sample_record("A & B Trail"), gh)
plain = html.unescape(body)
self.assertIn("Report a problem", plain)
self.assertIn("https://github.com/swaits/longhikes/issues/new?"
"template=correction.yml&title=Correction%3A+A+%26+B+Trail+%28x%29&trail=x", plain)
self.assertIn("Edit this record", plain)
self.assertIn("https://github.com/swaits/longhikes/edit/main/x/trail.toml", plain)
self.assertIn("History", plain)
self.assertIn("https://github.com/swaits/longhikes/commits/main/x", plain)
def test_trail_correction_links_github_branch(self):
gh = site.Site("N", "T", repo_url="https://github.com/o/r/", repo_branch="dev")
block = html.unescape(trail.correction_block(sample_record("X Trail"), gh))
self.assertIn("https://github.com/o/r/edit/dev/x/trail.toml", block)
self.assertIn("https://github.com/o/r/commits/dev/x", block)
def test_trail_correction_links_non_github_fall_back_to_repo(self):
other = site.Site("N", "T", repo_url="https://example.org/repo")
block = html.unescape(trail.correction_block(sample_record("X Trail"), other))
self.assertIn('href="https://example.org/repo"', block)
self.assertNotIn("template=correction.yml", block)
self.assertNotIn("/edit/", block)
self.assertNotIn("/commits/", block)
self.assertNotIn("Edit this record", block)
def test_trail_correction_links_empty_repo_url(self):
block = trail.correction_block(sample_record("X Trail"), site.Site("N", "T"))
self.assertEqual(block, "")
self.assertNotIn("github.com", layout.footer(site.Site("N", "T")))
self.assertNotIn("Suggest a trail", layout.footer(site.Site("N", "T")))
def test_footer_and_home_contribute_links_github(self):
gh = site.Site("N", "T", repo_url="https://github.com/swaits/longhikes")
footer = html.unescape(layout.footer(gh))
self.assertIn("Fix or add a trail", footer)
self.assertIn('href="https://github.com/swaits/longhikes"', footer)
self.assertIn("Suggest a trail", footer)
self.assertIn("https://github.com/swaits/longhikes/issues/new?template=new-trail.yml", footer)
body = html.unescape(home.render([sample_record("X Trail")], gh))
self.assertIn("https://github.com/swaits/longhikes/issues/new?template=new-trail.yml", body)
def test_footer_contribute_links_non_github_have_no_github_forms(self):
other = site.Site("N", "T", repo_url="https://example.org/repo")
footer = html.unescape(layout.footer(other))
self.assertIn('href="https://example.org/repo"', footer)
self.assertNotIn("template=", footer)
self.assertNotIn("github.com", footer)
def test_render_site_on_a_synthetic_record(self):
with tempfile.TemporaryDirectory() as tmp:
repo, out = os.path.join(tmp, "repo"), os.path.join(tmp, "out")