Give every page of trails one layout, with the map beside the rows, and set no tables
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

Every page that shows a set of trails (home, places, lists, Routes,
authors, Triple Crown, rankings, newest) has the same layout: the
trails as rows with their map beside them from 900 px wide up, and a
short map band above the rows when narrower. The home page gets its
headline back on the contour ground, with the ten lists as one line of
links. A trail page has its actions in its head and the map in a fixed
frame beside At a glance. No page sets a table: every set of trails is
the standard trail row, and other sets are rows in the same language.

Route authors' names link to their pages from route rows and trail
pages, the Routes page says how many routes by how many authors, and
the Lists index has a Route authors entry.

No trail's facts changed.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-17 06:40:16 -07:00
1 parent 59f912c47c
commit 298f1b9fd9
28 files changed
+843 -541

No files matched your search

+74 -27
View File
@@ -1,4 +1,6 @@
"""Small pieces the new view pages share: a page heading with a breadcrumb, a table, a ranked row."""
"""Small pieces the view pages share: a page heading with a breadcrumb, and rows of things that are not trails."""
import re
from . import words
from .markup import Markup, esc
@@ -16,36 +18,81 @@ def head(h1, lede_html, crumbs, *, kicker=""):
</div></div>"""
# A table with at least this many columns is set as one block per row on a phone (style.css).
STACK_COLUMNS = 4
# The site sets no tables. A set of things (files, terms, changes, places) is shown as rows in the
# language of a trail's row: a name, a sentence where there is one, and a line of short facts.
# A cell longer than this (in characters of text) is a sentence of the row, not a fact in its line.
LONG_CELL = 60
def _text_len(html):
return len(re.sub(r"<[^>]+>", "", str(html)).strip())
def plain_entry(name_html, *, text=(), facts=(), small=(), tag="", level=3, heading=True):
"""One row of something that is not a trail: name_html as a row's name, `tag` (HTML) above it as a
route tag is, `text` (HTML paragraphs) as a row's sentence, `facts` (HTML) on a line as a row's
facts are, `small` (HTML) as small print."""
kicker = f'<p class="entry__kicker">{tag}</p>' if tag else ""
h = f"h{level}" if heading else "p"
paras = "".join(f'<p class="entry__desc">{t}</p>' for t in text if str(t).strip())
line = "".join(f'<span>{f}</span>' for f in facts if str(f).strip())
line = f'<p class="entry__meta">{line}</p>' if line else ""
fine = " · ".join(str(x) for x in small if str(x).strip())
fine = f'<p class="entry__small">{fine}</p>' if fine else ""
return (f'<li class="entry entry--plain"><div class="entry__body">{kicker}'
f'<{h} class="entry__name">{name_html}</{h}>{paras}{line}{fine}</div></li>')
def plain_list(items_html, label=""):
aria = f' aria-label="{esc(label)}"' if label else ""
return Markup(f'<ol class="entries entries--plain"{aria}>{"".join(items_html)}</ol>')
def rows_list(headers, rows, caption=""):
"""A set of things as rows: the first cell of each is its name; a long cell is its sentence; the
short ones are its line of facts, each with its column's title."""
items = []
for row in rows:
cells = [v if isinstance(v, Markup) else esc(v) for v in row]
text, facts = [], []
for label, cell in zip(headers[1:], cells[1:]):
if not _text_len(cell):
continue
if _text_len(cell) > LONG_CELL:
text.append(cell)
else:
facts.append(f'<span class="entry__label">{esc(label)}</span> {cell}')
items.append(plain_entry(cells[0], text=text, facts=facts, heading=False))
return plain_list(items, caption)
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.
"""A set of things, shown as rows (rows_list): headers are the titles of the cells, rows lists of
HTML cells (Markup, or text that is escaped). The other arguments are kept for the callers."""
return rows_list(headers, rows, caption)
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} 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, row[0] if compare else headers[i], head=row_heads and i == 0)
for i, v in enumerate(row)) + "</tr>"
for row in rows)
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>')
_TABLE = re.compile(r'(?:<div class="table-wrap">\s*)?<table\b[^>]*>(.*?)</table>(?:\s*</div>)?', re.S)
_ROW = re.compile(r"<tr\b[^>]*>(.*?)</tr>", re.S)
_CELL = re.compile(r"<(th|td)\b[^>]*>(.*?)</\1>", re.S)
_CAPTION = re.compile(r"<caption\b[^>]*>(.*?)</caption>", re.S)
def untable(html):
"""html with every table in it set as rows (rows_list). For the pages written from Markdown and by
hand, whose tables are plain: one head row, then body rows."""
def one(m):
inner = m.group(1)
cap = _CAPTION.search(inner)
rows = [[c[1].strip() for c in _CELL.findall(r)] for r in _ROW.findall(inner)]
rows = [r for r in rows if r]
if not rows:
return ""
head, body = rows[0], rows[1:]
caption = re.sub(r"<[^>]+>", "", cap.group(1)) if cap else ""
return str(rows_list(head, [[Markup(c) for c in r] for r in body], caption))
return _TABLE.sub(one, str(html))
def trail_link(rec):