From 249d866efeca660687d396cb24d82ac2d68034a5 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Fri, 13 Nov 2026 14:46:35 -0700 Subject: [PATCH] Do not say a logo was taken from a page when none is included Fifteen records name where a trail's logo is held but include no logo file. Their pages listed that link as "The page the logo was taken from", with no logo anywhere on the page. The link now reads "The logo holder's site; the logo is not included here", and the Logo section says the trail has a logo, who holds it, and that no copy is in the dataset. Co-Authored-By: Claude Fable 5.2 --- web/olt/trail.py | 13 +++++++++++-- web/tests/test_pages.py | 11 +++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/web/olt/trail.py b/web/olt/trail.py index c9782ab..eb0ade8 100644 --- a/web/olt/trail.py +++ b/web/olt/trail.py @@ -411,7 +411,10 @@ def links_panel(rec): add(words_url, by or host(words_url), "Where the quoted words were read") if _is_url(sh.get("logo_source")): owner = sh.get("logo_owner") or sh.get("contact") or host(sh["logo_source"]) - add(sh["logo_source"], owner, "The page the logo was taken from") + # Only a record with a logo file took its logo from that page; without + # one the page is merely where the holder shows it. + add(sh["logo_source"], owner, "The page the logo was taken from" if common.shield_url(rec) + else "The logo holder's site; the logo is not included here") add(f"/trails/{rec['id']}/trail.toml", "trail.toml", "The record itself, as data") if rec["derived"].get("release"): add(f"/trails/{rec['id']}/release.txt", "release.txt", "Source, licence and date of the track files") @@ -623,8 +626,14 @@ def logo_block(rec): lead = {"no-logo-exists": "No logo", "logo-not-found": "Logo not found", "use-real-logo": "Logo not included"}.get(status, "No logo file") note = sh.get("note", "") + # "use-real-logo" without a file: the trail has a logo, but no copy is here. + why = "" + if status == "use-real-logo": + holder = sh.get("logo_owner") or sh.get("contact") or "" + why = (f" The trail has a logo{', held by ' + str(esc(holder)) if holder else ''}, " + "but no copy of it is in this dataset.") return block("logo-title", "Logo", Markup( - f'

{esc(lead)}.{" " + common.rich(note) if note else ""}

')) + f'

{esc(lead)}.{why}{" " + common.rich(note) if note else ""}

')) rows = [ fact("Status", words.label(words.SHIELD_STATUS, status), words.meaning(words.SHIELD_STATUS, status)), fact("Holder", sh.get("logo_owner", "")) if sh.get("logo_owner") else "", diff --git a/web/tests/test_pages.py b/web/tests/test_pages.py index 8d17a85..88d48cc 100644 --- a/web/tests/test_pages.py +++ b/web/tests/test_pages.py @@ -424,6 +424,17 @@ class RenderUnitTest(unittest.TestCase): self.assertIn("History", plain) self.assertIn("https://github.com/swaits/longhikes/commits/main/x", plain) + def test_logo_source_without_a_logo_file_is_not_called_taken_from(self): + # A record can name where its logo is held without including the logo. + rec = sample_record("X Trail") + rec["shield"] = {"status": "use-real-logo", "logo_source": "https://holder.example/", "contact": "Holder", + "note": "No policy found.", "logo_file": "", "logo_owner": "Holder & Co"} + _, _, body, _ = trail.render(rec, site.Site("N", "T")) + self.assertIn('href="https://holder.example/"', body) + self.assertNotIn("logo was taken from", body) + self.assertIn("the logo is not included here", body) + self.assertIn("The trail has a logo, held by Holder & Co, but no copy of it is in this dataset.", body) + 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))