diff --git a/.gitignore b/.gitignore index ce4a1a7..7052bc2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ # ---> Muistox media/ +templates_local/ + # ---> Python # Byte-compiled / optimized / DLL files diff --git a/config/settings.py b/config/settings.py index 224a8b6..1bbd576 100644 --- a/config/settings.py +++ b/config/settings.py @@ -43,6 +43,10 @@ TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [BASE_DIR / "templates"], + 'DIRS': [ + BASE_DIR / "templates_local", + BASE_DIR / "templates", + ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ @@ -50,7 +54,6 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', - 'gallery.context_processors.site_config', ], }, }, @@ -98,9 +101,8 @@ TIME_ZONE = 'UTC' USE_I18N = True -#USE_TZ = True -USE_TZ = False - +# USE_L10N = True +# USE_TZ = False # Static files (CSS, JavaScript, Images) @@ -130,20 +132,21 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' # Sessions SESSION_COOKIE_AGE = 60 * 60 * 24 * 365 * 5 # 5 vuotta SESSION_EXPIRE_AT_BROWSER_CLOSE = False -SESSION_COOKIE_SECURE = True SESSION_COOKIE_SAMESITE = 'Lax' +SESSION_CACHE_ALIAS = "default" # Sessio backend: cache + fallback tietokantaan SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db' -# Redis cache +# Redis cache CACHES = { "default": { "BACKEND": "django_redis.cache.RedisCache", "LOCATION": "redis://127.0.0.1:6379/1", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", - } + }, + 'KEY_PREFIX': 'session', } } @@ -198,4 +201,4 @@ LOGGING = { try: from .local_settings import * except ImportError: - pass \ No newline at end of file + pass diff --git a/config/site_config.json b/config/site_config.json deleted file mode 100644 index dbbe77a..0000000 --- a/config/site_config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "site_head_title": "Gallery", - "site_head_description": "Muistox Photo Gallery", - - "title": "Gallery", - "description": "Just another wannabe photographer...", - - "footer_copyright": "Powered by muistox.", - - "about_title": "Muistox gallery", - "about_description": "Just another wannabe photographer...", - "about_profile_image": "img/default.png", - - "contact_email": "muistox@gallery.invalid", - "bluesky_url": "https://bsky.app/", - "twitter_url": "https://twitter.com/", - "instagram_url": "https://www.instagram.com/" -} \ No newline at end of file diff --git a/gallery/context_processors.py b/gallery/context_processors.py deleted file mode 100644 index 5c38e85..0000000 --- a/gallery/context_processors.py +++ /dev/null @@ -1,20 +0,0 @@ -import json -from pathlib import Path - -from django.conf import settings -from django.core.cache import cache - - -def site_config(request): - config = cache.get('site_config') - - if not config: - config_path = Path(settings.BASE_DIR) / 'config' / 'site_config.json' - try: - with open(config_path, 'r') as f: - config = json.load(f) - cache.set('site_config', config, 3600) - except FileNotFoundError: - config = {} - - return {'site_config': config} diff --git a/gallery/templates/gallery/about.html b/gallery/templates/gallery/about.html index f54048b..1af3adf 100644 --- a/gallery/templates/gallery/about.html +++ b/gallery/templates/gallery/about.html @@ -27,35 +27,16 @@
-

{{ site_config.about_title }}

+

Muistox gallery

Profile photo

- {{ site_config.about_description }} + Just another wannabe photographer...

-

- Contact: - - {{ site_config.contact_email }} - -

- -
- {% if site_config.bluesky_url %} - - {% endif %} - {% if site_config.twitter_url %} - - {% endif %} - {% if site_config.instagram_url %} - - {% endif %} -
-
diff --git a/gallery/templates/gallery/main.html b/gallery/templates/gallery/main.html index 836af5a..b6bbcfa 100644 --- a/gallery/templates/gallery/main.html +++ b/gallery/templates/gallery/main.html @@ -3,7 +3,7 @@ {% load image_tags %} -{% block title %}{{ site_config.description }}{% endblock %} +{% block title %}Home{% endblock %} {% block parallax %} diff --git a/gallery/templates/gallery/partials/parallax.html b/gallery/templates/gallery/partials/parallax.html index b7d9e02..6074ed4 100644 --- a/gallery/templates/gallery/partials/parallax.html +++ b/gallery/templates/gallery/partials/parallax.html @@ -36,9 +36,9 @@
-

{{ site_config.title }}

+

Gallery

-

{{ site_config.description }}

+

Just another wannabe photographer...

\ No newline at end of file diff --git a/gallery/templates/gallery/photo_slideshow.html b/gallery/templates/gallery/photo_slideshow.html index 6d887e2..9e643d9 100644 --- a/gallery/templates/gallery/photo_slideshow.html +++ b/gallery/templates/gallery/photo_slideshow.html @@ -4,8 +4,8 @@ {% load static %} - - {{ site_config.site_head_title }} : Slideshow : {{ photo.album.name }} + + Slideshow : {{ photo.album.name }} - Gallery {% if next_photo %} {% endif %} diff --git a/templates/base.html b/templates/base.html index 0709d9e..73b2379 100644 --- a/templates/base.html +++ b/templates/base.html @@ -5,8 +5,8 @@ {% load static %} - - {% block title %}{% endblock %} - {{ site_config.site_head_title }} + + {% block title %}{% endblock %} - Gallery {% if canonical_url %} {% endif %} @@ -86,7 +86,7 @@