Cleanup
[wolnelektury.git] / src / search / templates / search / results.html
index c6ea383..dbcf1c0 100644 (file)
@@ -1,4 +1,4 @@
-{% extends "2022/base.html" %}
+{% extends "base.html" %}
 
 
 {% block main %}
       <button type="submit" class="c-form__hidden-submit">wyślij</button>
     </form>
 
+    {% if not hasresults %}
+      <p class="l-change-pop show">
+        Brak wyników.
+      </p>
+    {% endif %}
+
     {% if results.author %}
-    <div class="l-container">
-      <h2 class="header">Autorzy</h2>
-      <ul class="c-search-result c-search-result-author">
-        {% for tag in results.author %}
-          <li>
-            <a href="{{ tag.get_absolute_url }}">
-              {% if tag.photo %}
-                <figure>
-                  <img src="{{ tag.photo.url }}">
-                </figure>
-              {% endif %}
-              {{ tag.name }}
-            </a>
-          </li>
-        {% endfor %}
-      </ul>
-    </div>
+      <div class="l-container">
+        <h2 class="header">Autorzy</h2>
+        <ul class="c-search-result c-search-result-author">
+          {% for tag in results.author %}
+            <li>
+              <a href="{{ tag.get_absolute_url }}">
+                {% if tag.photo %}
+                  <figure>
+                    <img src="{{ tag.photo.url }}">
+                  </figure>
+                {% endif %}
+                {{ tag.name }}
+              </a>
+            </li>
+          {% endfor %}
+        </ul>
+      </div>
     {% endif %}
 
     {% if results.theme %}
       </div>
     {% endif %}
 
+    {% if results.genre %}
+      <div class="l-container">
+        <h2 class="header">Gatunki</h2>
+        <ul class="c-search-result">
+          {% for tag in results.genre %}
+            <li>
+              <a href="{{ tag.get_absolute_url }}">
+                {% if tag.photo %}
+                  <figure>
+                    <img src="{{ tag.photo.url }}">
+                  </figure>
+                {% endif %}
+                {{ tag.name }}
+              </a>
+            </li>
+          {% endfor %}
+        </ul>
+      </div>
+    {% endif %}
+
     {% if results.book %}
       <div class="l-container">
         <h2 class="header">Książki</h2>
       <div class="l-section l-section--col">
         <div class="l-books__grid">
           {% for book in results.book %}
-            {% include 'catalogue/2022/book_box.html' %}
+            {% include 'catalogue/book_box.html' %}
           {% endfor %}
         </div>
       </div>
       <div class="l-section l-section--col">
         <div class="l-books__grid">
           {% for book in results.art %}
-            {% include 'catalogue/2022/book_box.html' %}
+            {% include 'catalogue/book_box.html' %}
           {% endfor %}
         </div>
       </div>
     {% endif %}
 
-    {% if results.fragment or results.snippet %}
+    {% if results.snippet %}
       <div class="l-container">
         <h2 class="header">W treści</h2>
-        {% for f in results.snippet %}
+        {% for book, snippets in results.snippet.items %}
           <div class="c-search-result-fragment">
-            {% for author in f.book.authors %}
+            {% for author in book.authors %}
               <a class="c-search-result-fragment-author" href="{{ author.get_absolute_url }}">{{ author }}</a>
             {% endfor %}
-            <a class="c-search-result-fragment-title" href="{{ f.book.get_absolute_url }}">
-              {{ f.book.title }}
-            </a>
-            <a class="c-search-result-fragment-text" href='{% url 'book_text' f.book.slug %}#sec{{ f.sec }}'>
-              {{ f.headline|safe }}
+            <a class="c-search-result-fragment-title" href="{{ book.get_absolute_url }}">
+              {{ book.title }}
             </a>
+            {% for f in snippets %}
+              <a class="c-search-result-fragment-text" href='{% url 'book_text' f.book.slug %}#sec{{ f.sec }}'>
+                {{ f.headline|safe }}
+              </a>
+            {% endfor %}
           </div>
         {% endfor %}
       </div>
         <h2 class="header">Kolekcje</h2>
         <div class="c-search-result-collection">
           {% for collection in results.collection %}
-            {% include 'catalogue/2022/collection_box.html' %}
-            {% include 'catalogue/2022/collection_box.html' %}
+            {% include 'catalogue/collection_box.html' %}
           {% endfor %}
         </div>
       </div>
     {% endif %}
 
-    {% if pd_authors %}
+    {% if results.pdauthor or results.pdbook %}
       <div class="l-container">
         <div class="c-search-result-pd">
           <h2>Domena publiczna?</h2>
             Dowiedz się, dlaczego biblioteki internetowe nie mogą udostępniać dzieł tego autora.
           </p>
           <div>
-            {% for tag in pd_authors %}
+            {% for tag in results.pdauthor %}
               <div><a href="{{ tag.get_absolute_url }}">
                 <strong>{{ tag }}</strong>
-                Dzieła tego autora będą mogły być publikowane bez ograniczeń w&nbsp;roku&nbsp;<em>{{ tag.goes_to_pd }}</em>.
+                {% if tag.death  %}
+                  {% if tag.in_pd %}
+                    Dzieła tego autora są w&nbsp;domenie publicznej i&nbsp;czekają na publikację.
+                  {% else %}
+                    Dzieła tego autora będą mogły być publikowane bez ograniczeń w&nbsp;roku&nbsp;<em>{{ tag.goes_to_pd }}</em>.
+                  {% endif %}
+                {% else %}
+                  Dzieła tego autora są objęte prawem autorskim.
+                {% endif %}
+              </a></div>
+            {% endfor %}
+            {% for book in results.pdbook %}
+              <div><a href="{{ book.get_absolute_url }}">
+                <strong>{{ book }}</strong>
+                {% if book.pd  %}
+                  {% if book.in_pd %}
+                    Ten utwór jest w&nbsp;domenie publicznej i&nbsp;czeka na publikację.
+                  {% else %}
+                    Ten utwór będzie mógł być publikowany bez ograniczeń w&nbsp;roku&nbsp;<em>{{ book.pd }}</em>.
+                  {% endif %}
+                {% else %}
+                  Ten utwór nie jest jeszcze w domenie publicznej.
+                {% endif %}
               </a></div>
             {% endfor %}
           </div>