diff --git a/config/settings.py b/config/settings.py index d503725..85d357c 100644 --- a/config/settings.py +++ b/config/settings.py @@ -65,6 +65,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'gallery.context_processors.site_config', ], }, }, @@ -188,20 +189,6 @@ LOGGING = { }, } -ABOUT_PAGE_SETTINGS = { - - "title": "Muistox gallery", - "description": "Just another wannabe photographer...", - "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/", - -} - # Import local settings try: diff --git a/config/site_config.json b/config/site_config.json new file mode 100644 index 0000000..dbbe77a --- /dev/null +++ b/config/site_config.json @@ -0,0 +1,18 @@ +{ + "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 new file mode 100644 index 0000000..c7a7d46 --- /dev/null +++ b/gallery/context_processors.py @@ -0,0 +1,21 @@ +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 c882b59..c75a187 100644 --- a/gallery/templates/gallery/about.html +++ b/gallery/templates/gallery/about.html @@ -1,9 +1,9 @@ -{% extends "base_dark.html" %} +{% extends "base.html" %} {% load static %} {% load stats %} -{% block title %} Gallery : About{% endblock %} +{% block title %} About {% endblock %} {% block parallax %} @@ -17,34 +17,34 @@
-

{{ about.title }}

+

{{ site_config.about_title }}

Nyymix profiilikuva + src="{% static site_config.about_profile_image %}" + alt="Profile photo" width="120">

- {{ about.description }} + {{ site_config.about_description }}

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

- {% if about.bluesky_url %} - + {% if site_config.bluesky_url %} + {% endif %} - {% if about.twitter_url %} - + {% if site_config.twitter_url %} + {% endif %} - {% if about.instagram_url %} - + {% if site_config.instagram_url %} + {% endif %}
diff --git a/gallery/templates/gallery/album_detail.html b/gallery/templates/gallery/album_detail.html index ac1a69c..9b872b5 100644 --- a/gallery/templates/gallery/album_detail.html +++ b/gallery/templates/gallery/album_detail.html @@ -1,9 +1,9 @@ -{% extends "base_dark.html" %} +{% extends "base.html" %} {% load static %} -{% block title %} Gallery : {{ album.name }} {% endblock %} +{% block title %} {{ album.name }} {% endblock %} {% block parallax %} diff --git a/gallery/templates/gallery/album_list.html b/gallery/templates/gallery/album_list.html index 63b8d1b..83e0b61 100644 --- a/gallery/templates/gallery/album_list.html +++ b/gallery/templates/gallery/album_list.html @@ -1,8 +1,8 @@ -{% extends "base_dark.html" %} +{% extends "base.html" %} {% load static %} -{% block title %} Gallery : Albums {% endblock %} +{% block title %} Albums {% endblock %} {% block parallax %} @@ -24,13 +24,12 @@ Cover image for {{ album.name }} + loading="lazy">
-
+

{{ album }}

diff --git a/gallery/templates/gallery/partials/parallax.html b/gallery/templates/gallery/partials/parallax.html index d65bf83..5634298 100644 --- a/gallery/templates/gallery/partials/parallax.html +++ b/gallery/templates/gallery/partials/parallax.html @@ -17,7 +17,8 @@ width="{{ photo.width }}" height="{{ photo.height }}" style="aspect-ratio: 7 / 3;" - alt="{{ photo.album.name }} - {{ photo.slug }}" + alt="Foto from {{ photo.album.name }} album" + title="{{ photo.album.name }}" {% if forloop.first %} loading="eager" {% else %} loading="lazy" {% endif %} uk-cover /> @@ -34,11 +35,9 @@
-

Gallery

+

{{ site_config.title }}

-

- Just another wannabe photographer... -

+

{{ site_config.description }}

\ No newline at end of file diff --git a/gallery/templates/gallery/photo_detail.html b/gallery/templates/gallery/photo_detail.html index ccab3d0..32d9360 100644 --- a/gallery/templates/gallery/photo_detail.html +++ b/gallery/templates/gallery/photo_detail.html @@ -1,8 +1,8 @@ -{% extends "base_dark.html" %} +{% extends "base.html" %} {% load exif_filters %} -{% block title %} Gallery : {{ photo.album.name }} : {{ photo.slug }} {% endblock %} +{% block title %} {{ photo.album.name }} : {{ photo.slug }} {% endblock %} diff --git a/gallery/templates/gallery/photo_list.html b/gallery/templates/gallery/photo_list.html index b1f937f..186a810 100644 --- a/gallery/templates/gallery/photo_list.html +++ b/gallery/templates/gallery/photo_list.html @@ -1,8 +1,8 @@ -{% extends "base_dark.html" %} +{% extends "base.html" %} {% load static %} -{% block title %} Gallery : Photostream {% endblock %} +{% block title %} Photostream {% endblock %} {% block parallax %} diff --git a/gallery/templates/gallery/search.html b/gallery/templates/gallery/search.html index 0f97e69..d4bc50a 100644 --- a/gallery/templates/gallery/search.html +++ b/gallery/templates/gallery/search.html @@ -1,8 +1,8 @@ -{% extends "base_dark.html" %} +{% extends "base.html" %} {% load static %} -{% block title %} Gallery : Search {% endblock %} +{% block title %} Search {% endblock %} {% block parallax %} @@ -24,13 +24,12 @@ Cover image for {{ album.name }} + loading="lazy">
-
+

{{ album }}

diff --git a/gallery/views.py b/gallery/views.py index 5fa8bb7..6da5e87 100644 --- a/gallery/views.py +++ b/gallery/views.py @@ -98,17 +98,6 @@ class PhotoDetail(DetailView): return redirect('gallery:photo_url', album_slug=self.kwargs['album_slug'], photo_slug=self.kwargs['photo_slug']) -class About(TemplateView): - """Static about page.""" - template_name = "gallery/about.html" - - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - context["about"] = settings.ABOUT_PAGE_SETTINGS - return context - - - class Search(TemplateView): """Search view for public albums by name, place or city.""" template_name = "gallery/search.html" @@ -139,6 +128,11 @@ class Search(TemplateView): return context +class About(TemplateView): + """Static about page.""" + template_name = "gallery/about.html" + + def redirect_to_album(request, redir_path): """Handles redirect logic for shortened/legacy album URLs.""" redir = get_object_or_404(Redir, path=redir_path) diff --git a/templates/base_dark.html b/templates/base.html similarity index 94% rename from templates/base_dark.html rename to templates/base.html index 356bc9c..d4aabc5 100644 --- a/templates/base_dark.html +++ b/templates/base.html @@ -5,8 +5,8 @@ {% load static %} - - {% block title %}Gallery{% endblock %} + + {{ site_config.site_head_title }} : {% block title %}{% endblock %} @@ -85,7 +85,7 @@