Rename namespace for static pygments URL
This commit is contained in:
parent
78660500a5
commit
1326214c8f
4 changed files with 12 additions and 12 deletions
|
@ -17,7 +17,7 @@
|
|||
{% block extra_css %}
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'css/lite-youtube-embed.css' %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static 'contrib/shareon/shareon.min.css' %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% url 'static-pygments:styles' 'default' %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% url 'code-block:styles' 'default' %}">
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
|
|
|
@ -9,21 +9,17 @@ class PygmentsStylesTestCase(TestCase):
|
|||
def test_accessible(self) -> None:
|
||||
for style in get_all_styles():
|
||||
with self.subTest(style=style):
|
||||
response = self.client.get(
|
||||
reverse("static-pygments:styles", args=[style])
|
||||
)
|
||||
response = self.client.get(reverse("code-block:styles", args=[style]))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertEqual(response["Cache-Control"], "max-age=3600, public")
|
||||
self.assertEqual(response["ETag"], f'"{PYGMENTS_VERSION}"')
|
||||
|
||||
def test_unknown_style(self) -> None:
|
||||
response = self.client.get(
|
||||
reverse("static-pygments:styles", args=["not-a-style"])
|
||||
)
|
||||
response = self.client.get(reverse("code-block:styles", args=["not-a-style"]))
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_url_contains_version(self) -> None:
|
||||
for style in get_all_styles():
|
||||
with self.subTest(style=style):
|
||||
url = reverse("static-pygments:styles", args=[style])
|
||||
url = reverse("code-block:styles", args=[style])
|
||||
self.assertIn(PYGMENTS_VERSION_SLUG, url)
|
||||
|
|
|
@ -3,9 +3,13 @@ from django.urls import path
|
|||
from .utils import PYGMENTS_VERSION_SLUG
|
||||
from .views import pygments_styles
|
||||
|
||||
app_name = "code_block"
|
||||
app_name = "code-block"
|
||||
|
||||
urlpatterns = [
|
||||
# HACK: Bake the pygments version into the URL, without needing a custom method
|
||||
path(f"<slug:name>.{PYGMENTS_VERSION_SLUG}.css", pygments_styles, name="styles")
|
||||
path(
|
||||
f"pygments-<slug:name>.{PYGMENTS_VERSION_SLUG}.css",
|
||||
pygments_styles,
|
||||
name="styles",
|
||||
)
|
||||
]
|
||||
|
|
|
@ -14,8 +14,8 @@ urlpatterns = [
|
|||
path("documents/", include(wagtaildocs_urls)),
|
||||
path("search/", search_views.search, name="search"),
|
||||
path(
|
||||
"static-pygments/",
|
||||
include("website.contrib.code_block.urls", namespace="static-pygments"),
|
||||
"code-block/",
|
||||
include("website.contrib.code_block.urls"),
|
||||
),
|
||||
re_path(
|
||||
r"^images/([^/]*)/(\d*)/([^/]*)/[^/]*$",
|
||||
|
|
Loading…
Reference in a new issue