From 4b2c05eedf0c6b3d213ce0b760d641c345e3c9b3 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 23 May 2023 16:10:28 +0200 Subject: [PATCH] Layout. --- requirements/requirements.txt | 2 +- .../catalogue/2022/author_detail.html | 2 +- .../templates/catalogue/2022/book_box.html | 2 +- .../templates/catalogue/2022/book_detail.html | 2 +- .../catalogue/2022/book_fragments.html | 78 +++++++++++++++++++ .../catalogue/2022/fragment_box.html | 35 ++++++--- .../catalogue/2022/fragment_slider_box.html | 10 +++ .../catalogue/2022/theme_detail.html | 28 +------ .../templates/catalogue/catalogue.html | 8 +- .../catalogue/recent_audiobooks_list.html | 22 ++++-- .../catalogue/recent_daisy_list.html | 22 ++++-- .../templates/catalogue/recent_list.html | 24 ++++-- src/catalogue/urls.py | 19 +++-- src/catalogue/views.py | 7 +- .../templates/push/notification_form.html | 4 +- .../templates/push/notification_sent.html | 4 +- src/wolnelektury/settings/contrib.py | 1 + src/wolnelektury/templates/forms/p.html | 20 +++++ 18 files changed, 212 insertions(+), 78 deletions(-) create mode 100644 src/catalogue/templates/catalogue/2022/book_fragments.html create mode 100644 src/catalogue/templates/catalogue/2022/fragment_slider_box.html create mode 100644 src/wolnelektury/templates/forms/p.html diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 3fb38a59c..99e11fa09 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -19,7 +19,7 @@ django-admin-ordering==0.16 django-countries==7.3.2 # A version compatible with Django 2.2+, with long help text and editable max_length. --e git+https://github.com/rczajka/django-forms-builder@30beb889cbf297be35963c15501c764a0689b539#egg=django-forms-builder +-e git+https://github.com/rczajka/django-forms-builder@9c5cc4763e586b00b95366299f88f092471b7798#egg=django-forms-builder oauthlib>=3.0.1,<3.1 diff --git a/src/catalogue/templates/catalogue/2022/author_detail.html b/src/catalogue/templates/catalogue/2022/author_detail.html index dc673b26a..120fec425 100644 --- a/src/catalogue/templates/catalogue/2022/author_detail.html +++ b/src/catalogue/templates/catalogue/2022/author_detail.html @@ -95,7 +95,7 @@ {% for fragment in cites %}
- {% include "catalogue/2022/fragment_box.html" %} + {% include "catalogue/2022/fragment_slider_box.html" %}
{% endfor %} diff --git a/src/catalogue/templates/catalogue/2022/book_box.html b/src/catalogue/templates/catalogue/2022/book_box.html index 8aabcd55e..4919ba1ba 100644 --- a/src/catalogue/templates/catalogue/2022/book_box.html +++ b/src/catalogue/templates/catalogue/2022/book_box.html @@ -6,7 +6,7 @@ {% if book.is_picture %} {% if book.image_file %} {% thumbnail book.image_file "170x240" crop="center" as im %} - + {% endthumbnail %} {% endif %} {% else %} diff --git a/src/catalogue/templates/catalogue/2022/book_detail.html b/src/catalogue/templates/catalogue/2022/book_detail.html index 7fd9dcf6a..f0910a542 100644 --- a/src/catalogue/templates/catalogue/2022/book_detail.html +++ b/src/catalogue/templates/catalogue/2022/book_detail.html @@ -370,7 +370,7 @@
{% for fragment in cites %} - {% include "catalogue/2022/fragment_box.html" %} + {% include "catalogue/2022/fragment_slider_box.html" %} {% endfor %}
diff --git a/src/catalogue/templates/catalogue/2022/book_fragments.html b/src/catalogue/templates/catalogue/2022/book_fragments.html new file mode 100644 index 000000000..d1d4f2435 --- /dev/null +++ b/src/catalogue/templates/catalogue/2022/book_fragments.html @@ -0,0 +1,78 @@ +{% extends '2022/base.html' %} +{% load pagination_tags %} + +{% block global-content %} +
+ +
+ +
+ +
+
+

+ Motyw: {{ theme.name }} + w utworze + {{ book }} +

