Add 130 views of the same records, speed up map pages, and say who maintains the site
- New pages built from the records: lists by length, time to walk, month, kind of walking and holder; place-by-list pages; a Triple Crown table and key-figure tables for the National Scenic and Recreation Trails; highest points, most climbing and climb per mile; a page for every route author, with the authors of three or more routes leading the authors page; connected trails; recently added and changed; a glossary and a method page. Every place page opens with a summary. - Trail pages open with an "In brief" paragraph generated from the record and show when the record was last checked. The About page says who maintains the site and how to reach them. - The map starts when it is reached, not with the page. The site's own CSS, scripts and fonts are fingerprinted and cached for a year. Every image has its dimensions. - Titles are held to 60 characters and share previews get their own shorter description. - Social cards are redrawn so a long name can no longer push text into the footer, and the site-wide card takes its wording from the site settings instead of an old hand-made image. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
5b80fccd1e
commit
f2d3b71810
266 files changed
+4658
-252
No files matched your search
+21
-10
@@ -1,9 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Make the small PNG logo thumbnails the site shows in lists.
|
||||
|
||||
For every <id>/shield.png in the repository root, writes web/thumbs/<id>.png,
|
||||
scaled to fit within 256 x 256 px (never enlarged), metadata stripped and
|
||||
transparency kept. Needs ImageMagick 7 (`magick`) on the PATH; runs optipng
|
||||
For every <id>/shield.png (or, where there is no PNG, <id>/shield.svg) in the
|
||||
repository root, writes web/thumbs/<id>.png, scaled to fit within 256 x 256 px
|
||||
(a PNG is never enlarged; an SVG is drawn at that size, so a thumbnail is never
|
||||
blurred), metadata stripped and transparency kept. A vector logo can weigh
|
||||
hundreds of kilobytes (the Bartram Trail's is 345 KB); its thumbnail a few tens. Needs ImageMagick 7 (`magick`) on the PATH; runs optipng
|
||||
too when it is installed. Run on a developer machine and commit the output:
|
||||
the site build itself is standard library only and does not run this.
|
||||
|
||||
@@ -25,19 +27,28 @@ MAX_SIDE = 256
|
||||
|
||||
|
||||
def sources():
|
||||
"""{id: path} for each <id>/shield.png directly under the repository root."""
|
||||
"""{id: path} for each <id>/shield.png, or <id>/shield.svg when there is no PNG,
|
||||
directly under the repository root."""
|
||||
found = {}
|
||||
for name in sorted(os.listdir(ROOT)):
|
||||
path = os.path.join(ROOT, name, "shield.png")
|
||||
if not name.startswith((".", "_")) and os.path.isfile(path):
|
||||
found[name] = path
|
||||
if name.startswith((".", "_")):
|
||||
continue
|
||||
for ext in ("png", "svg"):
|
||||
path = os.path.join(ROOT, name, f"shield.{ext}")
|
||||
if os.path.isfile(path):
|
||||
found[name] = path
|
||||
break
|
||||
return found
|
||||
|
||||
|
||||
def make_thumb(src, dst):
|
||||
"""Write one thumbnail with ImageMagick, then optimise it when optipng is present."""
|
||||
cmd = ["magick", src, "-strip", "-resize", f"{MAX_SIDE}x{MAX_SIDE}>",
|
||||
"PNG32:" + dst]
|
||||
if src.endswith(".svg"):
|
||||
# Drawn at 384 dpi (so the drawing is larger than the thumbnail), then fitted.
|
||||
cmd = ["magick", "-background", "none", "-density", "384", src, "-strip",
|
||||
"-resize", f"{MAX_SIDE}x{MAX_SIDE}>", "PNG32:" + dst]
|
||||
else:
|
||||
cmd = ["magick", src, "-strip", "-resize", f"{MAX_SIDE}x{MAX_SIDE}>", "PNG32:" + dst]
|
||||
try:
|
||||
subprocess.run(cmd, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
except subprocess.CalledProcessError as e:
|
||||
@@ -50,7 +61,7 @@ def make_thumb(src, dst):
|
||||
|
||||
|
||||
def main(argv=None):
|
||||
ap = argparse.ArgumentParser(description="Make web/thumbs/<id>.png from each <id>/shield.png.")
|
||||
ap = argparse.ArgumentParser(description="Make web/thumbs/<id>.png from each <id>/shield.png (or .svg).")
|
||||
ap.add_argument("--force", action="store_true", help="rebuild thumbnails that are up to date")
|
||||
args = ap.parse_args(argv)
|
||||
|
||||
|
||||
Reference in new issue
Block a user