Layout.
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 23 May 2023 14:10:28 +0000 (16:10 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 23 May 2023 14:10:28 +0000 (16:10 +0200)
18 files changed:
requirements/requirements.txt
src/catalogue/templates/catalogue/2022/author_detail.html
src/catalogue/templates/catalogue/2022/book_box.html
src/catalogue/templates/catalogue/2022/book_detail.html
src/catalogue/templates/catalogue/2022/book_fragments.html [new file with mode: 0644]
src/catalogue/templates/catalogue/2022/fragment_box.html
src/catalogue/templates/catalogue/2022/fragment_slider_box.html [new file with mode: 0644]
src/catalogue/templates/catalogue/2022/theme_detail.html
src/catalogue/templates/catalogue/catalogue.html
src/catalogue/templates/catalogue/recent_audiobooks_list.html
src/catalogue/templates/catalogue/recent_daisy_list.html
src/catalogue/templates/catalogue/recent_list.html
src/catalogue/urls.py
src/catalogue/views.py
src/push/templates/push/notification_form.html
src/push/templates/push/notification_sent.html
src/wolnelektury/settings/contrib.py
src/wolnelektury/templates/forms/p.html [new file with mode: 0644]

index 3fb38a5..99e11fa 100644 (file)
@@ -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
index dc673b2..120fec4 100644 (file)
@@ -95,7 +95,7 @@
 
                 {% for fragment in cites %}
                   <div class="l-author__quotes__slider__item">
-                    {% include "catalogue/2022/fragment_box.html" %}
+                    {% include "catalogue/2022/fragment_slider_box.html" %}
                   </div>
                 {% endfor %}
 
index 8aabcd5..4919ba1 100644 (file)
@@ -6,7 +6,7 @@
       {% if book.is_picture %}
         {% if book.image_file %}
           {% thumbnail book.image_file "170x240" crop="center" as im %}
-          <img style="float: left; margin:{{ im|margin:"170x240" }}" src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}" />
+          <img src="{{ im.url }}" width="{{ im.x }}" height="{{ im.y }}" />
           {% endthumbnail %}
         {% endif %}
       {% else %}
index 7fd9dcf..f0910a5 100644 (file)
                 <div class="l-author__quotes">
                   <div class="l-author__quotes__slider">
                     {% for fragment in cites %}
-                      {% include "catalogue/2022/fragment_box.html" %}
+                      {% include "catalogue/2022/fragment_slider_box.html" %}
                     {% endfor %}
                   </div>
                 </div>
diff --git a/src/catalogue/templates/catalogue/2022/book_fragments.html b/src/catalogue/templates/catalogue/2022/book_fragments.html
new file mode 100644 (file)
index 0000000..d1d4f24
--- /dev/null
@@ -0,0 +1,78 @@
+{% extends '2022/base.html' %}
+{% load pagination_tags %}
+
+{% block global-content %}
+  <div class="l-container">
+    <div class="l-breadcrumb">
+      <a href="/"><span>Strona główna</span></a>
+      <a href="/katalog/lektury/"><span>Literatura</span></a>
+      {% for ancestor in fragment.book.ancestors %}
+        <a href="{{ ancestor.get_absolute_url }}">{{ ancestor.title }}</a>
+      {% endfor %}
+      <a href="{{ fragment.book.get_absolute_url }}"><span>{{ book.title }}</span></a>
+    </div>
+  </div>
+
+  <main class="l-main">
+
+    <div class="l-section">
+      <div class="l-author__header">
+        <h1>
+          <span>Motyw:</span> {{ theme.name }}
+          <span>w utworze</span>
+          <a href="{{ book.get_absolute_url }}">{{ book }}</a>
+        </h1>
+      </div>
+    </div>
+
+    <!-- div class="l-section">
+         <div class="l-books__header">
+         <div class="l-books__input">
+         <i class="icon icon-filter"></i>
+         <input type="text" placeholder="filtry, tytuł">
+         </div>
+         <div class="l-books__sorting">
+         <span>Sortuj:</span>
+         <div>
+         <button>autorzy</button>
+         <button>epoki</button>
+         <button>gatunki</button>
+         <button>rodzaje</button>
+         <button class="is-active">motywy</button>
+         </div>
+         </div>
+         </div>
+         </div -->
+
+    {% autopaginate fragments 10 %}
+
+    <div class="l-section l-section--col">
+      <div class="l-theme">
+        <div class="l-theme__col">
+          <div class="l-books__col">
+
+            {% for fragment in fragments %}
+              {% include 'catalogue/2022/fragment_box.html' %}
+            {% endfor %}
+            {% paginate using '2022/paginate.html' %}
+          </div>
+        </div>
+        <div class="l-theme__col">
+          <div class="l-theme__info">
+            <h3>Motyw: {{ theme.name }}</h3>
+            {{ theme.description|safe }}
+            <!--
+                 <h3>Motyw w sztuce <i class="icon icon-arrow-left"></i> <i class="icon icon-arrow-right"></i></h3>
+                 <div class="l-theme__info__slider">
+                 <img src="images/motyw.jpg" alt="">
+                 <img src="images/motyw.jpg" alt="">
+                 <img src="images/motyw.jpg" alt="">
+                 </div>
+            -->
+          </div>
+        </div>
+      </div>
+    </div>
+  </main>
+
+{% endblock %}
index 2522ce6..7371976 100644 (file)
@@ -1,10 +1,27 @@
-<a class="l-author__quotes__slider__item" href="{{ fragment.get_absolute_url }}">
-  <em>
-    {% if fragment.short_text %}
+<article class="l-books__item">
+  <figure class="l-books__item__img">
+    <a href="{{ fragment.get_absolute_url }}">
+      {% if fragment.book.cover_clean %}
+        <img src="{{ fragment.book.cover_clean.url }}" alt="{{ fragment.book.title }}">
+      {% endif %}
+    </a>
+  </figure>
+  <div class="l-books__item__content">
+    <div class="l-books__item__actions">
+      <a href="{{ fragment.book.get_absolute_url }}" class="icon icon-book-alt"></a>
+      {% if fragment.book.has_mp3_file %}
+        <a href="{{ fragment.book.get_absolute_url }}" class="icon icon-audio"></a>
+      {% endif %}
+    </div>
+    <h3>
+      {% for author in fragment.book.authors %}
+        <a href="{{ author.get_absolute_url }}">{{ author }}</a>{% if not forloop.last %}, {% endif %}
+      {% endfor %}
+    </h3>
+    <h2><a href="{{ fragment.book.get_absolute_url }}">{{ fragment.book.title }}</a></h2>
+    <div class="fragment-text">
       {{ fragment.short_text|safe }}
