From 758943d9c9bc7aafb8262ee265018502f2db469d Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Fri, 28 Oct 2022 12:09:18 +0200 Subject: [PATCH] More generic pages. --- src/api/templates/api/main.html | 46 +++++++++++-------- src/api/templates/oauth/authorize_token.html | 8 +++- src/api/views.py | 2 +- src/catalogue/api/views.py | 2 +- .../templates/dictionary/note_list.html | 7 ++- .../templates/infopages/2022/infopage.html | 16 ++----- src/isbn/templates/isbn/add_isbn.html | 7 ++- src/isbn/templates/isbn/assigned_isbn.html | 11 ++++- src/isbn/templates/isbn/confirm_isbn_wl.html | 7 ++- src/isbn/templates/isbn/wl_dc_tags.html | 13 ++++-- src/lesmianator/views.py | 2 +- src/reporting/templates/reporting/main.html | 8 +++- src/stats/templates/stats/top.html | 7 ++- src/waiter/templates/waiter/wait.html | 16 +++++-- src/wolnelektury/static/2022/more.scss | 3 +- src/wolnelektury/templates/2022/base.html | 1 + src/wolnelektury/templates/publish_plan.html | 8 +++- src/wolnelektury/templates/user.html | 8 +++- 18 files changed, 121 insertions(+), 51 deletions(-) diff --git a/src/api/templates/api/main.html b/src/api/templates/api/main.html index a2a67cd67..7af79da84 100644 --- a/src/api/templates/api/main.html +++ b/src/api/templates/api/main.html @@ -1,7 +1,13 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n %} {% load build_absolute_uri from fnp_common %} +{% block settings %} + {% load title %} + {% trans "WolneLektury.pl API" as title %} + {% title title %} +{% endblock %} + {% block title %}{% trans "WolneLektury.pl API" %}{% endblock %} {% block bodyid %}api{% endblock %} @@ -35,26 +41,26 @@

@@ -84,7 +90,7 @@

- {% url "api_fragment" "sen-nocy-letniej" "1290526312912-3814598192" as f %} + {% url "catalogue_api_fragment" "sen-nocy-letniej" "1290526312912-3814598192" as f %} {% blocktrans with "/api/authors/william-shakespeare/themes/zabawa/fragments/" as e %} The same way, using also books and themes, you can search for a list of fragments: {{e}}. diff --git a/src/api/templates/oauth/authorize_token.html b/src/api/templates/oauth/authorize_token.html index e54f70136..49dd098ea 100644 --- a/src/api/templates/oauth/authorize_token.html +++ b/src/api/templates/oauth/authorize_token.html @@ -1,6 +1,12 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n %} +{% block settings %} + {% load title %} + {% trans "Authorize access to Wolne Lektury" as title %} + {% title title %} +{% endblock %} + {% block titleextra %}{% trans "Authorize access to Wolne Lektury" %}{% endblock %} {% block body %} diff --git a/src/api/views.py b/src/api/views.py index 6762fb1da..be1491b6f 100644 --- a/src/api/views.py +++ b/src/api/views.py @@ -75,7 +75,7 @@ def oauth_user_auth(request): realms, credentials = endpoint.get_realms_and_credentials( **oauthlib_request(request)) except OAuth1Error as e: - return HttpResponse(e.message, status=400) + return HttpResponse(str(e), status=400) callback = request.GET.get('oauth_callback') form = OAuthAuthenticationForm(initial={ diff --git a/src/catalogue/api/views.py b/src/catalogue/api/views.py index b45ad4656..5512501c6 100644 --- a/src/catalogue/api/views.py +++ b/src/catalogue/api/views.py @@ -320,7 +320,7 @@ class TagView(RetrieveAPIView): slug=self.kwargs['slug'] ) except Http404: - if self.method == 'PUT': + if self.request.method == 'PUT': return Tag( category=self.kwargs['category'], slug=self.kwargs['slug'] diff --git a/src/dictionary/templates/dictionary/note_list.html b/src/dictionary/templates/dictionary/note_list.html index 3a19b4ec8..6c1da2ec1 100644 --- a/src/dictionary/templates/dictionary/note_list.html +++ b/src/dictionary/templates/dictionary/note_list.html @@ -1,7 +1,12 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n pagination_tags %} {% load set_get from set_get %} +{% block settings %} + {% load title %} + {% trans "Footnotes" as title %} + {% title title %} +{% endblock %} {% block bodyid %}footnotes{% endblock %} diff --git a/src/infopages/templates/infopages/2022/infopage.html b/src/infopages/templates/infopages/2022/infopage.html index 9c14723e5..465ad88cc 100644 --- a/src/infopages/templates/infopages/2022/infopage.html +++ b/src/infopages/templates/infopages/2022/infopage.html @@ -1,16 +1,12 @@ {% extends '2022/base.html' %} - -{% block global-content %} -

- -
+{% block settings %} + {% load title %} + {% title page.title %} +{% endblock %} -
+{% block main %}

{{ page.title }}

@@ -24,6 +20,4 @@ -
- {% endblock %} diff --git a/src/isbn/templates/isbn/add_isbn.html b/src/isbn/templates/isbn/add_isbn.html index fcbe6f208..b1eebe2bb 100644 --- a/src/isbn/templates/isbn/add_isbn.html +++ b/src/isbn/templates/isbn/add_isbn.html @@ -1,4 +1,9 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} + +{% block settings %} + {% load title %} + {% title 'Dodaj ISBN' %} +{% endblock %} {% block title %}Dodaj ISBN{% endblock %} diff --git a/src/isbn/templates/isbn/assigned_isbn.html b/src/isbn/templates/isbn/assigned_isbn.html index 971dbabad..5cb99b166 100644 --- a/src/isbn/templates/isbn/assigned_isbn.html +++ b/src/isbn/templates/isbn/assigned_isbn.html @@ -1,14 +1,21 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} + +{% block settings %} + {% load title %} + {% title 'Przypisane ISBN' %} +{% endblock %} {% block title %}Przypisane ISBN{% endblock %} {% block body %}

