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.description }} + {{ site_config.about_description }}
Contact: - - {{ about.contact_email }} + + {{ site_config.contact_email }}