Add Parks, Mountain ranges and Wilderness areas to the Places page's shortcut strip
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d90fa49df5
commit
3182d68935
2 files changed
+16
-1
No files matched your search
+2
-1
@@ -200,6 +200,7 @@ def regions_index_page(records, site, infos=()):
|
|||||||
f'<li><a href="{esc(i["path"])}">{esc(i["name"])}</a>'
|
f'<li><a href="{esc(i["path"])}">{esc(i["name"])}</a>'
|
||||||
f'<span class="places__n">{_plural(len(i["records"]))}</span></li>'
|
f'<span class="places__n">{_plural(len(i["records"]))}</span></li>'
|
||||||
for i in mine)
|
for i in mine)
|
||||||
|
jump.append(f'<li><a href="#{esc(kind.segment)}">{esc(kind.hub_title)}<span class="lists-row__n">{len(mine)}</span></a></li>')
|
||||||
blocks += f"""<section class="places__group" aria-labelledby="{esc(kind.segment)}">
|
blocks += f"""<section class="places__group" aria-labelledby="{esc(kind.segment)}">
|
||||||
<h2 id="{esc(kind.segment)}">{esc(kind.hub_title)}</h2>
|
<h2 id="{esc(kind.segment)}">{esc(kind.hub_title)}</h2>
|
||||||
<ul class="places__list">{rows}</ul>
|
<ul class="places__list">{rows}</ul>
|
||||||
@@ -218,7 +219,7 @@ def regions_index_page(records, site, infos=()):
|
|||||||
<p class="page-head__lede">The {len(records)} trails by state and province, grouped into parts of the
|
<p class="page-head__lede">The {len(records)} trails by state and province, grouped into parts of the
|
||||||
United States ({n_us}) and Canada ({n_ca}). A trail that crosses several states is on each one’s page.{lede_more}</p>
|
United States ({n_us}) and Canada ({n_ca}). A trail that crosses several states is on each one’s page.{lede_more}</p>
|
||||||
</div></header>
|
</div></header>
|
||||||
<nav class="lists-row" aria-label="Jump to a part of the country"><ul>{"".join(jump)}</ul></nav></div></div>
|
<nav class="lists-row" aria-label="Jump to a part of the country or a kind of place"><ul>{"".join(jump)}</ul></nav></div></div>
|
||||||
<div class="container section places">{blocks}</div>{foot}"""
|
<div class="container section places">{blocks}</div>{foot}"""
|
||||||
description = (f"Where the {len(records)} long trails and routes are: {n_us} in the United States and {n_ca} in Canada, "
|
description = (f"Where the {len(records)} long trails and routes are: {n_us} in the United States and {n_ca} in Canada, "
|
||||||
f"by state and province, with the number in each.")
|
f"by state and province, with the number in each.")
|
||||||
|
|||||||
@@ -48,11 +48,25 @@ class HubTest(unittest.TestCase):
|
|||||||
self.assertIn("Parks, mountain ranges and wilderness areas with three or more "
|
self.assertIn("Parks, mountain ranges and wilderness areas with three or more "
|
||||||
"trails have pages too.", re.sub(r"\s+", " ", body))
|
"trails have pages too.", re.sub(r"\s+", " ", body))
|
||||||
|
|
||||||
|
def test_the_shortcut_strip_links_each_kind_that_has_pages(self):
|
||||||
|
_, _, body = regions.regions_index_page(self.records, S, infos=self.infos)
|
||||||
|
strip = str(body)[str(body).index('<nav class="lists-row"'):]
|
||||||
|
strip = strip[:strip.index("</nav>")]
|
||||||
|
self.assertIn('<a href="#parks">Parks<span class="lists-row__n">1</span></a>', strip)
|
||||||
|
self.assertIn('<a href="#ranges">Mountain ranges<span class="lists-row__n">1</span></a>', strip)
|
||||||
|
self.assertNotIn("#wilderness", strip) # no wilderness page here: no shortcut
|
||||||
|
# the regional groups are still there, before the kinds
|
||||||
|
self.assertLess(strip.index('href="#west-coast"') if 'href="#west-coast"' in strip
|
||||||
|
else strip.index("<li>"), strip.index('href="#parks"'))
|
||||||
|
_, _, plain = regions.regions_index_page(self.records, S)
|
||||||
|
self.assertNotIn('href="#parks"', str(plain))
|
||||||
|
|
||||||
def test_the_hub_still_lists_every_state_group_as_before(self):
|
def test_the_hub_still_lists_every_state_group_as_before(self):
|
||||||
_, _, plain = regions.regions_index_page(self.records, S)
|
_, _, plain = regions.regions_index_page(self.records, S)
|
||||||
_, _, with_places = regions.regions_index_page(self.records, S, infos=self.infos)
|
_, _, with_places = regions.regions_index_page(self.records, S, infos=self.infos)
|
||||||
stripped = re.sub(r'<section class="places__group" aria-labelledby="(?:parks|ranges|wilderness)">.*?</section>',
|
stripped = re.sub(r'<section class="places__group" aria-labelledby="(?:parks|ranges|wilderness)">.*?</section>',
|
||||||
"", str(with_places), flags=re.S)
|
"", str(with_places), flags=re.S)
|
||||||
|
stripped = re.sub(r'<li><a href="#(?:parks|ranges|wilderness)">.*?</li>', "", stripped)
|
||||||
stripped = stripped.replace(
|
stripped = stripped.replace(
|
||||||
" Parks, mountain ranges and wilderness areas with three or more trails have pages too.", "")
|
" Parks, mountain ranges and wilderness areas with three or more trails have pages too.", "")
|
||||||
self.assertEqual(stripped, str(plain))
|
self.assertEqual(stripped, str(plain))
|
||||||
|
|||||||
Reference in new issue
Block a user