Point a trail page's correction link at the correction form, not the raw file editor
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
dea144fd11
commit
5f35a5b043
2 files changed
+11
-7
No files matched your search
+3
-3
@@ -1531,12 +1531,12 @@ def correction_block(rec, site):
|
|||||||
</div>""")
|
</div>""")
|
||||||
if site.is_github:
|
if site.is_github:
|
||||||
report = esc(site.correction_url(rec["id"], rec.get("name", "")))
|
report = esc(site.correction_url(rec["id"], rec.get("name", "")))
|
||||||
edit = esc(site.edit_url(rec["id"]))
|
record = esc(site.blob_url(f"{rec['id']}/trail.toml"))
|
||||||
history = esc(site.history_url(rec["id"]))
|
history = esc(site.history_url(rec["id"]))
|
||||||
parts.append(f"""<p class="prose">This record is a text file anyone can correct. Please say where a correction can be checked: a source page, a map, or a measured track.</p>
|
parts.append(f"""<p class="prose">This record is a text file anyone can correct. Please say where a correction can be checked: a source page, a map, or a measured track.</p>
|
||||||
<ul class="linklist">
|
<ul class="linklist">
|
||||||
<li><a href="{report}">Report a problem</a><small>No git needed: a short form, with this record ({code(rec["id"])}) filled in</small></li>
|
<li><a href="{report}">Report a correction</a><small>No git needed: a short form, with this record ({code(rec["id"])}) filled in</small></li>
|
||||||
<li><a href="{edit}">Edit this record</a><small>The record file (trail.toml) on GitHub</small></li>
|
<li><a href="{record}">The record file</a><small>trail.toml on GitHub, to read it as it is written</small></li>
|
||||||
<li><a href="{history}">History</a><small>Changes to this record on GitHub</small></li>
|
<li><a href="{history}">History</a><small>Changes to this record on GitHub</small></li>
|
||||||
</ul>""")
|
</ul>""")
|
||||||
elif site.repo_url:
|
elif site.repo_url:
|
||||||
|
|||||||
@@ -500,11 +500,14 @@ class RenderUnitTest(unittest.TestCase):
|
|||||||
gh = site.Site("N", "T", repo_url="https://github.com/swaits/longhikes")
|
gh = site.Site("N", "T", repo_url="https://github.com/swaits/longhikes")
|
||||||
_, _, body, _ = trail.render(sample_record("A & B Trail"), gh)
|
_, _, body, _ = trail.render(sample_record("A & B Trail"), gh)
|
||||||
plain = html.unescape(body)
|
plain = html.unescape(body)
|
||||||
self.assertIn("Report a problem", plain)
|
self.assertIn("Report a correction", plain)
|
||||||
self.assertIn("https://github.com/swaits/longhikes/issues/new?"
|
self.assertIn("https://github.com/swaits/longhikes/issues/new?"
|
||||||
"template=correction.yml&title=Correction%3A+A+%26+B+Trail+%28x%29&trail=x", plain)
|
"template=correction.yml&title=Correction%3A+A+%26+B+Trail+%28x%29&trail=x", plain)
|
||||||
self.assertIn("Edit this record", plain)
|
# the raw editor, which a web contributor cannot finish a change in, is no longer offered
|
||||||
self.assertIn("https://github.com/swaits/longhikes/edit/main/x/trail.toml", plain)
|
self.assertNotIn("Edit this record", plain)
|
||||||
|
self.assertNotIn("/edit/", plain)
|
||||||
|
self.assertIn("The record file", plain)
|
||||||
|
self.assertIn("https://github.com/swaits/longhikes/blob/main/x/trail.toml", plain)
|
||||||
self.assertIn("History", plain)
|
self.assertIn("History", plain)
|
||||||
self.assertIn("https://github.com/swaits/longhikes/commits/main/x", plain)
|
self.assertIn("https://github.com/swaits/longhikes/commits/main/x", plain)
|
||||||
|
|
||||||
@@ -523,7 +526,7 @@ class RenderUnitTest(unittest.TestCase):
|
|||||||
def test_trail_correction_links_github_branch(self):
|
def test_trail_correction_links_github_branch(self):
|
||||||
gh = site.Site("N", "T", repo_url="https://github.com/o/r/", repo_branch="dev")
|
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))
|
block = html.unescape(trail.correction_block(sample_record("X Trail"), gh))
|
||||||
self.assertIn("https://github.com/o/r/edit/dev/x/trail.toml", block)
|
self.assertIn("https://github.com/o/r/blob/dev/x/trail.toml", block)
|
||||||
self.assertIn("https://github.com/o/r/commits/dev/x", block)
|
self.assertIn("https://github.com/o/r/commits/dev/x", block)
|
||||||
|
|
||||||
def test_trail_correction_links_non_github_fall_back_to_repo(self):
|
def test_trail_correction_links_non_github_fall_back_to_repo(self):
|
||||||
@@ -532,6 +535,7 @@ class RenderUnitTest(unittest.TestCase):
|
|||||||
self.assertIn('href="https://example.org/repo"', block)
|
self.assertIn('href="https://example.org/repo"', block)
|
||||||
self.assertNotIn("template=correction.yml", block)
|
self.assertNotIn("template=correction.yml", block)
|
||||||
self.assertNotIn("/edit/", block)
|
self.assertNotIn("/edit/", block)
|
||||||
|
self.assertNotIn("/blob/", block)
|
||||||
self.assertNotIn("/commits/", block)
|
self.assertNotIn("/commits/", block)
|
||||||
self.assertNotIn("Edit this record", block)
|
self.assertNotIn("Edit this record", block)
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user