Przypisane ISBN

-

{{ title }}

+
+

{{ title }}

{% for format, isbn in isbn_formats %}
{{ format }}
{{ isbn }}
{% endfor %}
+
{% endblock %} diff --git a/src/isbn/templates/isbn/confirm_isbn_wl.html b/src/isbn/templates/isbn/confirm_isbn_wl.html index dab9f26d7..96b732624 100644 --- a/src/isbn/templates/isbn/confirm_isbn_wl.html +++ b/src/isbn/templates/isbn/confirm_isbn_wl.html @@ -1,4 +1,9 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} + +{% block settings %} + {% load title %} + {% title 'Potwierdź dane' %} +{% endblock %} {% block title %}Potwierdź dane{% endblock %} diff --git a/src/isbn/templates/isbn/wl_dc_tags.html b/src/isbn/templates/isbn/wl_dc_tags.html index 5bf80360c..01ca42573 100644 --- a/src/isbn/templates/isbn/wl_dc_tags.html +++ b/src/isbn/templates/isbn/wl_dc_tags.html @@ -1,14 +1,21 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} + +{% block settings %} + {% load title %} + {% title 'Przypisane ISBN' %} +{% endblock %} {% block title %}Znaczniki ISBN{% endblock %} {% block body %}

Znaczniki ISBN

+

{{ title }}

