From 62c40d1b7b42a7f60e5bc9e0b8b570f1ab15dba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Wed, 23 Aug 2023 10:54:25 +0200 Subject: [PATCH] Update cached styles and scripts after version change (#510) --- bookmarks/context_processors.py | 7 +++++++ bookmarks/templates/bookmarks/archive.html | 2 +- bookmarks/templates/bookmarks/form.html | 3 +-- bookmarks/templates/bookmarks/index.html | 2 +- bookmarks/templates/bookmarks/layout.html | 8 ++++---- bookmarks/templates/bookmarks/shared.html | 2 +- bookmarks/utils.py | 8 ++++++++ bookmarks/views/settings.py | 8 +------- siteroot/settings/base.py | 1 + 9 files changed, 25 insertions(+), 16 deletions(-) diff --git a/bookmarks/context_processors.py b/bookmarks/context_processors.py index e1c171d..a179811 100644 --- a/bookmarks/context_processors.py +++ b/bookmarks/context_processors.py @@ -1,5 +1,6 @@ from bookmarks import queries from bookmarks.models import Toast +from bookmarks import utils def toasts(request): @@ -23,3 +24,9 @@ def public_shares(request): } return {} + + +def app_version(request): + return { + 'app_version': utils.app_version + } diff --git a/bookmarks/templates/bookmarks/archive.html b/bookmarks/templates/bookmarks/archive.html index e060a86..b31c5f5 100644 --- a/bookmarks/templates/bookmarks/archive.html +++ b/bookmarks/templates/bookmarks/archive.html @@ -41,5 +41,5 @@ - + {% endblock %} diff --git a/bookmarks/templates/bookmarks/form.html b/bookmarks/templates/bookmarks/form.html index 39530df..83ec994 100644 --- a/bookmarks/templates/bookmarks/form.html +++ b/bookmarks/templates/bookmarks/form.html @@ -116,8 +116,7 @@ Nevermind - {# Replace tag input with auto-complete component #} - + + {% endblock %} diff --git a/bookmarks/templates/bookmarks/layout.html b/bookmarks/templates/bookmarks/layout.html index a020b75..f978002 100644 --- a/bookmarks/templates/bookmarks/layout.html +++ b/bookmarks/templates/bookmarks/layout.html @@ -18,14 +18,14 @@ {# Include SASS styles, files are resolved from bookmarks/styles #} {# Include specific theme variant based on user profile setting #} {% if request.user_profile.theme == 'light' %} - + {% elif request.user_profile.theme == 'dark' %} - + {% else %} {# Use auto theme as fallback #} - - {% endif %} diff --git a/bookmarks/templates/bookmarks/shared.html b/bookmarks/templates/bookmarks/shared.html index cc271e3..f4fa062 100644 --- a/bookmarks/templates/bookmarks/shared.html +++ b/bookmarks/templates/bookmarks/shared.html @@ -45,5 +45,5 @@ - + {% endblock %} diff --git a/bookmarks/utils.py b/bookmarks/utils.py index 0352fbe..0a407cd 100644 --- a/bookmarks/utils.py +++ b/bookmarks/utils.py @@ -1,3 +1,4 @@ +import logging import re from datetime import datetime from typing import Optional @@ -6,6 +7,13 @@ from dateutil.relativedelta import relativedelta from django.template.defaultfilters import pluralize from django.utils import timezone, formats +try: + with open("version.txt", "r") as f: + app_version = f.read().strip("\n") +except Exception as exc: + logging.exception(exc) + app_version = '' + def unique(elements, key): return list({key(element): element for element in elements}.values()) diff --git a/bookmarks/views/settings.py b/bookmarks/views/settings.py index d743af0..3ced6bc 100644 --- a/bookmarks/views/settings.py +++ b/bookmarks/views/settings.py @@ -16,16 +16,10 @@ from bookmarks.models import UserProfileForm, FeedToken from bookmarks.queries import query_bookmarks from bookmarks.services import exporter, tasks from bookmarks.services import importer +from bookmarks.utils import app_version logger = logging.getLogger(__name__) -try: - with open("version.txt", "r") as f: - app_version = f.read().strip("\n") -except Exception as exc: - logging.exception(exc) - pass - @login_required def general(request): diff --git a/siteroot/settings/base.py b/siteroot/settings/base.py index 9dc94f5..ef4402d 100644 --- a/siteroot/settings/base.py +++ b/siteroot/settings/base.py @@ -73,6 +73,7 @@ TEMPLATES = [ 'django.contrib.messages.context_processors.messages', 'bookmarks.context_processors.toasts', 'bookmarks.context_processors.public_shares', + 'bookmarks.context_processors.app_version', ], }, },