+
+
+ + + + {% autopaginate fragments 10 %} + +
+
+
+
+ + {% for fragment in fragments %} + {% include 'catalogue/2022/fragment_box.html' %} + {% endfor %} + {% paginate using '2022/paginate.html' %} +
+
+
+
+

Motyw: {{ theme.name }}

+ {{ theme.description|safe }} + +
+
+
+
+
+ +{% endblock %} diff --git a/src/catalogue/templates/catalogue/2022/fragment_box.html b/src/catalogue/templates/catalogue/2022/fragment_box.html index 2522ce66e..7371976c3 100644 --- a/src/catalogue/templates/catalogue/2022/fragment_box.html +++ b/src/catalogue/templates/catalogue/2022/fragment_box.html @@ -1,10 +1,27 @@ - - - {% if fragment.short_text %} +
+
+ + {% if fragment.book.cover_clean %} + {{ fragment.book.title }} + {% endif %} + +
+
+
+ + {% if fragment.book.has_mp3_file %} + + {% endif %} +
+

+ {% for author in fragment.book.authors %} + {{ author }}{% if not forloop.last %}, {% endif %} + {% endfor %} +

+

{{ fragment.book.title }}

+
{{ fragment.short_text|safe }} - {% else %} - {{ fragment.text|safe }} - {% endif %} - -

{{ fragment.book.pretty_title }}

- +
+ Czytaj więcej +
+
diff --git a/src/catalogue/templates/catalogue/2022/fragment_slider_box.html b/src/catalogue/templates/catalogue/2022/fragment_slider_box.html new file mode 100644 index 000000000..2522ce66e --- /dev/null +++ b/src/catalogue/templates/catalogue/2022/fragment_slider_box.html @@ -0,0 +1,10 @@ + + + {% if fragment.short_text %} + {{ fragment.short_text|safe }} + {% else %} + {{ fragment.text|safe }} + {% endif %} + +

{{ fragment.book.pretty_title }}

+
diff --git a/src/catalogue/templates/catalogue/2022/theme_detail.html b/src/catalogue/templates/catalogue/2022/theme_detail.html index 5713cecea..29b0eebfa 100644 --- a/src/catalogue/templates/catalogue/2022/theme_detail.html +++ b/src/catalogue/templates/catalogue/2022/theme_detail.html @@ -46,33 +46,7 @@
{% for fragment in object_list %} - + {% include 'catalogue/2022/fragment_box.html' %} {% endfor %} {% paginate using '2022/paginate.html' %}
diff --git a/src/catalogue/templates/catalogue/catalogue.html b/src/catalogue/templates/catalogue/catalogue.html index bb86b7ac6..935d232fa 100644 --- a/src/catalogue/templates/catalogue/catalogue.html +++ b/src/catalogue/templates/catalogue/catalogue.html @@ -1,4 +1,4 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout|yesno:"2022/base.html,base/base.html" %} {% load i18n %} {% load catalogue_tags %} @@ -7,9 +7,9 @@ {% block bodyid %}catalogue-catalogue{% endblock %} -{% block body %} +{% block body %}{% block main %}

{% trans "All works" %}

-
+ -{% endblock %} +{% endblock %}{% endblock %} diff --git a/src/catalogue/templates/catalogue/recent_audiobooks_list.html b/src/catalogue/templates/catalogue/recent_audiobooks_list.html index a597f0b88..b600936f8 100644 --- a/src/catalogue/templates/catalogue/recent_audiobooks_list.html +++ b/src/catalogue/templates/catalogue/recent_audiobooks_list.html @@ -1,4 +1,4 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout|yesno:"2022/base.html,base/base.html" %} {% load i18n %} {% load catalogue_tags %} @@ -6,10 +6,20 @@ {% block bodyid %}recent-list{% endblock %} -{% block body %} +{% block body %}{% block main %}

{% trans "Recent audiobooks" %}

