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

+16
View File
@@ -41,6 +41,22 @@ def line_short(rec):
return line_differs(rec) and rec["verification"]["difference_percent"] < 0
def built_text(rec):
""""290 mi built" for an unfinished trail whose holder states the built length; else "". Markup."""
if not rec.get("built_km"):
return Markup("")
return Markup(f"{words.length(rec['built_km'], 'inline')} built")
def system_text(rec):
""""Whole system: 1,584 mi, counting all designated trail ..." where the holder publishes a
larger figure; else "". Markup. The note says what the figure counts (system_note)."""
if not rec.get("system_km"):
return Markup("")
return Markup(f"Whole system: {words.length(rec['system_km'], 'inline')}, "
f"counting {esc(str(rec.get('system_note', '')).strip().rstrip('.'))}")
def partial_short_text(rec):
"""The short form for lists: "Track measures 1.2 mi (2.0 km) of 684 mi (1,100 km) published",
in the reader's unit order (words.length). Markup."""
+6
View File
@@ -2,6 +2,7 @@
glossary.toml [[term]] the Glossary page (olt/reference.py)
collections.toml [[collection]] named sets of trails set side by side (olt/standing.py)
[[list]] which lists the home page shows, and in what order (olt/home.py)
authors.toml [[author]] route authors credited in more than one form (olt/authors.py)
Each is checked by tools/validate.py and described in docs/schema.md. Like left-out.toml, a file
@@ -34,3 +35,8 @@ def collections(repo_root):
def authors(repo_root):
return load(repo_root, "authors.toml", "author")
def lists(repo_root):
"""The [[list]] entries of collections.toml: a list's key, and `home`, its place in the home page's row."""
return load(repo_root, "collections.toml", "list")
+3 -2
View File
@@ -373,8 +373,9 @@ site calls them trails.</p>
<p>A trail is listed when it is a named, continuous walk, or a named loop, of at least 50&nbsp;miles (80&nbsp;km)
in the United States or Canada. It is either an official trail, looked after as one trail by a land agency or
a trail association, or a route: {esc(facets.ROUTE_DEFINITION[0].lower() + facets.ROUTE_DEFINITION[1:])}
{routes} of the {n} trails are routes. Every National Scenic Trail is listed, and a few well-known multi-day
trails between 37 and 50&nbsp;miles (60 and 80&nbsp;km).</p>
{routes} of the {n} trails are routes. The length is the end-to-end length of the trail&rsquo;s canonical path, and the
trail must be walkable from one end to the other today. A National Scenic Trail is listed unless it cannot be walked
through, and so are a few well-known multi-day trails between 37 and 50&nbsp;miles (60 and 80&nbsp;km).</p>
<p>Each record has a <em>tier</em>, which says why it is listed. A record can also be <em>held</em>: listed,
but with something about it not yet settled, which its note says.</p>
<p>Trails that were looked at and left out are kept in the open too, with the reason for each one:
+81 -55
View File
@@ -7,7 +7,7 @@ attributes in olt/facets.py, under the same names the trail pages use.
import collections
import math
from . import browse, common, facets, hike, words
from . import browse, common, datafiles, facets, hike, sketch, words
from .markup import Markup, esc
# Length range choices for the filters, round in the unit they are written in.
@@ -68,17 +68,22 @@ def counts(records):
return c
def overview_bbox(records):
"""data-bbox attribute: the extent of every track and sketch, so the map opens on it before the data loads."""
def overview_box(records):
"""[west, south, east, north] of every track and sketch of these trails, or None."""
boxes = [r["derived"]["bbox"] for r in records if r["derived"].get("bbox")]
for r in records:
box = hike.sketch_bbox(hike.sketch_points(r))
if box:
boxes.append(box)
if not boxes:
return ""
box = [min(b[0] for b in boxes), min(b[1] for b in boxes), max(b[2] for b in boxes), max(b[3] for b in boxes)]
return f' data-bbox="{",".join(f"{v:.4f}" for v in box)}"'
return None
return [min(b[0] for b in boxes), min(b[1] for b in boxes), max(b[2] for b in boxes), max(b[3] for b in boxes)]
def overview_bbox(records):
"""data-bbox attribute: the extent of every track and sketch, so the map opens on it before the data loads."""
box = overview_box(records)
return f' data-bbox="{",".join(f"{v:.4f}" for v in box)}"' if box else ""
sort_name = facets.sort_name
@@ -304,24 +309,28 @@ def finder_form(records, c=None, steps=None):
{_checks("gpx", facets.GPX_FILTER.items(), c, "gpx")}
</fieldset>""")
return f"""<form class="filters" id="finder-form" role="search" aria-label="Find a trail">
<div class="filters__search field">
<label class="field__label" for="q">Search</label>
<input class="input" id="q" name="q" type="search" placeholder="Name, abbreviation or author of a route" autocomplete="off" spellcheck="false">
<div class="filters__bar">
<div class="filters__search field">
<label class="vh" for="q">Search</label>
<input class="input" id="q" name="q" type="search" placeholder="Search by name, abbreviation or author" autocomplete="off" spellcheck="false">
</div>
<button class="button filters__toggle js-only" type="button" aria-expanded="false" aria-controls="filters-panels">Filters <span class="filters__count"></span></button>
<button class="button button--quiet filters__clear" type="reset" hidden>Clear</button>
<a class="button button--quiet filters__maplink" href="#map">Map</a>
</div>
<details class="filters__panel" open>
<summary>Filters <span class="filters__count"></span></summary>
<div class="filters__first">
{"".join(first)}
</div>
</details>
<details class="filters__more">
<summary>More filters <span class="filters__active"></span></summary>
<div class="filters__form">
{"".join(more)}
</div>
</details>
<div class="field filters__reset">
<button class="button button--quiet" type="reset">Clear search and filters</button>
<div class="filters__panels" id="filters-panels">
<details class="filters__panel" open>
<summary>Filters</summary>
<div class="filters__first">
{"".join(first)}
</div>
</details>
<details class="filters__more">
<summary>More filters <span class="filters__active"></span></summary>
<div class="filters__form">
{"".join(more)}
</div>
</details>
</div>
</form>"""
@@ -559,11 +568,19 @@ def overview_map(recs, label, *, wide=False, scope="", saved=False):
ids_attr += f' data-drawable="{esc(" ".join(ids))}"'
sentences.append("Each trail&rsquo;s page names its source, credit and licence. "
"Base map: OpenFreeMap, &copy;&nbsp;OpenMapTiles, data &copy;&nbsp;OpenStreetMap contributors.")
return Markup(f"""<figure class="mapfig{" mapfig--wide" if wide else ""}" data-map="overview" data-src="/data/overview.geojson"{ids_attr}{overview_bbox(recs)}>
# The tracks are drawn into the page, on the ground the live map opens on (olt/sketch.py). The
# Saved page has none: which trails it draws is the visitor's own, so app.js draws them.
frame_attr, drawing = "", ""
box = overview_box(recs)
if box and not saved:
fr = sketch.frame(box)
frame_attr = f' data-frame="{",".join(f"{v:g}" for v in fr)}"'
drawing = sketch.svg(sketch.overview_features(ids), fr, ident=True)
return Markup(f"""<figure class="mapfig{" mapfig--wide" if wide else ""}" data-map="overview" data-src="/data/overview.geojson"{ids_attr}{overview_bbox(recs)}{frame_attr}>
<div class="mapfig__frame">
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true"></span>
<div class="map" role="region" aria-label="{esc(label)}">
<div class="map__fallback"></div>
<div class="map__fallback">{drawing}</div>
<div class="map__canvas"></div>
<p class="map__status" role="status">The map needs JavaScript. The list has every trail.</p>
</div>
@@ -578,18 +595,32 @@ def overview_map(recs, label, *, wide=False, scope="", saved=False):
</figure>""")
def place_grid(text_html, listing, map_html):
"""The body of a place, list or routes page: the list beside its map on a wide screen, with the
page's own text above the map there, so that the first trails are on the first screen. On a
narrow screen the list comes first, then the map, then the text (style.css .place-grid)."""
return f"""<div class="place-grid">
<div class="place-grid__text">{text_html}</div>
<div class="place-grid__list">{listing}</div>
<div class="place-grid__map">{map_html}</div>
</div>"""
def has_overview_map(recs, scope=""):
"""True when overview_map would draw a map of these trails (needs the map library)."""
n = len(drawable_ids(recs))
return n > 0 and (scope == "all" or n >= MAP_MIN)
def lists_row(records):
"""The ready-made lists, as a row of links with their counts. The terrain lists are
on /lists/; here the Terrain filter does the same work."""
def lists_row(records, picks=()):
"""The row of lists on the home page: the lists the data file marks for it (picks, from
datafiles.home_lists: key and position), in that order, each with its count, then "All lists".
A marked list that is not shown today (too few trails, or nearly all of them) is left out."""
have = {lst.key: (lst, recs) for lst, recs in browse.shown(records)}
items = "".join(
f'<li><a href="{esc(browse.path(lst))}">{esc(lst.title)} <span class="chips__n">{len(recs)}</span></a></li>'
for lst, recs in browse.shown(records) if not lst.key.startswith("terrain-"))
f'<li><a href="{esc(browse.path(have[key][0]))}">{esc(have[key][0].title)} '
f'<span class="chips__n">{len(have[key][1])}</span></a></li>'
for key in picks if key in have)
if not items:
return ""
return f"""<nav class="lists-row" aria-labelledby="lists-title">
@@ -598,6 +629,12 @@ def lists_row(records):
</nav>"""
def home_picks(entries):
"""The keys of the lists marked for the home page, in the order of their `home` positions."""
marked = [e for e in entries if isinstance(e.get("home"), int)]
return [e["key"] for e in sorted(marked, key=lambda e: e["home"])]
def description(records):
"""The home page's meta description: how many, what each has, and how many have a GPX."""
n_gpx = sum(1 for r in records if facets.gpx_here(r))
@@ -606,8 +643,8 @@ def description(records):
return common.cut_at_word(text, common.DESCRIPTION_LIMIT)
def render(records, site):
"""The home page body (HTML)."""
def render(records, site, repo_root=""):
"""The home page body (HTML). repo_root: where collections.toml names the lists the page shows."""
c = counts(records)
recs = sorted(records, key=sort_name)
total = c["total"]
@@ -618,32 +655,21 @@ def render(records, site):
contribute = (f'<p class="finder__foot">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>.</p>')
picks = home_picks(datafiles.lists(repo_root))
return f"""<section class="hero hero--short hero--home" aria-labelledby="hero-title">
<div class="container hero__inner">
<h1 id="hero-title" class="lockup"><img class="lockup__mark" src="/assets/favicon.svg" alt="" width="96" height="96">{esc(site.name)}<span class="vh">: long-distance hiking trails of the United States and Canada</span></h1>
<p class="hero__tagline">{esc(site.tagline.rstrip("."))}.</p>
<ul class="hero__tags">
<li><a href="#finder">Filters</a></li>
<li><a href="/lists/with-gpx/">GPX</a></li>
<li><a href="/sources/">A source for every fact</a></li>
<li><a href="/data/">Open data</a></li>
</ul>
<h1 id="hero-title">{esc(site.tagline.rstrip("."))}</h1>
<p class="hero__lede">{lede}</p>
{lists_row(records)}
</div>
</section>
<section class="section section--finder" id="finder" aria-labelledby="finder-title">
<div class="container finder__grid">
<h2 class="vh" id="finder-title">Every trail</h2>
{finder_form(records, c, length_steps(records))}
<div class="finder__main">
{overview_map(records, "Map of the trails the filters leave", wide=True, scope="all")}
{results(recs, finder=True)}
</div>
<div class="finder__notes">
<p class="finder__foot">Not for navigation: tracks vary in quality and some trails are unfinished. Check each trail&rsquo;s own maps before you go.</p>
{contribute}
</div>
<div class="container home" id="finder">
<div class="home__lists">{lists_row(records, picks)}</div>
<h2 class="vh" id="finder-title">Every trail</h2>
<div class="home__bar">{finder_form(records, c, length_steps(records))}</div>
<div class="home__results">{results(recs, finder=True)}</div>
<div class="home__map" id="map">{overview_map(records, "Map of the trails the filters leave", wide=True, scope="all")}</div>
<div class="home__notes finder__notes">
<p class="finder__foot">Not for navigation: tracks vary in quality and some trails are unfinished. Check each trail&rsquo;s own maps before you go.</p>
{contribute}
</div>
</section>"""
</div>"""
+20 -11
View File
@@ -24,14 +24,19 @@ from .markup import Markup, attrs, esc, json_block
NAV = (
("Trails", "/"),
("Places", "/regions/"),
("Lists", "/lists/"),
("About", "/about/"),
)
# Pages with no header item of their own, and the item they sit under. The
# lists (Routes among them) are part of Trails; the dataset pages are part of
# About and are linked from the About hub and the footer.
NAV_PARENT = {"/trails/": "/", "/lists/": "/", "/routes/": "/",
# Pages with no header item of their own, and the item they sit under. A trail's page is part of
# Trails; the dataset pages are part of About and are linked from the About hub and the footer.
NAV_PARENT = {"/trails/": "/",
"/sources/": "/about/", "/logos/": "/about/", "/data/": "/about/",
"/left-out/": "/about/"}
"/left-out/": "/about/", "/method/": "/about/", "/glossary/": "/about/"}
# Under Lists: the lists (Routes among them), the tables and rankings, the authors and the views of
# what is new. A table that collections.toml names has an address of its own; olt/pages.py adds it
# to UNDER_LISTS as it writes the page.
LISTS_PREFIXES = ("/lists/", "/routes/", "/numbers/", "/authors/", "/recent/", "/connected/")
UNDER_LISTS = set()
FEED_PATH = "/feed.xml" # the Atom feed of the changelog (olt/feed.py)
@@ -45,6 +50,7 @@ FONT_PRELOADS = (
"/assets/fonts/ibm-plex-sans-condensed-500-latin.woff2",
"/assets/fonts/ibm-plex-sans-condensed-600-latin.woff2",
)
CONTOURS = "/assets/contours.svg"
MAPLIBRE_CSS = "/assets/vendor/maplibre-gl/maplibre-gl.css"
MAPLIBRE_JS = "/assets/vendor/maplibre-gl/maplibre-gl.js"
# The outdoor map of the trail pages: its style, named on each trail map figure
@@ -56,11 +62,11 @@ CONTOUR_JS = "/assets/vendor/maplibre-contour/maplibre-contour.js"
def _current(path, href):
"""True when the nav item href is the section the page at path belongs to."""
if href == "/" and path == "/":
return True
if href == "/lists/":
return path.startswith(LISTS_PREFIXES) or path in UNDER_LISTS
if any(path.startswith(p) and parent == href for p, parent in NAV_PARENT.items()):
return True
return href != "/" and path.startswith(href)
return path == "/" if href == "/" else path.startswith(href)
SAVED_PATH = "/saved/"
@@ -207,7 +213,7 @@ def layout(title, body, *, path, description="", maps=False, outdoor=False, scri
description meta description (155 characters); defaults to the site tagline. The share
descriptions (og:description, twitter:description) are cut from it to 125.
maps True on a page with a .mapfig[data-map]: app.js is given the addresses of
MapLibre, and loads it when the map scrolls into view or is touched.
MapLibre, and loads it a moment after the page has loaded.
outdoor True as well on a page whose map is an outdoor map (a trail
page): app.js loads the contour add-on with MapLibre.
scripts extra same-origin script URLs, loaded with defer after app.js.
@@ -275,14 +281,17 @@ def layout(title, body, *, path, description="", maps=False, outdoor=False, scri
head += [f'<link rel="alternate" type="{esc(kind)}" href="{esc(href)}"{attrs(title=name)}>'
for href, kind, name in alternates]
head += [f'<link rel="preload" href="{fingerprint.url(f)}" as="font" type="font/woff2" crossorigin>' for f in FONT_PRELOADS]
# The contour picture behind the page head: found by the stylesheet only, so it would arrive after
# the first paint and, on a compact head, be the last thing painted (the page's largest paint).
head.append(f'<link rel="preload" href="{fingerprint.url(CONTOURS)}" as="image" type="image/svg+xml">')
head += [
f'<link rel="stylesheet" href="{fingerprint.url("/assets/style.css")}">',
# Sets the theme and unit preference before first paint (no inline scripts allowed).
f'<script src="{fingerprint.url("/assets/prefs.js")}"></script>',
]
# The page's one script. A page with a map does not load MapLibre (200 KB of script, 65 KB
# of style) with the page: app.js loads these three files itself, when the map scrolls
# into view or is touched, from the addresses it is given here.
# of style) with the page: app.js loads these three files itself, a moment after the page has
# loaded and never on a scroll or a touch, from the addresses it is given here.
libs = {}
if maps:
libs = {"data-maplibre-css": MAPLIBRE_CSS, "data-maplibre-js": MAPLIBRE_JS}
+7 -7
View File
@@ -117,17 +117,17 @@ def left_out_page(entries, site, repo_root):
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'<tr><td data-label="Trail">{esc(e.get("name", ""))}{mark}</td>'
f'<td data-label="Where">{esc(_where(e))}</td>'
f'<td data-label="Length">{_length(e)}</td>'
f'<td data-label="Why it is left out">{why}</td>'
f'<td data-label="Decided"><time datetime="{esc(e.get("decided", ""))}">'
f"{esc(e.get('decided', ''))}</time></td>"
f"<td>{source}</td></tr>")
f'<td data-label="Source">{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>
<div class="table-wrap"><table data-stack="rows">
<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>"""
+19 -6
View File
@@ -16,23 +16,36 @@ def head(h1, lede_html, crumbs, *, kicker=""):
</div></div>"""
def table(headers, rows, *, caption="", numeric=(), row_heads=False):
# A table with at least this many columns is set as one block per row on a phone (style.css).
STACK_COLUMNS = 4
def table(headers, rows, *, caption="", numeric=(), row_heads=False, compare=False):
"""A table in the site's table wrapper. headers: column titles; rows: lists of HTML cells
(Markup, or text that is escaped); numeric: column numbers set at the end of the cell;
row_heads: the first cell of each row is a row heading."""
def cell(i, value, head=False):
row_heads: the first cell of each row is a row heading.
Every cell carries its label (data-label: its column's title, or in a compare table its row's
heading) so that a phone can set the same markup as blocks, with no sideways scrolling
(style.css): one block per row where the table has STACK_COLUMNS columns or more, and
compare: a table of figures down the side and one trail in each column, with a fixed layout
of equal columns, and on a phone one block per trail, headed by the trail's name."""
def cell(i, value, label, head=False):
text = value if isinstance(value, Markup) else esc(value)
cls = ' class="num"' if i in numeric else ""
if head:
return f'<th scope="row"{cls}>{text}</th>'
return f"<td{cls}>{text}</td>"
return f'<td{cls} data-label="{esc(label)}">{text}</td>'
cap = f'<caption class="vh">{esc(caption)}</caption>' if caption else ""
num = ' class="num"'
head = "".join(f'<th scope="col"{num if i in numeric else ""}>{esc(h)}</th>' for i, h in enumerate(headers))
body = "".join(
"<tr>" + "".join(cell(i, v, head=row_heads and i == 0) for i, v in enumerate(row)) + "</tr>"
"<tr>" + "".join(cell(i, v, row[0] if compare else headers[i], head=row_heads and i == 0)
for i, v in enumerate(row)) + "</tr>"
for row in rows)
return Markup(f'<div class="table-wrap"><table>{cap}<thead><tr>{head}</tr></thead><tbody>{body}</tbody></table></div>')
mode = "columns" if compare else "rows" if len(headers) >= STACK_COLUMNS else ""
stack = f' data-stack="{mode}"' if mode else ""
return Markup(f'<div class="table-wrap"><table{stack}>{cap}<thead><tr>{head}</tr></thead><tbody>{body}</tbody></table></div>')
def trail_link(rec):
+5 -2
View File
@@ -31,7 +31,7 @@ import os
import shutil
from .markup import esc
from . import authors, browse, cards, datafiles, docs, facets, feed, home, layout, leftout, pagekit, placefacets, reference, regions, saved, seo, site as site_settings, standing, thumbs, trail, views
from . import authors, browse, cards, datafiles, docs, facets, feed, home, layout, leftout, pagekit, placefacets, reference, regions, saved, seo, site as site_settings, sketch, standing, thumbs, trail, views
WEB_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ASSETS_DIR = os.path.join(WEB_DIR, "assets")
@@ -86,6 +86,8 @@ def render_site(records, out_dir, repo_root, site=None):
"""Write every HTML page for the given records. Returns the number of pages written."""
site = site or site_settings.load()
copy_assets(out_dir)
sketch.use(out_dir) # the maps' static drawings are read from the track files written here
layout.UNDER_LISTS.clear()
pages = 0
dates = {} # page path -> its own date (YYYY-MM-DD), for the sitemap
everything = seo.newest(records)
@@ -105,7 +107,7 @@ def render_site(records, out_dir, repo_root, site=None):
image=card, image_alt=card_alt))
dates[path] = seo.modified(rec)
pages += 1
body = home.render(records, site)
body = home.render(records, site, repo_root)
layout.write_page(out_dir, "/", layout.layout("", body, path="/", maps=True, site=site,
description=home.description(records),
jsonld=seo.home_jsonld(site)))
@@ -161,6 +163,7 @@ def render_site(records, out_dir, repo_root, site=None):
recs = built[3] if len(built) > 3 and isinstance(built[3], list) else None
pending.append((path, t, d, b, {"recs": recs}))
view_paths.append(path)
layout.UNDER_LISTS.add(path) # its header item is Lists
labels[path] = link_label
if group:
extras.append((group, link_label, blurb, path, len(recs) if recs else 0))
+2 -3
View File
@@ -105,9 +105,8 @@ def page(p, records, site, all_pages):
</div></header>
</div></div>
<div class="container section place">
<div class="prose place-summary">{summary.facts(recs, records)}</div>
{home.overview_map(recs, f"Map of the trails in {name}: {lst.title}")}
{home.results(recs, default_sort=lst.sort, top=2)}
{home.place_grid(f'<div class="prose place-summary">{summary.facts(recs, records)}</div>', home.results(recs, default_sort=lst.sort, top=2),
home.overview_map(recs, f"Map of the trails in {name}: {lst.title}"))}
<nav class="region-nav" aria-label="Lists"><a href="{esc(browse.path(lst))}">{esc(lst.title)} everywhere</a> · <a href="/lists/">All lists</a></nav>
{nav}
</div>"""
+4 -1
View File
@@ -108,6 +108,8 @@ def method_page(records, site, repo_root):
gaps = sum(1 for r, _ in ver if r.get("source", {}).get("length_gap_note"))
mid = statistics.median(abs(d) for _, d in ver) if ver else 0
no_track = sum(1 for r in records if not common.has_line(r))
n_system = sum(1 for r in records if r.get("system_km"))
n_built = sum(1 for r in records if r.get("built_km"))
elev = [(r, elevation.get(r)) for r in records if elevation.get(r)]
src = collections.Counter((e["source"].get("model", ""), e["source"].get("smoothing", ""),
e["source"].get("sample_spacing_m")) for _, e in elev if e.get("source"))
@@ -130,7 +132,8 @@ def method_page(records, site, repo_root):
f"length was measured and checked against the published length."), [("Trails", "/"), ("About", "/about/")])
+ f"""<div class="container section place"><div class="prose">
<h2>Length</h2>
<p>{esc(_sentence(meaning.get("length_km", "")))} It is the figure the trail&rsquo;s holder or author gives, and each record says where it comes from. The lists and pages show it in miles with kilometres after.</p>
<p>A trail&rsquo;s length here is the end-to-end length of its canonical path: one walk from one end to the other, taking one branch at a split, leaving out side trails and counting no stretch twice. It is the figure the trail&rsquo;s holder or author gives for that walk, and each record says where it comes from. A trail that cannot be walked from end to end today is not listed. The lists and pages show the length in miles with kilometres after.</p>
<p>Some holders also publish a larger figure for a whole system, or a planned total. A record keeps it apart as the whole system, with what it counts, and no list, length band or time estimate uses it. {n_system} of the {n} records have one. A trail that can be walked through but is partly unbuilt keeps the holder&rsquo;s end-to-end route as its length and gives the built length beside it. {n_built} of the {n} records give one.</p>
<p>Where a track is included, its length is measured along the track as a geodesic length and compared with the published figure. The difference is the measured length minus the published length, as a percent of the published length. Track ends within 100 metres are joined, and the number of parts left is shown.</p>
<p>Across the {len(ver)} measured tracks, the middle difference is {mid:.1f} percent.</p>
{pagekit.table(["Measured against published", "Tracks", "Share"], rows, caption="How the measured tracks compare", numeric=(1, 2))}
+13 -18
View File
@@ -178,9 +178,8 @@ def region_page(slug, records, site, facet_pages=()):
</div></header>
</div></div>
<div class="container section place">
<div class="prose place-summary">{summary.facts(recs, records)}{standing_note}{summary.details(recs)}</div>
{home.overview_map(recs, f"Map of the trails in {info['name']}")}
{home.results(recs, top=2)}
{home.place_grid(f'<div class="prose place-summary">{summary.facts(recs, records)}{standing_note}{summary.details(recs)}</div>',
home.results(recs, top=2), home.overview_map(recs, f"Map of the trails in {info['name']}"))}
{nav}
</div>"""
name = info["name"]
@@ -236,6 +235,14 @@ def routes_page(records, site, repo_root=None, after="", author_pages=None):
groups = [(f"By {author_pages[a]}" if a in author_pages else f"By {esc(a)}", sorted(by_author[a], key=home.sort_name), route_guides)
for a in sorted(by_author, key=str.lower)]
n_gpx = _gpx_count(routes)
intro = f"""<div class="prose">
<p>Every other trail on this site is an official trail. Being a route says who looks after it, not
how rough it is: some routes are on maintained trail all the way, and some official trails have
long road walks. The Walking line on each trail&rsquo;s page says what the walking is.</p>
<p>{_plural(len(routes), "route")}, by {len(by_author)} authors. {n_gpx} {"has" if n_gpx == 1 else "have"} a GPX here; for the rest,
each route&rsquo;s page says whether its author gives the track away, sells it, or does not publish it.
<a href="/?kind=route">Narrow them with the filters</a>.</p>
</div>"""
body = f"""<div class="page-head"><div class="container">
<nav class="breadcrumb" aria-label="Breadcrumb"><ol><li><a href="/">Trails</a></li>
<li><a href="/lists/">Lists</a></li><li aria-current="page">Routes</li></ol></nav>
@@ -243,18 +250,7 @@ def routes_page(records, site, repo_root=None, after="", author_pages=None):
<p class="page-head__lede" id="what-is-a-route">{esc(facets.ROUTE_DEFINITION)}</p>
</div></header></div></div>
<div class="container section">
<div class="prose">
<p>Every other trail on this site is an official trail. Being a route says who looks after it, not
how rough it is: some routes are on maintained trail all the way, and some official trails have
long road walks. The Walking line on each trail&rsquo;s page says what the walking is.</p>
<p>{_plural(len(routes), "route")}, by {len(by_author)} authors. {n_gpx} {"has" if n_gpx == 1 else "have"} a GPX here; for the rest,
each route&rsquo;s page says whether its author gives the track away, sells it, or does not publish it.
<a href="/?kind=route">Narrow them with the filters</a>.</p>
</div>
</div>
<div class="container section">
{home.overview_map(routes, "Map of the routes with a GPX here")}
{home.results(groups=groups, routes_list=True, top=2)}
{home.place_grid(intro, home.results(groups=groups, routes_list=True, top=2), home.overview_map(routes, "Map of the routes with a GPX here"))}
{after}
<nav class="region-nav" aria-label="Other lists">{'<a href="/authors/">Route authors</a> · ' if linked else ""}<a href="/lists/">All lists</a> · <a href="/">Every trail</a></nav>
</div>"""
@@ -286,10 +282,9 @@ def list_page(lst, recs, total, site, *, records=None, before="", after=""):
</div></header>
</div></div>
<div class="container section place">
<div class="prose place-summary">{about}</div>
{before}
{home.overview_map(recs, f"Map of the trails in the list {lst.title}")}
{home.results(recs, default_sort=lst.sort, top=2)}
{home.place_grid(f'<div class="prose place-summary">{about}</div>', home.results(recs, default_sort=lst.sort, top=2),
home.overview_map(recs, f"Map of the trails in the list {lst.title}"))}
{after}
<p class="finder__foot">{rule}</p>
<nav class="region-nav" aria-label="Other lists"><a href="/lists/">All lists</a> · <a href="/">Every trail</a></nav>
+13 -1
View File
@@ -56,7 +56,9 @@ def distribution():
# What the dataset records for each trail (docs/schema.md), as variableMeasured.
VARIABLES = (
("length_km", "Published length of the trail", "KMT"),
("length_km", "End-to-end length of the trail's canonical path, as its holder or author states it", "KMT"),
("system_km", "The larger figure the holder publishes for the whole system or a planned total, where there is one", "KMT"),
("built_km", "The built length of an unfinished trail, as its holder states it", "KMT"),
("measured_km", "Length measured from the track, in kilometres", "KMT"),
("difference_percent", "Measured length against the published length, in per cent", "P1"),
("ascent_m", "Total climbing along the track, computed from an elevation model", "MTR"),
@@ -257,6 +259,16 @@ def _properties(rec):
_pv("Published length", mi, "SMI", "miles", description=rec.get("length_note", "")),
_pv("Published length", rec["length_km"], "KMT", "kilometres"),
]
if rec.get("system_km"):
# The holder's larger figure: its own labelled value, never the trail's length.
note = str(rec.get("system_note", "")).strip().rstrip(".")
props.append(_pv("Whole system length", round(words.km_to_mi(rec["system_km"])), "SMI", "miles",
description=f"Counting {note}"))
props.append(_pv("Whole system length", rec["system_km"], "KMT", "kilometres",
description=f"Counting {note}"))
if rec.get("built_km"):
props.append(_pv("Built length", round(words.km_to_mi(rec["built_km"])), "SMI", "miles"))
props.append(_pv("Built length", rec["built_km"], "KMT", "kilometres"))
days = h.get("days")
if isinstance(days, list) and len(days) == 2:
props.append(_pv("Usual time to walk it all", f"{days[0]} to {days[1]} days", "DAY", "days",
+188
View File
@@ -0,0 +1,188 @@
"""The static sketch: the tracks of a map, drawn into the page at build time.
A map frame is never empty. From the first paint it holds a light drawing of the track, on the
plain ground, in the colours the live map uses (the .fallback__* rules of style.css), and the live
map (app.js) takes over from it without a jump. For that the two must frame the same ground:
frame the extent of the tracks, widened on every side by PAD of its longer side, as
[west, south, east, north] in degrees (data-frame on the figure). The drawing
fits it exactly, and app.js opens the live map on the same box with no padding,
so the track holds still when the base map arrives.
The drawing is an <svg> with a fixed viewBox (the frame, FIT units along its longer side) and
preserveAspectRatio="xMidYMid meet", so it fits any frame size the way the live map fits the
same bounds. Coordinates are Web Mercator, as the live map's. Each track is simplified to TOL
units and written as whole numbers in one relative path: a few kilobytes for a trail, and a
fixed, small size for the overview of every trail.
The tracks are read from the files the build has already written (trails/<id>/map.json,
data/overview.geojson): the same simplified geometry the page ships to the live map.
"""
import json
import math
import os
from . import geo
from .markup import Markup
FIT = 1200 # the longer side of the viewBox, in user units
PAD = 0.07 # each side of the frame, as a share of the extent's longer side
TOL = 1.1 # simplification, in viewBox units (about a pixel on a wide screen)
MANY = 12 # a map of more tracks than this is drawn lighter: coarser, and with no halo
TOL_MANY = 2.4
MIN_SPAN = (0.5, 0.36) # degrees: a lone point or a tiny extent gets about a county of ground
RAD = math.pi / 180.0
EARTH_M = 6371008.8
DATA_DIR = "" # the site being built (olt/pages.py sets it); no data, no sketch
_cache = {}
def use(out_dir):
"""Name the site directory the tracks are read from, and forget what was read before."""
global DATA_DIR
DATA_DIR = out_dir or ""
_cache.clear()
def _read(*parts):
if not DATA_DIR:
return None
path = os.path.join(DATA_DIR, *parts)
if path not in _cache:
try:
with open(path, encoding="utf-8") as f:
_cache[path] = json.load(f)
except (OSError, ValueError):
_cache[path] = None
return _cache[path]
def trail_features(trail_id):
"""The features of one trail's map.json (main and alternates), or []."""
fc = _read("trails", trail_id, "map.json") or _read("trails", trail_id, "sketch.json")
return list(fc["features"]) if fc else []
def overview_features(ids=None):
"""The overview's features, limited to the trail ids given (all when None)."""
fc = _read("data", "overview.geojson")
if not fc:
return []
want = None if ids is None else set(ids)
return [f for f in fc["features"] if want is None or (f.get("properties") or {}).get("id") in want]
def _merc(lat):
return math.log(math.tan(math.pi / 4 + lat * RAD / 2))
def _unmerc(y):
return math.degrees(2 * math.atan(math.exp(y)) - math.pi / 2)
def frame(box):
"""[west, south, east, north] of the ground a map frame shows for the extent `box`
(the same box in degrees): widened by PAD, and given a minimum size."""
w, s, e, n = box
if e - w < 0.02:
cx = (w + e) / 2
w, e = cx - MIN_SPAN[0] / 2, cx + MIN_SPAN[0] / 2
if n - s < 0.02:
cy = (s + n) / 2
s, n = cy - MIN_SPAN[1] / 2, cy + MIN_SPAN[1] / 2
x0, x1 = w * RAD, e * RAD
y0, y1 = _merc(s), _merc(n)
pad = PAD * max(x1 - x0, y1 - y0)
return [round((x0 - pad) / RAD, 5), round(_unmerc(y0 - pad), 5),
round((x1 + pad) / RAD, 5), round(_unmerc(y1 + pad), 5)]
def frame_attr(box):
return ",".join(f"{v:g}" for v in frame(box))
class Plane:
"""Projects [lon, lat] into the viewBox of a frame."""
def __init__(self, fr):
w, s, e, n = fr
self.x0, self.x1 = w * RAD, e * RAD
self.y0, self.y1 = _merc(s), _merc(n)
span = max(self.x1 - self.x0, self.y1 - self.y0)
self.k = FIT / span
self.w = (self.x1 - self.x0) * self.k
self.h = (self.y1 - self.y0) * self.k
# metres on the ground per viewBox unit, at the middle of the frame
mid = _unmerc((self.y0 + self.y1) / 2)
self.m_per_unit = EARTH_M / self.k * math.cos(mid * RAD)
def xy(self, point):
return ((point[0] * RAD - self.x0) * self.k, (self.y1 - _merc(point[1])) * self.k)
def _path(plane, parts, tol=TOL):
"""One relative SVG path for the parts: whole-number steps, simplified to tol units."""
out = []
for part in geo.simplify(geo.join_parts(parts), tol * plane.m_per_unit):
pts = []
for p in part:
x, y = plane.xy(p)
q = (round(x), round(y))
if not pts or q != pts[-1]:
pts.append(q)
if len(pts) < 2:
continue
steps = " ".join(f"{b[0] - a[0]} {b[1] - a[1]}" for a, b in zip(pts, pts[1:]))
out.append(f"M{pts[0][0]} {pts[0][1]}l{steps}")
return "".join(out)
def _parts(feature):
g = feature.get("geometry") or {}
if g.get("type") == "LineString":
return [g["coordinates"]]
return list(g.get("coordinates") or []) if g.get("type") == "MultiLineString" else []
def _points(feature):
g = feature.get("geometry") or {}
if g.get("type") == "Point":
return [g["coordinates"]]
return list(g.get("coordinates") or []) if g.get("type") == "MultiPoint" else []
def svg(features, fr, *, route_main=False, ident=False):
"""The sketch of these features on the frame `fr`, as Markup, or "" with nothing to draw.
route_main: a route page draws its main track in the route colour and dashed, as the map does.
ident: write each trail's id on its paths (data-id), for the filters of an overview to hide them.
"""
if not features:
return ""
plane = Plane(fr)
many = len(features) > MANY
tol = TOL_MANY if many else TOL
casings, lines, rings = [], [], []
for f in features:
props = f.get("properties") or {}
rid = f' data-id="{props["id"]}"' if ident and props.get("id") else ""
route = props.get("kind") == "route" or (route_main and (props.get("role") == "main" or props.get("sketch")))
sketch = bool(props.get("sketch"))
d = _path(plane, _parts(f), tol=tol if not sketch else 0.0)
if d:
if not sketch and not many:
casings.append(f'<path class="fallback__casing" d="{d}"{rid}/>')
mod = (" fallback__line--sketch" + (" fallback__line--sketch-route" if route else "")) if sketch \
else " fallback__line--alternate" if props.get("role") == "alternate" \
else " fallback__line--route" if route else ""
lines.append(f'<path class="fallback__line{mod}" d="{d}"{rid}/>')
for pt in _points(f):
x, y = plane.xy(pt)
cls = "fallback__ring" + (" fallback__ring--route" if props.get("kind") == "route" or route_main else "")
rings.append(f'<circle class="{cls}" cx="{x:.0f}" cy="{y:.0f}" r="4"{rid}/>')
if not lines and not rings:
return ""
return Markup(f'<svg class="map__sketch" viewBox="0 0 {plane.w:.2f} {plane.h:.2f}" '
f'preserveAspectRatio="xMidYMid meet" aria-hidden="true" focusable="false">'
f'{"".join(casings)}{"".join(lines)}{"".join(rings)}</svg>')
+1 -1
View File
@@ -128,7 +128,7 @@ def collection_page(collection, records, site):
from . import home
body = (pagekit.head(f"{name} trails compared", lede, [("Trails", "/"), ("Lists", "/lists/")])
+ '<div class="container section place">'
f'{pagekit.table(headers, rows, caption=f"The {name} trails side by side", row_heads=True)}'
f'{pagekit.table(headers, rows, caption=f"The {name} trails side by side", row_heads=True, compare=True)}'
f'{source}'
f'<div class="prose place-summary">{summary.facts(recs, records)}</div>'
f'{home.results(recs, top=2)}'
+116 -43
View File
@@ -8,7 +8,7 @@ import os
import re
import urllib.parse
from . import browse, common, elevation, facets, hike, related, seo, words
from . import browse, common, elevation, facets, hike, related, seo, sketch, words
from .layout import OUTDOOR_STYLE
from .markup import Markup, esc
@@ -242,6 +242,15 @@ def permit_sentence(rec):
return text
def built_clause(rec):
"""", with about 290 miles (467 km) built" for an unfinished trail whose holder states the built
length; else "". HTML-safe text."""
if not rec.get("built_km"):
return ""
mi = words.fmt_int(words.km_to_mi(rec["built_km"]))
return f", with {esc(mi)} miles ({esc(words.fmt_km(rec['built_km']))} km) built"
def brief_sentences(rec):
"""The "In brief" paragraph as a list of sentences in HTML, from the record's own fields only.
A fact the record lacks is left out. At most MAX_BRIEF sentences, in the order a searcher
@@ -278,7 +287,7 @@ def brief_sentences(rec):
article = "an" if mi.startswith("8") else "a" # "an 81-mile", "an 800-mile"
through = f" through {country}" if country else ""
items.append((0, 0, f"{_name_html(rec)} is {article} {esc(mi)}-mile ({esc(km)} km) {esc(noun)}"
f"{esc(tail)}{esc(through)} {esc(place_text(rec))}."))
f"{esc(tail)}{esc(through)} {esc(place_text(rec))}{built_clause(rec)}."))
unfinished = common.sentence(h.get("unfinished", ""))
if unfinished and unfinished not in hike.summary(rec): # the lede above may already say it
items.append((4, 1, esc(unfinished)))
@@ -360,9 +369,11 @@ def brief_sentences(rec):
return [text for _, _, text in kept]
def brief(rec):
"""The "In brief" paragraph for the top of a trail page: Markup."""
return Markup(f'<p class="trail-brief"><strong>In brief.</strong> {" ".join(brief_sentences(rec))}</p>')
def brief(rec, label=True):
"""The "In brief" paragraph of a trail: Markup. label: it opens with "In brief." (a trail page has
its own "In brief" heading over it and leaves the label out)."""
lead = "<strong>In brief.</strong> " if label else ""
return Markup(f'<p class="trail-brief">{lead}{" ".join(brief_sentences(rec))}</p>')
def checked_line(rec):
@@ -393,8 +404,42 @@ def page_head(rec, author_links=None):
heading = esc(common_name) if common_name else common.name(rec)
full_name = f'<p class="titleblock__sub">Full name: {common.name(rec)}</p>' if common_name else ""
plate = common.plate(rec, size="lg", link=True, eager=True) if has_plate else ""
summary = hike.summary(rec)
lede = common.rich(summary) if summary else fallback_lede(rec)
tag_html = common.badges(rec)
kicker = f'<p class="cluster">{tag_html}</p>' if tag_html else ""
lead = lead_line(rec)
define = route_definition() if route else ""
return f"""<div class="page-head page-head--trail">
<div class="container">
<nav class="breadcrumb" aria-label="Breadcrumb"><ol>{"".join(crumbs)}</ol></nav>
<header class="titleblock{" titleblock--with-plate" if has_plate else ""}">
{plate}
<div class="titleblock__text">
{kicker}
<h1>{heading}{abbr_html}</h1>
{full_name}{f'<p class="titleblock__sub">{lead_html(rec, lead, author_links)}</p>' if lead else ""}
{define}
</div>
</header>
</div>
</div>"""
# The longest first sentence of the summary that stands above the map (about two lines beside the
# At a glance panel); a longer one is left to the "In brief" section below the map.
LEAD_MAX = 180
def lead_text(rec):
"""The line above the map: the first sentence of the summary, or "" when it is longer than LEAD_MAX
(the whole summary is under the map either way). Markup."""
one = hike.one_line(rec)
if not one or len(one) > LEAD_MAX:
return ""
return Markup(f'<p class="trail-lede">{common.rich(one)}</p>')
def action_buttons(rec):
"""The buttons under the lead: the trail's own page, the GPX, Save."""
actions = []
official = official_link(rec)
if official:
@@ -409,29 +454,21 @@ def page_head(rec, author_links=None):
else:
actions.append(f'<a class="button button--quiet" href="#track">GPX: {esc(facets.GPX_STATUS[facets.gpx(rec)])}</a>')
actions.append(str(common.save_button(rec, row=False)))
tag_html = common.badges(rec)
kicker = f'<p class="cluster">{tag_html}</p>' if tag_html else ""
lead = lead_line(rec)
define = route_definition() if route else ""
return f"""<div class="page-head">
<div class="container">
<nav class="breadcrumb" aria-label="Breadcrumb"><ol>{"".join(crumbs)}</ol></nav>
<header class="titleblock{" titleblock--with-plate" if has_plate else ""}">
{plate}
<div class="titleblock__text">
{kicker}
<h1>{heading}{abbr_html}</h1>
{full_name}{f'<p class="titleblock__sub">{lead_html(rec, lead, author_links)}</p>' if lead else ""}
{define}
</div>
</header>
<p class="trail-lede">{lede}</p>
{brief(rec)}
{checked_line(rec)}
<p class="cluster trail-actions">{"".join(actions)}</p>
{links_panel(rec)}
</div>
</div>"""
return f'<p class="cluster trail-actions">{"".join(actions)}</p>'
def trail_text(rec):
"""The words under the map area: the summary in full, the "In brief" paragraph, the date of the
last check and the other pages about the trail. The text stays in the page for search engines."""
summary = hike.summary(rec)
lede = common.rich(summary) if summary else fallback_lede(rec)
return f"""<section class="trail-text" aria-labelledby="brief-title">
<h2 id="brief-title">In brief</h2>
<p class="trail-summary">{lede}</p>
{brief(rec, label=False)}
{checked_line(rec)}
</section>
{links_panel(rec)}"""
def shape_label(rec, records):
@@ -468,6 +505,13 @@ def length_note(rec, records):
return ""
def length_asides(rec, records):
"""What sits quietly under the length: the built figure of an unfinished trail, the holder's
larger figure with what it counts, then the link to the list the length puts the trail in."""
lines = [common.built_text(rec), common.system_text(rec), length_note(rec, records) or ""]
return Markup("<br>".join(str(line) for line in lines if line))
def time_note(rec, records):
"""The estimate's note, then a link to the list of trails that take as long."""
note = facets.estimate_note(rec)
@@ -485,7 +529,7 @@ def glance(rec, records=None):
lists they put the trail in (left out when None)."""
h = hike.table(rec)
rows = [glance_row(facets.LENGTH, words.length(rec["length_km"], "stack", rec["derived"]["length_mi"]),
length_note(rec, records))]
length_asides(rec, records))]
rows.append(glance_row(facets.TIME, facets.time_text(rec), time_note(rec, records)))
season = facets.season_text(rec)
if season:
@@ -565,15 +609,27 @@ def glance(rec, records=None):
pending = f'<p class="note">{esc(names)} {verb} not on file for this trail yet.</p>'
elev_caveat = elevation.coverage_caveat(elev) if elev else ""
elev_note = f'<p class="note">{esc(elev_caveat)}</p>' if elev_caveat else ""
# On a narrow screen only the first facts show (length and time first) and a button opens the
# rest (style.css, app.js); with no JavaScript every fact shows.
return f"""<section class="glance detail__glance" aria-labelledby="glance-title">
<h2 class="glance__title" id="glance-title">At a glance</h2>
<dl class="glance__facts">{"".join(rows)}</dl>
{unfinished}{caution}{elev_note}{pending}
<button class="glance__toggle js-only" type="button" aria-expanded="false" data-glance-toggle>All the facts</button>
</section>"""
# Map or empty frame ---------------------------------------------------------
def sketch_of(box, features, route_main=False):
"""(data-frame attribute, the static sketch) of a map frame for the extent `box`: the ground the
live map opens on, and the drawing of the track on it (olt/sketch.py). Both are "" without a box."""
if not box:
return "", ""
fr = sketch.frame(box)
return f' data-frame="{",".join(f"{v:g}" for v in fr)}"', sketch.svg(features, fr, route_main=route_main)
def map_figure(rec):
src = rec["source"]
has_alt = "alternates" in rec["derived"]["files"]
@@ -583,12 +639,13 @@ def map_figure(rec):
legend += f"<li>{common.SWATCH_ALT}Alternates and connectors</li>"
bbox = rec["derived"].get("map_bbox") or rec["derived"].get("bbox")
bbox_attr = f' data-bbox="{",".join(str(v) for v in bbox)}"' if bbox else ""
frame_attr, drawing = sketch_of(bbox, sketch.trail_features(rec["id"]), route_main=route)
credit = common.sentence(common.credit_text(src.get("attribution", "")))
return f"""<figure class="mapfig mapfig--detail detail__map" data-map="trail" data-src="/trails/{esc(rec["id"])}/map.json" data-route="{"yes" if route else "no"}"{bbox_attr} data-outdoor="{OUTDOOR_STYLE}">
return f"""<figure class="mapfig mapfig--detail detail__map" data-map="trail" data-src="/trails/{esc(rec["id"])}/map.json" data-route="{"yes" if route else "no"}"{bbox_attr}{frame_attr} data-outdoor="{OUTDOOR_STYLE}">
<div class="mapfig__frame">
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true"></span>
<div class="map" role="region" aria-label="Map of the {esc(rec["name"])}">
<div class="map__fallback"></div>
<div class="map__fallback">{drawing}</div>
<div class="map__canvas"></div>
<p class="map__status" role="status">The map needs JavaScript. Download the GPX or GeoJSON file from this page.</p>
</div>
@@ -753,11 +810,12 @@ def sketch_figure(rec):
legend_text = "No GPX here: start only"
_title, status, reason, rule, actions_html = _no_gpx_parts(rec)
reason_html = reason if isinstance(reason, Markup) else common.rich(reason)
return f"""<figure class="mapfig mapfig--detail detail__map" id="track" data-map="sketch" data-src="/trails/{esc(rec["id"])}/sketch.json" data-route="{"yes" if route else "no"}"{bbox_attr} data-outdoor="{OUTDOOR_STYLE}">
frame_attr, drawing = sketch_of(box, sketch.trail_features(rec["id"]), route_main=route)
return f"""<figure class="mapfig mapfig--detail detail__map" id="track" data-map="sketch" data-src="/trails/{esc(rec["id"])}/sketch.json" data-route="{"yes" if route else "no"}"{bbox_attr}{frame_attr} data-outdoor="{OUTDOOR_STYLE}">
<div class="mapfig__frame">
<span class="mapfig__corner mapfig__corner--nw" aria-hidden="true"></span>
<div class="map" role="region" aria-label="Map showing the start and end of the {esc(rec["name"])}; no GPX here">
<div class="map__fallback"></div>
<div class="map__fallback">{drawing}</div>
<div class="map__canvas"></div>
<p class="map__status" role="status">The map needs JavaScript. The ends of the trail are named below it.</p>
</div>
@@ -1072,8 +1130,15 @@ def record_block(rec):
rows.append(fact("Inclusion", words.label(words.INCLUSION, inc), words.meaning(words.INCLUSION, inc)))
rows += [
Markup(f'<div><dt>Where</dt><dd>{where}</dd></div>'),
Markup(f'<div><dt>Published length</dt><dd>{words.length(rec["length_km"], "inline", rec["derived"]["length_mi"])}'
f'<small>{esc(rec.get("length_note", ""))}. A check value, not measured from the track.</small></dd></div>'),
Markup(f'<div><dt>Length</dt><dd>{words.length(rec["length_km"], "inline", rec["derived"]["length_mi"])}'
f'<small>{esc(common.sentence(rec.get("length_note", "")))} The end-to-end length of the trail&rsquo;s '
f'canonical path, a check value, not measured from the track.</small></dd></div>'),
fact("Built length", common.built_text(rec), "How much of the trail is built, as the holder states it.")
if rec.get("built_km") else "",
fact("Whole system", Markup(f'{words.length(rec["system_km"], "inline")}, counting '
f'{esc(str(rec["system_note"]).strip().rstrip("."))}'),
"The holder's larger figure, kept apart from the length.")
if rec.get("system_km") else "",
abbreviation_fact(rec),
fact("Record ID", Markup(code(rec["id"])), "Stable: the directory name, never changed"),
]
@@ -1539,7 +1604,10 @@ def description(rec):
then the first sentence of the summary (or the designation where there is none)."""
mi = words.fmt_int(rec["derived"]["length_mi"])
km = words.fmt_km(rec["length_km"])
text = f"A {kind_word(rec)} of {mi} miles ({km} km) {places_short(rec)}"
built = ""
if rec.get("built_km"):
built = f", {words.fmt_int(words.km_to_mi(rec['built_km']))} miles built,"
text = f"A {kind_word(rec)} of {mi} miles ({km} km){built} {places_short(rec)}"
days = hike.days(rec)
if days:
text += f", usually {days}"
@@ -1621,20 +1689,25 @@ def render(rec, site, records=None, author_links=None):
"""Return (title, description, body HTML, needs_map) for one trail.
records: every trail, for the ways onward at the foot (left out when None)."""
has_track = common.has_line(rec)
sketch = hike.sketch_points(rec) if not has_track else []
has_map = has_track or bool(sketch)
sketch_points = hike.sketch_points(rec) if not has_track else []
has_map = has_track or bool(sketch_points)
aside = downloads_panel(rec) + guides_panel(rec)
aside_html = (f'<aside class="detail__aside" aria-label="{"Downloads" if has_track else "Where to get the route"}">'
f'{aside}</aside>') if aside else ""
profile = elevation_figure(rec)
side = f'<div class="detail__side">{glance(rec, records)}{aside_html}</div>'
body = f"""{page_head(rec, author_links)}
<div class="container detail{"" if aside else " detail--no-aside"}{"" if has_map else " detail--no-map"}{" detail--with-profile" if profile else ""}">
{glance(rec, records)}
{map_figure(rec) if has_track else sketch_figure(rec) if sketch else empty_frame(rec)}
<div class="detail__lead">
{lead_text(rec)}
{action_buttons(rec)}
</div>
{side}
{map_figure(rec) if has_track else sketch_figure(rec) if sketch_points else empty_frame(rec)}
{profile}
{aside_html}
</div>
<div class="container trail-more">
{trail_text(rec)}
{onward(rec, records)}
{page_foot(rec, site)}
{about_data(rec, site)}
+1 -1
View File
@@ -43,7 +43,7 @@ WAVES = {
"held": ("Held", "Listed, but something about it is not settled"),
}
INCLUSION = {
"nst-unconditional": ("Listed unconditionally", "Every National Scenic Trail is listed"),
"nst-unconditional": ("Listed as a National Scenic Trail", "A National Scenic Trail is listed unless it cannot be walked from one end to the other"),
"candidate-decision-pending": ("Candidate", "The decision to list it is pending"),
}
KINDS = {