diff --git a/cfgov/v1/jinja2/v1/layouts/base.html b/cfgov/v1/jinja2/v1/layouts/base.html index 2d278890ef7..a7ce70c63cf 100644 --- a/cfgov/v1/jinja2/v1/layouts/base.html +++ b/cfgov/v1/jinja2/v1/layouts/base.html @@ -60,7 +60,8 @@ {%- endblock -%} "> - + {# Base32 encoding used to avoid an issue with Search.gov custom fields losing capitalization. -#} + {# Always open preview panel links in a new tab. #} {% if request.in_preview_panel %} diff --git a/cfgov/v1/jinja2tags/__init__.py b/cfgov/v1/jinja2tags/__init__.py index 424461aa60c..084cf0580b9 100644 --- a/cfgov/v1/jinja2tags/__init__.py +++ b/cfgov/v1/jinja2tags/__init__.py @@ -1,3 +1,5 @@ +from base64 import b32encode + from jinja2 import pass_context from jinja2.ext import Extension @@ -51,6 +53,10 @@ def unique_id_in_context(context): return get_unique_id() +def encode_b32_string(s): + return b32encode(s.encode("utf-8")).decode("utf-8") + + class V1Extension(Extension): def __init__(self, environment): super().__init__(environment) @@ -63,6 +69,7 @@ def __init__(self, environment): "get_unique_id": get_unique_id, "is_filter_selected": pass_context(is_filter_selected), "unique_id_in_context": pass_context(unique_id_in_context), + "encode_b32_string": encode_b32_string, "app_url": app_url, "app_page_url": app_page_url, } diff --git a/cfgov/v1/sitemap.py b/cfgov/v1/sitemap.py index abf171fc331..5a94447b4ba 100644 --- a/cfgov/v1/sitemap.py +++ b/cfgov/v1/sitemap.py @@ -11,7 +11,7 @@ class Sitemap(WagtailSitemap): # Used to set a minimum modified date for all pages in the sitemap. # This can be updated to trigger sitemap updates that are not reflected # in Wagtail page publish events. - MIN_SITEMAP_DATE = datetime(2025, 6, 4, tzinfo=timezone.utc) + MIN_SITEMAP_DATE = datetime(2025, 7, 9, tzinfo=timezone.utc) latest_lastmod = MIN_SITEMAP_DATE def get_urls(self, page=1, site=None, protocol=None): diff --git a/cfgov/v1/tests/jinja2tags/test_jinja2tags.py b/cfgov/v1/tests/jinja2tags/test_jinja2tags.py index 340966f3494..2b5f85c5342 100644 --- a/cfgov/v1/tests/jinja2tags/test_jinja2tags.py +++ b/cfgov/v1/tests/jinja2tags/test_jinja2tags.py @@ -98,3 +98,16 @@ def test_nonexistent_category_name_returns_none(self): self.checkRender( "{{ get_category_icon('Invalid category name') }}", "None" ) + + +class TestEncodeB32String(SimpleTestCase): + def setUp(self): + self.jinja_engine = engines["wagtail-env"] + + def test_encode_b32_string(self): + s = ( + "{%- block desc -%}cfpb{%- endblock -%}" + "{{encode_b32_string(self.desc())}}" + ) + template = self.jinja_engine.from_string(s) + self.assertEqual(template.render(), "cfpbMNTHAYQ=") diff --git a/cfgov/v1/tests/test_sitemap.py b/cfgov/v1/tests/test_sitemap.py index b6d8d174b3f..7bd2b0591fd 100644 --- a/cfgov/v1/tests/test_sitemap.py +++ b/cfgov/v1/tests/test_sitemap.py @@ -29,13 +29,13 @@ def test_sitemap(self): ( b'\n' b'\n' - b"http://localhost/2025-06-03" - b"http://localhost/old/2025-06-03\n" + b"http://localhost/2025-07-08" + b"http://localhost/old/2025-07-08\n" b"\n" ), ) # The Last-Modified header should also be set appropriately. self.assertEqual( - response["Last-Modified"], "Wed, 04 Jun 2025 00:00:00 GMT" + response["Last-Modified"], "Wed, 09 Jul 2025 00:00:00 GMT" )