Update about page
This commit is contained in:
parent
c86eca4dbb
commit
5f529dc2b9
8 changed files with 102 additions and 25 deletions
|
@ -138,19 +138,13 @@ MEDIA_ROOT = BASE_DIR / 'media'
|
||||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||||
|
|
||||||
|
|
||||||
# Import local settings
|
|
||||||
try:
|
|
||||||
from .local_settings import *
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Session lifetime 1 year
|
# Session lifetime 1 year
|
||||||
SESSION_COOKIE_AGE = 31556000
|
SESSION_COOKIE_AGE = 31556000
|
||||||
|
|
||||||
|
|
||||||
# Gotify
|
# Gotify
|
||||||
#GOTIFY_URL = "https://gotify....."
|
# GOTIFY_URL = "https://gotify....."
|
||||||
#GOTIFY_TOKEN = "topsecret"
|
# GOTIFY_TOKEN = "topsecret"
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
|
@ -166,10 +160,10 @@ LOGGING = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'handlers': {
|
'handlers': {
|
||||||
#'gotify': {
|
# 'gotify': {
|
||||||
# 'level': 'ERROR',
|
# 'level': 'ERROR',
|
||||||
# 'class': 'gallery.logging_handlers.GotifyHandler',
|
# 'class': 'gallery.logging_handlers.GotifyHandler',
|
||||||
#},
|
# },
|
||||||
'error_file': {
|
'error_file': {
|
||||||
'level': 'ERROR',
|
'level': 'ERROR',
|
||||||
'class': 'logging.FileHandler',
|
'class': 'logging.FileHandler',
|
||||||
|
@ -185,10 +179,31 @@ LOGGING = {
|
||||||
},
|
},
|
||||||
'loggers': {
|
'loggers': {
|
||||||
'django': {
|
'django': {
|
||||||
#'handlers': ['error_file', 'warning_file', 'gotify'],
|
# 'handlers': ['error_file', 'warning_file', 'gotify'],
|
||||||
'handlers': ['error_file', 'warning_file'],
|
'handlers': ['error_file', 'warning_file'],
|
||||||
'level': 'WARNING',
|
'level': 'WARNING',
|
||||||
'propagate': True,
|
'propagate': True,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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:
|
||||||
|
from .local_settings import *
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Generated by Django 5.1.4 on 2025-02-23 15:54
|
# Generated by Django 5.1.7 on 2025-03-28 19:11
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import django.db.models.deletion
|
import django.db.models.deletion
|
||||||
|
@ -56,7 +56,7 @@ class Migration(migrations.Migration):
|
||||||
name='Photo',
|
name='Photo',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('slug', models.CharField(editable=False, max_length=15, verbose_name='Photo Slug')),
|
('slug', models.CharField(editable=False, max_length=15, unique=True, verbose_name='Photo Slug')),
|
||||||
('photo', models.ImageField(height_field='height', upload_to=gallery.models.photo.get_upload_path, verbose_name='Photo', width_field='width')),
|
('photo', models.ImageField(height_field='height', upload_to=gallery.models.photo.get_upload_path, verbose_name='Photo', width_field='width')),
|
||||||
('width', models.PositiveIntegerField(default=0, editable=False, verbose_name='Photo Width')),
|
('width', models.PositiveIntegerField(default=0, editable=False, verbose_name='Photo Width')),
|
||||||
('height', models.PositiveIntegerField(default=0, editable=False, verbose_name='Photo Height')),
|
('height', models.PositiveIntegerField(default=0, editable=False, verbose_name='Photo Height')),
|
||||||
|
@ -88,4 +88,8 @@ class Migration(migrations.Migration):
|
||||||
'verbose_name_plural': 'Redirs',
|
'verbose_name_plural': 'Redirs',
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
migrations.AddConstraint(
|
||||||
|
model_name='photo',
|
||||||
|
constraint=models.UniqueConstraint(fields=('slug',), name='unique_photo_slug'),
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{% extends "base_dark.html" %}
|
{% extends "base_dark.html" %}
|
||||||
{% load top_tags %}
|
{% load static %}
|
||||||
|
{% load stats %}
|
||||||
|
|
||||||
<!-- Title -->
|
<!-- Title -->
|
||||||
{% block title %} Gallery : About{% endblock %}
|
{% block title %} Gallery : About{% endblock %}
|
||||||
|
@ -7,17 +8,48 @@
|
||||||
<!-- Content -->
|
<!-- Content -->
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="uk-margin-top uk-width-1-4@m">
|
{% gallery_stats as counts %}
|
||||||
<div class="uk-card uk-card-default uk-card-body uk-padding-small">
|
|
||||||
{% load static %}
|
|
||||||
<img src="{% static 'img/profile.png' %}" alt="Contact">
|
|
||||||
|
|
||||||
<div class="uk-container uk-margin-small-top">
|
<div class="uk-container uk-margin-top">
|
||||||
<a href="https://bsky.app/profile/nyymix.net" uk-icon="icon: bluesky"></a>
|
<div class="uk-card uk-card-default uk-card-hover uk-card-body uk-padding-small uk-text-center">
|
||||||
<a href="https://twitter.com/nyymix" uk-icon="icon: twitter"></a>
|
<h3 class="uk-card-title uk-text-bold">{{ about.title }}</h3>
|
||||||
<a href="https://www.instagram.com/nyymix/" uk-icon="icon: instagram"></a>
|
|
||||||
|
<img class="uk-border-circle uk-box-shadow-small uk-margin-small"
|
||||||
|
src="{% static about.profile_image %}"
|
||||||
|
alt="Nyymix profiilikuva" width="120">
|
||||||
|
|
||||||
|
<p class="uk-text-muted uk-margin-small">
|
||||||
|
{{ about.description }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p class="uk-text-muted uk-margin-small">
|
||||||
|
Contact:
|
||||||
|
<a href="mailto:{{ about.contact_email }}">
|
||||||
|
{{ about.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>
|
||||||
|
{% endif %}
|
||||||
|
{% if about.twitter_url %}
|
||||||
|
<a href="{{ about.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>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr class="uk-divider-icon">
|
||||||
|
|
||||||
|
<div class="uk-text-small uk-text-muted">
|
||||||
|
<p>
|
||||||
|
<strong>{{ counts.0 }}</strong> <a href="{% url 'gallery:albums_url' %}">Albums</a> (public {{ counts.1 }}),
|
||||||
|
<strong>{{ counts.2 }}</strong> <a href="{% url 'gallery:photos_url' %}">Photos</a></p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="uk-align-center uk-container-large">
|
<div class="uk-align-center uk-container-large uk-padding-medium">
|
||||||
|
|
||||||
<ul uk-accordion>
|
<ul uk-accordion>
|
||||||
<li class="uk-open">
|
<li class="uk-open">
|
||||||
|
|
13
gallery/templatetags/stats.py
Normal file
13
gallery/templatetags/stats.py
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
from gallery.models import Album, Photo
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def gallery_stats():
|
||||||
|
total_photos = Photo.objects.count()
|
||||||
|
total_albums = Album.objects.count()
|
||||||
|
public_albums = Album.objects.filter(is_public=True).count()
|
||||||
|
return total_albums, public_albums, total_photos
|
|
@ -11,27 +11,34 @@ def last_albums(count=5):
|
||||||
albums = Album.objects.filter(is_public=True).order_by("-album_date")[:count]
|
albums = Album.objects.filter(is_public=True).order_by("-album_date")[:count]
|
||||||
return albums
|
return albums
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def top_photos(count=5):
|
def top_photos(count=5):
|
||||||
photos = Photo.objects.filter(album__is_public=True).order_by('-is_favorite', '-likes', '-views').select_related('album')[:count]
|
photos = Photo.objects.filter(album__is_public=True).order_by('-is_favorite', '-likes', '-views').select_related('album')[:count]
|
||||||
return photos
|
return photos
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def random_photos_landscape(count=5):
|
def random_photos_landscape(count=5):
|
||||||
photos = Photo.objects.filter(album__is_public=True, width__gt=F('height')).order_by('?')[:count]
|
photos = Photo.objects.filter(album__is_public=True, width__gt=F('height')).order_by('?')[:count]
|
||||||
return photos
|
return photos
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def top_photos_landscape(count=5):
|
def top_photos_landscape(count=5):
|
||||||
photos = Photo.objects.filter(album__is_public=True, width__gt=F('height')).order_by('-views').select_related('album')[:count]
|
photos = Photo.objects.filter(album__is_public=True, width__gt=F('height')).order_by('-views').select_related('album')[:count]
|
||||||
return photos
|
return photos
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def top_photos_portrait(count=5):
|
def top_photos_portrait(count=5):
|
||||||
photos = Photo.objects.filter(album__is_public=True, height__gt=F('width')).order_by('-views').select_related('album')[:count]
|
photos = Photo.objects.filter(album__is_public=True, height__gt=F('width')).order_by('-views').select_related('album')[:count]
|
||||||
return photos
|
return photos
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def top_photos_in_album(album, count=5):
|
def top_photos_in_album(album, count=5):
|
||||||
photos = Photo.objects.filter(album=album).order_by('-is_favorite', '-likes', '-views').select_related('album')[:count]
|
photos = Photo.objects.filter(album=album).order_by('-is_favorite', '-likes', '-views').select_related('album')[:count]
|
||||||
return photos
|
return photos
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
from django.conf import settings
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.views.generic import DetailView, ListView, TemplateView
|
from django.views.generic import DetailView, ListView, TemplateView
|
||||||
|
@ -90,6 +91,11 @@ class PhotoDetail(DetailView):
|
||||||
class About(TemplateView):
|
class About(TemplateView):
|
||||||
template_name = "gallery/about.html"
|
template_name = "gallery/about.html"
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context["about"] = settings.ABOUT_PAGE_SETTINGS # Haetaan asetukset
|
||||||
|
return context
|
||||||
|
|
||||||
|
|
||||||
def redirect_to_album(request, redir_path):
|
def redirect_to_album(request, redir_path):
|
||||||
redir = get_object_or_404(Redir, path=redir_path)
|
redir = get_object_or_404(Redir, path=redir_path)
|
||||||
|
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
Loading…
Add table
Reference in a new issue