From cca5833541ccea4a46b2e5ea65d5860501d2d19a Mon Sep 17 00:00:00 2001 From: j Date: Wed, 26 Jul 2023 11:50:09 +0200 Subject: [PATCH] move about into context --- app/item/views.py | 7 ++++--- app/page/views.py | 7 +++---- app/static/css/site.scss | 20 +++++++++++++++++--- app/templates/base.html | 39 +++++++++++++++++++++++---------------- app/user/views.py | 5 +++-- app/utils.py | 10 ++++++++++ 6 files changed, 60 insertions(+), 28 deletions(-) create mode 100644 app/utils.py diff --git a/app/item/views.py b/app/item/views.py index f216d9c..0e03575 100644 --- a/app/item/views.py +++ b/app/item/views.py @@ -14,10 +14,11 @@ from . import models from . import tasks from ..signalbot.rpc import send_reaction from .utils import render_to_json +from ..utils import default_context def index(request): - context = {"settings": settings} + context = default_context(request) week, archive = models.Item.public() context['items'] = week context['archive'] = archive.exists() @@ -25,7 +26,7 @@ def index(request): def archive(request): - context = {"settings": settings} + context = default_context(request) qs = models.Item.public() week, archive = models.Item.public() context['items'] = archive @@ -33,7 +34,7 @@ def archive(request): def item(request, id): - context = {"settings": settings} + context = default_context(request) item = models.Item.objects.get(id=id) context['item'] = item qs = item.comments.order_by('created') diff --git a/app/page/views.py b/app/page/views.py index 7c3da49..9386cc2 100644 --- a/app/page/views.py +++ b/app/page/views.py @@ -2,12 +2,11 @@ from django.conf import settings from django.shortcuts import render, redirect, get_object_or_404 from . import models +from ..utils import default_context def page(request, slug): page = get_object_or_404(models.Page, slug=slug) - context = { - 'settings': settings, - 'page': page, - } + context = default_context(request) + context['page'] = page return render(request, 'page.html', context) diff --git a/app/static/css/site.scss b/app/static/css/site.scss index f1a5155..bdf6c77 100644 --- a/app/static/css/site.scss +++ b/app/static/css/site.scss @@ -4,6 +4,7 @@ header, footer { margin: auto; } header { + width: 100%; a { color: yellow; text-decoration: none; @@ -59,18 +60,31 @@ nav.overlay { position: absolute; width: 100%; height: 100vh; - top: 42px; + top: 0; left: 0; right: 0; + padding: 0; + border: 0; max-width: 1000px; margin: auto; background: rgb(16, 16, 16); opacity: 0; z-index: 100; - padding: 4px; display: none; &.active { - display: block; + display: flex; + flex-direction: column; opacity: 0.9; } + .about { + padding: 4px; + padding-top: 8px; + padding-bottom: 8px; + flex-grow: 1; + white-space: pre-line; + } + .user { + padding: 4px; + padding-bottom: 8px; + } } diff --git a/app/templates/base.html b/app/templates/base.html index 9eb72e1..8afd3ef 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -18,30 +18,37 @@ [=] {{ settings.SITENAME }} {% endblock %} diff --git a/app/user/views.py b/app/user/views.py index 20f1739..2949f51 100644 --- a/app/user/views.py +++ b/app/user/views.py @@ -7,6 +7,7 @@ import django.contrib.auth from django.contrib.auth import get_user_model from ..item.utils import render_to_json +from ..utils import default_context from brake.decorators import ratelimit @@ -34,13 +35,13 @@ def register(request): response['user'] = user.username return render_to_json(response) else: - context = {'settings': settings} + context = default_context(request) return render(request, 'register.html', context) @ratelimit(method="POST", block=True, rate="5/m") def login(request): - context = {'settings': settings} + context = default_context(request) response = {} request_type = 'json' if request.method == "POST": diff --git a/app/utils.py b/app/utils.py new file mode 100644 index 0000000..4ad3432 --- /dev/null +++ b/app/utils.py @@ -0,0 +1,10 @@ +from django.conf import settings + +from .page.models import Page + + +def default_context(request): + context = {} + context['settings'] = settings + context['about'] = Page.objects.filter(slug="about").first() + return context