mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-08-24 19:01:42 +02:00
Merge branch 'fix-custom-css-static' into 'master'
[FIX] Don't use `static` for the `custom-styles.css` file See merge request allianceauth/allianceauth!1736
This commit is contained in:
commit
a13620ff37
@ -8,7 +8,6 @@ from allianceauth.custom_css.models import CustomCSS
|
|||||||
# Django
|
# Django
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.template.defaulttags import register
|
from django.template.defaulttags import register
|
||||||
from django.templatetags.static import static
|
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -20,7 +19,7 @@ def custom_css_static(path: str) -> str:
|
|||||||
Versioned static URL
|
Versioned static URL
|
||||||
This is to make sure to break the browser cache on CSS updates.
|
This is to make sure to break the browser cache on CSS updates.
|
||||||
|
|
||||||
Example: /static/allianceauth/custom-styles.css?v=1234567890
|
Example: /static/allianceauth/custom-styles.css?v=1752004819.555084
|
||||||
|
|
||||||
:param path:
|
:param path:
|
||||||
:type path:
|
:type path:
|
||||||
@ -42,7 +41,6 @@ def custom_css_static(path: str) -> str:
|
|||||||
custom_css_version = (
|
custom_css_version = (
|
||||||
str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "")
|
str(custom_css_changed).replace(" ", "").replace(":", "").replace("-", "")
|
||||||
) # remove spaces, colons, and dashes
|
) # remove spaces, colons, and dashes
|
||||||
static_url = static(path)
|
versioned_url = f"{settings.STATIC_URL}{path}?v={custom_css_version}"
|
||||||
versioned_url = static_url + "?v=" + custom_css_version
|
|
||||||
|
|
||||||
return mark_safe(f'<link rel="stylesheet" href="{versioned_url}">')
|
return mark_safe(f'<link rel="stylesheet" href="{versioned_url}">')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user