-{% for format, content_type, isbn in isbn_formats %} + {% for format, content_type, isbn in isbn_formats %} <dc:relation.hasFormat id="{{ format }}" xmlns:dc="http://purl.org/dc/elements/1.1/">https://wolnelektury.pl/{% if format == 'html' %}katalog/lektura{% else %}media/book/{{ format }}{% endif %}/{{ slug }}.{{ format }}</dc:relation.hasFormat>
<meta refines="#{{ format }}" id="{{ format }}-id" property="dcterms:identifier">ISBN-{{ isbn }}</meta>
<meta refines="#{{ format }}-id" property="identifier-type">ISBN</meta>
<meta refines="#{{ format }}" property="dcterms:format">{{ content_type }}</meta>
{% endfor %}
-{% endblock %} \ No newline at end of file +
+{% endblock %} diff --git a/src/lesmianator/views.py b/src/lesmianator/views.py index e179c1483..b4cbf69b3 100644 --- a/src/lesmianator/views.py +++ b/src/lesmianator/views.py @@ -16,7 +16,7 @@ def main_page(request): return render( request, - 'lesmianator/lesmianator.html', + 'lesmianator/2022/lesmianator.html' if request.EXPERIMENTS['layout'].value else 'lesmianator/lesmianator.html', {"last": last, "shelves": shelves}) @cache.never_cache diff --git a/src/reporting/templates/reporting/main.html b/src/reporting/templates/reporting/main.html index bae491e32..a69e9d165 100644 --- a/src/reporting/templates/reporting/main.html +++ b/src/reporting/templates/reporting/main.html @@ -1,7 +1,13 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n %} {% load reporting_stats catalogue_tags %} +{% block settings %} + {% load title %} + {% trans "Reports" as title %} + {% title title %} +{% endblock %} + {% block titleextra %}{% trans "Reports" %}{% endblock %} {% block bodyid %}reports-stats{% endblock %} diff --git a/src/stats/templates/stats/top.html b/src/stats/templates/stats/top.html index f5ee6c293..ed6867e4a 100644 --- a/src/stats/templates/stats/top.html +++ b/src/stats/templates/stats/top.html @@ -1,4 +1,9 @@ -{% extends 'base/base.html' %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} + +{% block settings %} + {% load title %} + {% title 'Top' %} +{% endblock %} {% block body %} diff --git a/src/waiter/templates/waiter/wait.html b/src/waiter/templates/waiter/wait.html index 22f5af823..c004895e1 100644 --- a/src/waiter/templates/waiter/wait.html +++ b/src/waiter/templates/waiter/wait.html @@ -1,7 +1,15 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n %} {% load static from static %} + +{% block settings %} + {% load title %} + {% trans "Your file is being prepared, please wait." as title %} + {% title title %} +{% endblock %} + + {% block titleextra %} {% if file_url %} {% trans "The file is ready for download!" %} @@ -42,12 +50,14 @@ {% else %} {% if waiting %}

- {% trans 'Please wait' %} {% trans "Your file is being prepared, please wait." %}

-

{% blocktrans with d=waiting.description %}The file you requested was: {{d}}.{% endblocktrans %}

+

+ {% trans 'Please wait' %} + {% blocktrans with d=waiting.description %}The file you requested was: {{d}}.{% endblocktrans %} +

{% blocktrans %}Be aware: Generating the file can take a while. diff --git a/src/wolnelektury/static/2022/more.scss b/src/wolnelektury/static/2022/more.scss index 8f95d12f9..424125394 100644 --- a/src/wolnelektury/static/2022/more.scss +++ b/src/wolnelektury/static/2022/more.scss @@ -318,10 +318,11 @@ form { color: #92BD39; } - > p, form { + > p, form, > .normal-text { min-width: 300px; margin-left: 50px; margin-right: 50px; + width: auto; } } diff --git a/src/wolnelektury/templates/2022/base.html b/src/wolnelektury/templates/2022/base.html index 12bae5959..f314f1f85 100644 --- a/src/wolnelektury/templates/2022/base.html +++ b/src/wolnelektury/templates/2022/base.html @@ -22,6 +22,7 @@ {% tracking_code %} + {% block extrahead %}{% endblock %} {% include '2022/header.html' %} diff --git a/src/wolnelektury/templates/publish_plan.html b/src/wolnelektury/templates/publish_plan.html index ffc11501e..22e59a97f 100644 --- a/src/wolnelektury/templates/publish_plan.html +++ b/src/wolnelektury/templates/publish_plan.html @@ -1,6 +1,12 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n %} +{% block settings %} + {% load title %} + {% trans "Publishing plan" as title %} + {% title title %} +{% endblock %} + {% block titleextra %}{% trans "Publishing plan" %}{% endblock titleextra %} diff --git a/src/wolnelektury/templates/user.html b/src/wolnelektury/templates/user.html index 3adb03028..40c7950d4 100644 --- a/src/wolnelektury/templates/user.html +++ b/src/wolnelektury/templates/user.html @@ -1,7 +1,13 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout.value|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n %} +{% block settings %} + {% load title %} + {% trans "User" as title %} + {% title title %} +{% endblock %} + {% block titleextra %}{% trans "User" %}{% endblock %} {% block body %} -- 2.20.1