Create json config file & update templates
This commit is contained in:
parent
2f4a23b600
commit
c0b47b0739
12 changed files with 80 additions and 63 deletions
|
@ -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:
|
||||
|
|
18
config/site_config.json
Normal file
18
config/site_config.json
Normal file
|
@ -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 <a href='https://git.hakkeri.net/nyymix/muistox'>muistox</a>.",
|
||||
|
||||
"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/"
|
||||
}
|
21
gallery/context_processors.py
Normal file
21
gallery/context_processors.py
Normal file
|
@ -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}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
{% extends "base_dark.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
{% load stats %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery : About{% endblock %}
|
||||
{% block title %} About {% endblock %}
|
||||
|
||||
<!-- Parallax -->
|
||||
{% block parallax %}
|
||||
|
@ -17,34 +17,34 @@
|
|||
|
||||
<div class="uk-container uk-margin-top">
|
||||
<div class="uk-card uk-card-default uk-card-hover uk-card-body uk-padding-small uk-text-center">
|
||||
<h3 class="uk-card-title uk-text-bold">{{ about.title }}</h3>
|
||||
<h3 class="uk-card-title uk-text-bold">{{ site_config.about_title }}</h3>
|
||||
|
||||
<img class="uk-border-circle uk-box-shadow-small uk-margin-small"
|
||||
src="{% static about.profile_image %}"
|
||||
alt="Nyymix profiilikuva" width="120">
|
||||
src="{% static site_config.about_profile_image %}"
|
||||
alt="Profile photo" width="120">
|
||||
|
||||
<p class="uk-text-muted uk-margin-small">
|
||||
{{ about.description }}
|
||||
{{ site_config.about_description }}
|
||||
</p>
|
||||
|
||||
|
||||
<p class="uk-text-muted uk-margin-small">
|
||||
Contact:
|
||||
<a href="mailto:{{ about.contact_email }}">
|
||||
{{ about.contact_email }}
|
||||
<a href="mailto:{{ site_config.contact_email }}">
|
||||
{{ site_config.contact_email }}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
|
||||
<div class="uk-flex uk-flex-center uk-child-width-auto uk-margin-small-top" uk-grid>
|
||||
{% if about.bluesky_url %}
|
||||
<a href="{{ about.bluesky_url }}" uk-icon="icon: bluesky" uk-tooltip="Bluesky"></a>
|
||||
{% if site_config.bluesky_url %}
|
||||
<a href="{{ site_config.bluesky_url }}" uk-icon="icon: bluesky" uk-tooltip="Bluesky"></a>
|
||||
{% endif %}
|
||||
{% if about.twitter_url %}
|
||||
<a href="{{ about.twitter_url }}" uk-icon="icon: twitter" uk-tooltip="Twitter"></a>
|
||||
{% if site_config.twitter_url %}
|
||||
<a href="{{ site_config.twitter_url }}" uk-icon="icon: twitter" uk-tooltip="Twitter"></a>
|
||||
{% endif %}
|
||||
{% if about.instagram_url %}
|
||||
<a href="{{ about.instagram_url }}" uk-icon="icon: instagram" uk-tooltip="Instagram"></a>
|
||||
{% if site_config.instagram_url %}
|
||||
<a href="{{ site_config.instagram_url }}" uk-icon="icon: instagram" uk-tooltip="Instagram"></a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
{% extends "base_dark.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery : {{ album.name }} {% endblock %}
|
||||
{% block title %} {{ album.name }} {% endblock %}
|
||||
|
||||
<!-- Parallax -->
|
||||
{% block parallax %}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{% extends "base_dark.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery : Albums {% endblock %}
|
||||
{% block title %} Albums {% endblock %}
|
||||
|
||||
<!-- Parallax -->
|
||||
{% block parallax %}
|
||||
|
@ -24,13 +24,12 @@
|
|||
<img src="{{ album.cover_url }}"
|
||||
alt="Cover image for {{ album.name }}"
|
||||
title="{{ album.name }}"
|
||||
loading="lazy"
|
||||
class="uk-border-rounded">
|
||||
loading="lazy">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Album info overlay -->
|
||||
<div class="uk-overlay uk-overlay-primary uk-position-bottom uk-padding-small uk-border-rounded">
|
||||
<div class="uk-overlay uk-overlay-primary uk-position-bottom uk-padding-small">
|
||||
<h3 class="uk-card-title uk-margin-remove-bottom">
|
||||
<a href="{{ album.get_absolute_url }}">{{ album }}</a>
|
||||
</h3>
|
||||
|
|
|
@ -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 />
|
||||
</li>
|
||||
|
@ -34,11 +35,9 @@
|
|||
<a class="uk-position-center-left uk-position-small uk-hidden-hover" href="#" uk-slidenav-previous uk-slideshow-item="previous"></a>
|
||||
<a class="uk-position-center-right uk-position-small uk-hidden-hover" href="#" uk-slidenav-next uk-slideshow-item="next"></a>
|
||||
<div class="uk-position-top uk-padding-small">
|
||||
<h1>Gallery</h1>
|
||||
<h1>{{ site_config.title }}</h1>
|
||||
</div>
|
||||
<div class="uk-overlay uk-overlay-primary uk-position-bottom uk-padding-small">
|
||||
<p class="uk-text-small uk-margin-remove-top">
|
||||
Just another wannabe photographer...
|
||||
</p>
|
||||
<p class="uk-text-small uk-margin-remove-top">{{ site_config.description }}</p>
|
||||
</div>
|
||||
</div>
|
|
@ -1,8 +1,8 @@
|
|||
{% extends "base_dark.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% load exif_filters %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery : {{ photo.album.name }} : {{ photo.slug }} {% endblock %}
|
||||
{% block title %} {{ photo.album.name }} : {{ photo.slug }} {% endblock %}
|
||||
|
||||
|
||||
<!-- Content -->
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{% extends "base_dark.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery : Photostream {% endblock %}
|
||||
{% block title %} Photostream {% endblock %}
|
||||
|
||||
<!-- Parallax -->
|
||||
{% block parallax %}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{% extends "base_dark.html" %}
|
||||
{% extends "base.html" %}
|
||||
{% load static %}
|
||||
|
||||
<!-- Title -->
|
||||
{% block title %} Gallery : Search {% endblock %}
|
||||
{% block title %} Search {% endblock %}
|
||||
|
||||
<!-- Parallax -->
|
||||
{% block parallax %}
|
||||
|
@ -24,13 +24,12 @@
|
|||
<img src="{{ album.cover_url }}"
|
||||
alt="Cover image for {{ album.name }}"
|
||||
title="{{ album.name }}"
|
||||
loading="lazy"
|
||||
class="uk-border-rounded">
|
||||
loading="lazy">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Album info overlay -->
|
||||
<div class="uk-overlay uk-overlay-primary uk-position-bottom uk-padding-small uk-border-rounded">
|
||||
<div class="uk-overlay uk-overlay-primary uk-position-bottom uk-padding-small">
|
||||
<h3 class="uk-card-title uk-margin-remove-bottom">
|
||||
<a href="{{ album.get_absolute_url }}">{{ album }}</a>
|
||||
</h3>
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
{% load static %}
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="Nyymix.net Photo Gallery">
|
||||
<title>{% block title %}Gallery{% endblock %}</title>
|
||||
<meta name="description" content="{{ site_config.site_head_description }}">
|
||||
<title>{{ site_config.site_head_title }} : {% block title %}{% endblock %}</title>
|
||||
|
||||
<!-- UIkit CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/uikit/dist/css/uikit.min.css" />
|
||||
|
@ -85,7 +85,7 @@
|
|||
<!-- Footer -->
|
||||
<footer class="uk-align-center uk-container-large">
|
||||
<div class="uk-background-secondary uk-padding-small uk-light uk-text-center uk-text-light">
|
||||
© {% now "Y" %} Nyymix, powered by <a href="https://git.hakkeri.net/nyymix/muistox">muistox</a>.
|
||||
© {% now "Y" %} {{ site_config.footer_copyright|safe }}
|
||||
</div>
|
||||
</footer>
|
||||
|
Loading…
Add table
Reference in a new issue