-
- {% work_list object_list %} -
-{% endblock %} + {% if request.EXPERIMENTS.layout %} +
+
+ {% for book in object_list %} + {% include "catalogue/2022/book_box.html" %} + {% endfor %} +
+
+ {% else %} +
+ {% work_list object_list %} +
+ {% endif %} +{% endblock %}{% endblock %} diff --git a/src/catalogue/templates/catalogue/recent_daisy_list.html b/src/catalogue/templates/catalogue/recent_daisy_list.html index 2b0ab83ed..fe6be3bb1 100644 --- a/src/catalogue/templates/catalogue/recent_daisy_list.html +++ b/src/catalogue/templates/catalogue/recent_daisy_list.html @@ -1,4 +1,4 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout|yesno:"2022/base.html,base/base.html" %} {% load i18n %} {% load catalogue_tags %} @@ -6,10 +6,20 @@ {% block bodyid %}recent-list{% endblock %} -{% block body %} +{% block body %}{% block main %}

{% trans "Recent DAISY files" %}

-
- {% work_list object_list %} -
-{% endblock %} + {% if request.EXPERIMENTS.layout %} +
+
+ {% for book in object_list %} + {% include "catalogue/2022/book_box.html" %} + {% endfor %} +
+
+ {% else %} +
+ {% work_list object_list %} +
+ {% endif %} +{% endblock %}{% endblock %} diff --git a/src/catalogue/templates/catalogue/recent_list.html b/src/catalogue/templates/catalogue/recent_list.html index f0fadb30b..f6b917228 100644 --- a/src/catalogue/templates/catalogue/recent_list.html +++ b/src/catalogue/templates/catalogue/recent_list.html @@ -1,4 +1,4 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout|yesno:"2022/base.html,base/base.html" %} {% load i18n %} {% load catalogue_tags %} @@ -6,17 +6,27 @@ {% block bodyid %}recent-list{% endblock %} -{% block body %} +{% block body %}{% block main %}

{% trans "Recent publications" %}

{% url 'recent_audiobooks_list' as a %} {% url 'recent_daisy_list' as d %}

{% blocktrans %}You can also see recent audiobooks - and recent DAISY files.{% endblocktrans %} + and recent DAISY files.{% endblocktrans %}