-    {% else %}
-      {{ fragment.text|safe }}
-    {% endif %}
-  </em>
-  <p>{{ fragment.book.pretty_title }}</p>
-</a>
+    </div>
+    <a href="{{ fragment.get_absolute_url }}">Czytaj więcej</a>
+  </div>
+</article>
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 (file)
index 0000000..2522ce6
--- /dev/null
@@ -0,0 +1,10 @@
+<a class="l-author__quotes__slider__item" href="{{ fragment.get_absolute_url }}">
+  <em>
+    {% if fragment.short_text %}
+      {{ fragment.short_text|safe }}
+    {% else %}
+      {{ fragment.text|safe }}
+    {% endif %}
+  </em>
+  <p>{{ fragment.book.pretty_title }}</p>
+</a>
index 5713cec..29b0eeb 100644 (file)
           <div class="l-books__col">
 
             {% for fragment in object_list %}
-              <article class="l-books__item">
-                <figure class="l-books__item__img">
-                  <a href="{{ fragment.get_absolute_url }}">
-                    {% if fragment.book.cover_clean %}
-                      <img src="{{ fragment.book.cover_clean.url }}" alt="{{ fragment.book.title }}">
-                    {% endif %}
-                  </a>
-                </figure>
-                <div class="l-books__item__content">
-                  <div class="l-books__item__actions">
-                    <a href="#" class="icon icon-book-alt"></a>
-                    {% if fragment.book.has_mp3_file %}
-                      <a href="#" class="icon icon-audio"></a>
-                    {% endif %}
-                  </div>
-                  <h3>
-                    {% for author in fragment.book.authors %}
-                      <a href="{{ author.get_absolute_url }}">{{ author }}</a>{% if not forloop.last %}, {% endif %}
-                    {% endfor %}
-                  </h3>
-                  <h2><a href="{{ fragment.book.get_absolute_url }}">{{ fragment.book.title }}</a></h2>
-                  <div class="fragment-text">
-                    {{ fragment.short_text|safe }}
-                  </div>
-                  <a href="{{ fragment.get_absolute_url }}">Czytaj więcej</a>
-                </div>
-              </article>
+              {% include 'catalogue/2022/fragment_box.html' %}
             {% endfor %}
             {% paginate using '2022/paginate.html' %}
           </div>
index bb86b7a..935d232 100644 (file)
@@ -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 %}
   <h1>{% trans "All works" %}</h1>
-  <div class="normal-text catalogue-catalogue">
+  <div class="normal-text catalogue-catalogue l-container">
     <p>
       <a href="{% url 'reporting_catalogue_pdf' %}">
         {% trans "Download the catalogue in PDF format." %}
