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 <noreply@anthropic.com>
This commit is contained in:
1 parent
48e1cc39fb
commit
249d866efe
2 files changed
+22
-2
No files matched your search
+11
-2
@@ -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'<p class="record-text"><strong>{esc(lead)}.</strong>{" " + common.rich(note) if note else ""}</p>'))
|
||||
f'<p class="record-text"><strong>{esc(lead)}.</strong>{why}{" " + common.rich(note) if note else ""}</p>'))
|
||||
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 "",
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in new issue
Block a user