From cecd679da6409adafaf5e0a4c078e90396585728 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sat, 27 Jan 2024 19:19:51 +0200 Subject: [PATCH] style.css: make hash the same --- .gitignore | 1 + app/e11sync/settings.py | 3 +- app/lib/staticfiles.py | 17 +++++++++ blog/assets/grids-responsive.css | 1 + blog/assets/pure.css | 1 + blog/assets/style.scss | 1 + blog/config.yaml | 6 ++-- blog/content/contact.md | 9 +++++ .../default/layouts/_default/baseof.html | 36 +++++++++---------- static/Makefile | 2 +- static/style.scss | 2 ++ 11 files changed, 53 insertions(+), 26 deletions(-) create mode 100644 app/lib/staticfiles.py create mode 120000 blog/assets/grids-responsive.css create mode 120000 blog/assets/pure.css create mode 120000 blog/assets/style.scss create mode 100644 blog/content/contact.md diff --git a/.gitignore b/.gitignore index 37912fe..a3f12b7 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ __pycache__ result .hugo_build.lock +resources/_gen diff --git a/app/e11sync/settings.py b/app/e11sync/settings.py index ea03db4..8d0a3ea 100644 --- a/app/e11sync/settings.py +++ b/app/e11sync/settings.py @@ -114,10 +114,9 @@ STATICFILES_FINDERS = [ "django.contrib.staticfiles.finders.AppDirectoriesFinder", ] -_storage = 'django.contrib.staticfiles.storage' STORAGES = { "staticfiles": { - "BACKEND": _storage + ".ManifestStaticFilesStorage", + "BACKEND": 'lib.staticfiles.ManifestStaticFilesStorageSha256' }, } diff --git a/app/lib/staticfiles.py b/app/lib/staticfiles.py new file mode 100644 index 0000000..48a50ee --- /dev/null +++ b/app/lib/staticfiles.py @@ -0,0 +1,17 @@ +from hashlib import sha256 + +from django.contrib.staticfiles.storage import ManifestStaticFilesStorage + + +class ManifestStaticFilesStorageSha256(ManifestStaticFilesStorage): + def file_hash(self, name, content=None): + """ + Return a hash of the file with the given name and optional content. + """ + if content is None: + return None + hasher = sha256(usedforsecurity=False) + for chunk in content.chunks(): + hasher.update(chunk) + return hasher.hexdigest() + diff --git a/blog/assets/grids-responsive.css b/blog/assets/grids-responsive.css new file mode 120000 index 0000000..a7d8bf1 --- /dev/null +++ b/blog/assets/grids-responsive.css @@ -0,0 +1 @@ +../../static/grids-responsive.css \ No newline at end of file diff --git a/blog/assets/pure.css b/blog/assets/pure.css new file mode 120000 index 0000000..1e0a97e --- /dev/null +++ b/blog/assets/pure.css @@ -0,0 +1 @@ +../../static/pure.css \ No newline at end of file diff --git a/blog/assets/style.scss b/blog/assets/style.scss new file mode 120000 index 0000000..8bc72e7 --- /dev/null +++ b/blog/assets/style.scss @@ -0,0 +1 @@ +../../static/style.scss \ No newline at end of file diff --git a/blog/config.yaml b/blog/config.yaml index a606a84..05d5471 100644 --- a/blog/config.yaml +++ b/blog/config.yaml @@ -6,11 +6,11 @@ author: Motiejus Jakštys Menus: main: - Name: Sign Up - URL: / + URL: ../ - Name: Blog - URL: /blog/ + URL: / - Name: Contact - URL: /contact/ + URL: ../contact/ permalinks: log: '/:year/:slug/' Params: diff --git a/blog/content/contact.md b/blog/content/contact.md new file mode 100644 index 0000000..35df990 --- /dev/null +++ b/blog/content/contact.md @@ -0,0 +1,9 @@ +--- +title: "Contact" +description: "11sync.net contact details" +--- + +- **Email**: [hello@11sync.net](mailto:hello@11sync.net) +- **Libera.chat**: [#11sync on Libera Chat](https://web.libera.chat/#11sync) + +Unless otherwise stated, ©Motiejus Jakštys. [CC-BY-ND-4.0](https://creativecommons.org/licenses/by-nd/4.0/). diff --git a/blog/themes/default/layouts/_default/baseof.html b/blog/themes/default/layouts/_default/baseof.html index 57d8a74..6f53c04 100644 --- a/blog/themes/default/layouts/_default/baseof.html +++ b/blog/themes/default/layouts/_default/baseof.html @@ -4,7 +4,7 @@ {{ partial "html-meta.html" . -}} {{ if not .IsHome }}{{ .Title }} - {{ end }}{{ .Site.Title }} -{{ $css := resources.Get "style.css" }} +{{ $css := resources.Get "style.scss" | resources.ToCSS (dict "transpiler" "dartsass" "enableSourceMap" false) | resources.Fingerprint }} {{ with .Site.Params.favicon -}} @@ -18,29 +18,25 @@ /> - + +
+ + +
- {{ with .Site.Menus.parent -}} - - {{ end -}} -
-

{{ .Site.Title }}

- {{- if .Site.Params.subtitle }}

{{ .Site.Params.subtitle }}

{{- end }} -
- +

{{ .Site.Title }}

+ {{- if .Site.Params.subtitle }} +

{{ .Site.Params.subtitle }}

+ {{- end }}
+
{{ block "main" . }}{{- end }}
- +
diff --git a/static/Makefile b/static/Makefile index 3260b10..e412271 100644 --- a/static/Makefile +++ b/static/Makefile @@ -1,2 +1,2 @@ style.css: style.scss grids-responsive.css pure.css - sass --no-source-map $< $@ + sass --no-charset --no-source-map $< | perl -p -e 'chomp if eof' > $@ diff --git a/static/style.scss b/static/style.scss index 269546a..5ed582f 100644 --- a/static/style.scss +++ b/static/style.scss @@ -113,6 +113,8 @@ header { } nav { + margin: 0 auto; + max-width: 1000px; padding: 10px 0; text-align: right; a {