@@ -25,4 +25,4 @@
     <h2>{% trans "Art" %}</h2>
     {% plain_list pictures by_author=True paged=False initial_blocks=True %}
   </div>
-{% endblock %}
+{% endblock %}{% endblock %}
index a597f0b..b600936 100644 (file)
@@ -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 %}
   <h1>{% trans "Recent audiobooks" %}</h1>
 
-  <div id="books-list">
-    {% work_list object_list %}
-  </div>
-{% endblock %}
+  {% if request.EXPERIMENTS.layout %}
+    <div class="l-section l-section--col">
+      <div class="l-books__grid" id="book-list">
+        {% for book in object_list %}
+          {% include "catalogue/2022/book_box.html" %}
+        {% endfor %}
+      </div>
+    </div>
+  {% else %}
+    <div id="books-list">
+      {% work_list object_list %}
+    </div>
+  {% endif %}
+{% endblock %}{% endblock %}
index 2b0ab83..fe6be3b 100644 (file)
@@ -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 %}
   <h1>{% trans "Recent DAISY files" %}</h1>
 
-  <div id="books-list">
-    {% work_list object_list %}
-  </div>
-{% endblock %}
+  {% if request.EXPERIMENTS.layout %}
+    <div class="l-section l-section--col">
+      <div class="l-books__grid" id="book-list">
+        {% for book in object_list %}
+          {% include "catalogue/2022/book_box.html" %}
+        {% endfor %}
+      </div>
+    </div>
+  {% else %}
+    <div id="books-list">
+      {% work_list object_list %}
+    </div>
+  {% endif %}
+{% endblock %}{% endblock %}
index f0fadb3..f6b9172 100644 (file)
@@ -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 %}
   <h1>{% trans "Recent publications" %}</h1>
 
   {% url 'recent_audiobooks_list' as a %}
   {% url 'recent_daisy_list' as d %}
   <p class='normal-text'>
     {% blocktrans %}You can also see <a href="{{a}}">recent audiobooks</a>
-    and <a href="{{d}}">recent DAISY files</a>.{% endblocktrans %}
+      and <a href="{{d}}">recent DAISY files</a>.{% endblocktrans %}
   </p>
 
-  <div id="books-list">
-    {% work_list object_list %}
-  </div>
-{% endblock %}
+  {% if request.EXPERIMENTS.layout %}
+    <div class="l-section l-section--col">
+      <div class="l-books__grid" id="book-list">
+        {% for book in object_list %}
+          {% include "catalogue/2022/book_box.html" %}
+        {% endfor %}
+      </div>
+    </div>
+  {% else %}
+    <div id="books-list">
+      {% work_list object_list %}
+    </div>
+  {% endif %}
+{% endblock %}{% endblock %}
index f8eb6a4..7049b1c 100644 (file)
@@ -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/<slug:slug>.html', picture.views.picture_viewer, name='picture_viewer'),
     path('obraz/<slug:slug>/', 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/<slug:slug>/', 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/<slug:slug>/', views.CustomPDFFormView(), name='custom_pdf_form'),
index 2b188e6..b4e5920 100644 (file)
@@ -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,
index e926c92..09e6055 100644 (file)
@@ -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 @@
       <tr><td></td><td><button type="submit">Wyślij</button></td></tr>
     </table>
   </form>
-{% endblock %}
\ No newline at end of file
+{% endblock %}
index 44c29c3..3cf938a 100644 (file)
@@ -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 %}
   <h1>Wysłano powiadomienie</h1>
   <p>Gratulacje!</p>
-{% endblock %}
\ No newline at end of file
+{% endblock %}
index f2247fa..858c402 100644 (file)
@@ -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 (file)
index 0000000..be238bb
--- /dev/null
@@ -0,0 +1,20 @@
+{{ errors }}
+{% if errors and not fields %}
+  <p>{% for field in hidden_fields %}{{ field }}{% endfor %}</p>
+{% endif %}
+{% for field, errors in fields %}
+  {{ errors }}
+  <p{% with classes=field.css_classes %}{% if classes %} class="{{ classes }}"{% endif %}{% endwith %}>
+    {% if field.label %}{{ field.label_tag }}{% endif %}
+    {% if field.help_text %}
+    <br><span class="helptext">{{ field.help_text|safe }}</span>
+    {% endif %}
+    {{ field }}
+    {% if forloop.last %}
+      {% for field in hidden_fields %}{{ field }}{% endfor %}
+    {% endif %}
+  </p>
+{% endfor %}
+{% if not fields and not errors %}
+  {% for field in hidden_fields %}{{ field }}{% endfor %}
+{% endif %}