-
- {% work_list object_list %} -
-{% endblock %} + {% if request.EXPERIMENTS.layout %} +
+
+ {% for book in object_list %} + {% include "catalogue/2022/book_box.html" %} + {% endfor %} +
+
+ {% else %} +
+ {% work_list object_list %} +
+ {% endif %} +{% endblock %}{% endblock %} diff --git a/src/catalogue/urls.py b/src/catalogue/urls.py index f8eb6a4b2..7049b1c85 100644 --- a/src/catalogue/urls.py +++ b/src/catalogue/urls.py @@ -14,7 +14,7 @@ import search.views urlpatterns = [ path('obraz/strona/', picture.views.picture_page, name='picture_page'), # pictures - currently pictures are coupled with catalogue, hence the url is here - path('obraz/', picture.views.picture_list_thumb, name='picture_list_thumb'), # TODO: catalogue view + path('obraz/', picture.views.picture_list_thumb, name='picture_list_thumb'), path('obraz/.html', picture.views.picture_viewer, name='picture_viewer'), path('obraz//', picture.views.picture_detail, name='picture_detail'), @@ -22,9 +22,8 @@ urlpatterns = [ path('szukaj/', RedirectView.as_view( url='/szukaj/', query_string=True, permanent=True)), - path('', views.catalogue, name='catalogue'), # TODO catalogue + path('', views.catalogue, name='catalogue'), - # TODO: catalogue path('autor/', views.tag_catalogue, {'category': 'author'}, name='author_catalogue'), path('epoka/', views.tag_catalogue, {'category': 'epoch'}, name='epoch_catalogue'), path('gatunek/', views.tag_catalogue, {'category': 'genre'}, name='genre_catalogue'), @@ -37,16 +36,16 @@ urlpatterns = [ path('lektury/', views.literature, name='book_list'), path('lektury//', views.collection, name='collection'), path('audiobooki/', views.audiobooks, name='audiobook_list'), - path('daisy/', views.daisy_list, name='daisy_list'), # TODO: catalogue + path('daisy/', views.daisy_list, name='daisy_list'), path('jtags/', search.views.hint, {'param': 'q', 'mozhint': True}, name='jhint'), - path('nowe/', ListView.as_view( # TODO - queryset=Book.objects.filter(parent=None, findable=True).order_by('-created_at'), + path('nowe/', ListView.as_view( + queryset=Book.objects.filter(parent=None, findable=True).order_by('-created_at')[:100], template_name='catalogue/recent_list.html'), name='recent_list'), - path('nowe/audiobooki/', ListView.as_view( # TODO - queryset=Book.objects.filter(media__type='ogg').annotate(m=Max('media__uploaded_at')).order_by('-m'), + path('nowe/audiobooki/', ListView.as_view( + queryset=Book.objects.filter(media__type='ogg').annotate(m=Max('media__uploaded_at')).order_by('-m')[:100], template_name='catalogue/recent_audiobooks_list.html'), name='recent_audiobooks_list'), - path('nowe/daisy/', ListView.as_view( # TODO - queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m'), + path('nowe/daisy/', ListView.as_view( + queryset=Book.objects.filter(media__type='daisy').annotate(m=Max('media__uploaded_at')).order_by('-m')[:100], template_name='catalogue/recent_daisy_list.html'), name='recent_daisy_list'), path('custompdf//', views.CustomPDFFormView(), name='custom_pdf_form'), diff --git a/src/catalogue/views.py b/src/catalogue/views.py index 2b188e684..b4e5920ea 100644 --- a/src/catalogue/views.py +++ b/src/catalogue/views.py @@ -299,9 +299,14 @@ def book_fragments(request, slug, theme_slug): fragments = Fragment.tagged.with_all([theme]).filter( Q(book=book) | Q(book__ancestor=book)) + if request.EXPERIMENTS['layout'].value: + template_name = 'catalogue/2022/book_fragments.html' + else: + template_name = 'catalogue/book_fragments.html' + return render( request, - 'catalogue/book_fragments.html', + template_name, { 'book': book, 'theme': theme, diff --git a/src/push/templates/push/notification_form.html b/src/push/templates/push/notification_form.html index e926c9229..09e60550d 100644 --- a/src/push/templates/push/notification_form.html +++ b/src/push/templates/push/notification_form.html @@ -1,4 +1,4 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n %} {% block titleextra %}{% trans "Notifications" %}{% endblock %} @@ -14,4 +14,4 @@ -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/push/templates/push/notification_sent.html b/src/push/templates/push/notification_sent.html index 44c29c327..3cf938a5b 100644 --- a/src/push/templates/push/notification_sent.html +++ b/src/push/templates/push/notification_sent.html @@ -1,4 +1,4 @@ -{% extends "base/base.html" %} +{% extends request.EXPERIMENTS.layout|yesno:"2022/base_simple.html,base/base.html" %} {% load i18n %} {% block titleextra %}{% trans "Notifications" %}{% endblock %} @@ -7,4 +7,4 @@ {% block body %}

Wysłano powiadomienie

Gratulacje!

-{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/wolnelektury/settings/contrib.py b/src/wolnelektury/settings/contrib.py index f2247facd..858c4022c 100644 --- a/src/wolnelektury/settings/contrib.py +++ b/src/wolnelektury/settings/contrib.py @@ -53,3 +53,4 @@ FORMS_BUILDER_EXTRA_FIELDS = [ FORMS_BUILDER_HELPTEXT_MAX_LENGTH = 2048 FORMS_BUILDER_REQUIRED_CSS_CLASS = 'required' FORMS_BUILDER_INACTIVE_VISIBLE = True +FORMS_BUILDER_TEMPLATE_NAME_P = 'forms/p.html' diff --git a/src/wolnelektury/templates/forms/p.html b/src/wolnelektury/templates/forms/p.html new file mode 100644 index 000000000..be238bb80 --- /dev/null +++ b/src/wolnelektury/templates/forms/p.html @@ -0,0 +1,20 @@ +{{ errors }} +{% if errors and not fields %} +

{% for field in hidden_fields %}{{ field }}{% endfor %}

+{% endif %} +{% for field, errors in fields %} + {{ errors }} + + {% if field.label %}{{ field.label_tag }}{% endif %} + {% if field.help_text %} +
{{ field.help_text|safe }} + {% endif %} + {{ field }} + {% if forloop.last %} + {% for field in hidden_fields %}{{ field }}{% endfor %} + {% endif %} +

+{% endfor %} +{% if not fields and not errors %} + {% for field in hidden_fields %}{{ field }}{% endfor %} +{% endif %} -- 2.20.1