Minor visuals.
[wolnelektury.git] / src / catalogue / templates / catalogue / book_short.html
index af4dc82..25c1309 100644 (file)
 {% spaceless %}
-{% load i18n %}
-{% load catalogue_tags %}
-{% load book_shelf_tags from social_tags %}
-<div class="{% block box-class %}book-box{% if audiobooks %} audiobook-box{% endif %}{% endblock %}">
-<div class="book-box-inner">
+  {% load i18n %}
+  {% load cache %}
+  {% load catalogue_tags %}
+  {% load book_shelf_tags from social_tags %}
+  {% load static %}
 
-{% block book-box-pre %}
-    {% include "catalogue/snippets/like_button.html" %}
-{% endblock %}
+  {% with ga=book.get_audiobooks %}
+  {% with audiobooks=ga.0 %}
+  <div class="{% block box-class %}book-box{% if audiobooks %} audiobook-box{% endif %}{% endblock %}">
+    <div class="book-box-inner">
 
-<div class="book-left-column">
+    {% block book-box-pre %}
+      {% include "catalogue/snippets/like_button.html" %}
+    {% endblock %}
 
-    <div class="book-box-body">
+    {% with book.tags_by_category as tags %}
+    <div class="book-left-column">
+      <div class="book-box-body">
         {% block book-box-body-pre %}
         {% endblock %}
 
-        <div class="book-box-head">
-            <div class="author">
-                {% for tag in tags.author %}
-                    <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>{% if not forloop.last %},
-                {% endif %}{% endfor %}{% for parent in parents %},
-                    <a href="{{ parent.get_absolute_url }}">{{ parent.title }}</a>{% endfor %}
-            </div>
-            <div class="title">
-                {% if main_link %}<a href="{{ main_link }}">{% endif %}{{ book.title }}{% if main_link %}</a>{% endif %}
-            </div>
+        <div class="cover-area">
+          {% if book.cover_thumb %}
+            <a href="{% block cover-link %}{{ book.get_absolute_url }}{% endblock %}">
+              <img src="{{ book.cover_thumb.url }}" alt="Cover" class="cover" />
+            </a>
+          {% endif %}
+          {% block cover-area-extra %}{% endblock %}
         </div>
 
-        <div class="cover-area">
-            {% if book.cover_thumb %}
-                {% if main_link %}<a href="{{ main_link }}">{% endif %}
-                    <img src="{{ book.cover_thumb.url }}" alt="Cover" class="cover" />
-                {% if main_link %}</a>{% endif %}
-            {% endif %}
-            {% block cover-area-extra %}{% endblock %}
+        {% get_current_language as LANGUAGE_CODE %}
+        {% cache 86400 book_box_head_tags book.pk LANGUAGE_CODE %}
+        <div class="book-box-head">
+          <div class="author">
+            {% for tag in tags.author %}
+              <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>{% if not forloop.last %},
+            {% endif %}{% endfor %}{% for parent in book.parents %},
+              <a href="{{ parent.get_absolute_url }}">{{ parent.title }}</a>{% endfor %}
+          </div>
+          <div class="title">
+            <a href="{{ book.get_absolute_url }}">{{ book.title }}</a>
+          </div>
+          {% if book.translator %}
+              <div class="author">
+                  tłum. {{ book.translator }}
+              </div>
+          {% endif %}
         </div>
 
         <div class="tags">
-            {% spaceless %}
+          <span class="category">
+          <span class="mono"> {% trans "Epoch" %}:</span>&nbsp;<span class="book-box-tag">
+            {% for tag in tags.epoch %}
+              <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
+              {% if not forloop.last %}<span>, </span>{% endif %}
+            {% endfor %}
+          </span></span>
 
-            <span class="category">
-            <span class="mono"> {% trans "Epoch" %}:</span>&nbsp;<span class="book-box-tag">
-                {% for tag in tags.epoch %}
-                    <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
-                    {% if not forloop.last %}<span>, </span>{% endif %}
-                {% endfor %}
-            </span></span>
+          <span class="category">
+          <span class="mono"> {% trans "Kind" %}:</span>&nbsp;<span class="book-box-tag">
+            {% for tag in tags.kind %}
+              <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
+              {% if not forloop.last %}<span>, </span>{% endif %}
+            {% endfor %}
+          </span></span>
 
-            <span class="category">
-            <span class="mono"> {% trans "Kind" %}:</span>&nbsp;<span class="book-box-tag">
-                {% for tag in tags.kind %}
-                    <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
-                    {% if not forloop.last %}<span>, </span>{% endif %}
-                {% endfor %}
-            </span></span>
+          <span class="category">
+          <span class="mono"> {% trans "Genre" %}:</span>&nbsp;<span class="book-box-tag">
+            {% for tag in tags.genre %}
+              <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
+              {% if not forloop.last %}<span>, </span>{% endif %}
+            {% endfor %}
+          </span></span>
 
-            <span class="category">
-            <span class="mono"> {% trans "Genre" %}:</span>&nbsp;<span class="book-box-tag">
-                {% for tag in tags.genre %}
-                    <a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a>
-                    {% if not forloop.last %}<span>, </span>{% endif %}
-                {% endfor %}
-            </span></span>
+         {% with extra_info=book.get_extra_info_json %}
+            {% if extra_info.location %}
+              <span class="category">
+              <span class="mono"> {% trans "Region" %}:</span>&nbsp;<span class="book-box-tag">
+                  {{ extra_info.location }}
+              </span></span>
+            {% endif %}
+         {% endwith %}
 
-            {% if show_lang %}
+          {% if book.is_foreign %}
             <span class="category">
-            <span class="mono"> {% trans "Language" %}:</span>&nbsp;<span class="book-box-tag">
+              <span class="mono"> {% trans "Language" %}:</span>&nbsp;<span class="book-box-tag">
                 <a>{{ book.language_name }}</a>
-            </span></span>
-            {% endif %}
-
-            {% if stage_note %}
-            <br><span class="category">
-                <a{% if stage_note_url %} href="{{ stage_note_url }}"{% endif %}>{{ stage_note }}</a>
+              </span>
             </span>
-            {% endif %}
+          {% endif %}
 
-           {% endspaceless %}
+          {% with stage_note=book.stage_note %}
+          {% if stage_note.0 %}
+            <br>
+            <span class="category">
+              <a{% if stage_note.1 %} href="{{ stage_note.1 }}"{% endif %}>{{ stage_note.0 }}</a>
+            </span>
+          {% endif %}
+          {% endwith %}
         </div>
-    </div>
-    {% book_shelf_tags book.pk %}
+        {% endcache %}
+      </div>
+      {% book_shelf_tags book.pk %}
 
-    <ul class="book-box-tools">
-        <li class="book-box-read">
-        {% if book.html_file %}
-            <a href="{% url 'book_text' book.slug %}" class="downarrow">{% trans "Read online" %}</a>
-        {% endif %}
-        </li>
-        <li class="book-box-download">
-            <a class="downarrow">{% trans "Download" %}: </a>
+      {% cache 86400 book_box_tools book.pk book|status:request.user LANGUAGE_CODE %}
+      {% if book|status:request.user != 'closed' %}
+        <ul class="book-box-tools">
+          <li class="book-box-read">
+            {% if book.html_file %}
+           <div>{% content_warning book %}</div>
+              <a href="{% url 'book_text' book.slug %}" class="downarrow">{% trans "Read online" %}</a>
+            {% endif %}
+            {% if book.print_on_demand %}
+              <a href="{{ book.ridero_link }}" class="downarrow print tlite-tooltip" title="{% trans "Cena książki w druku cyfrowym jest zależna od liczby stron.<br>Przed zakupem upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia.<br>Wszystkie nasze zasoby w wersji elektronicznej są zawsze dostępne bezpłatnie." %}">{% trans "Print on demand –" %}
+                  <img src="{% static 'img/ridero.png' %}" style="height: 0.8em;"/></a>
+            {% endif %}
+          </li>
+          <li class="book-box-download">
             <div class="book-box-formats">
-             {% if book.pdf_file %}
-             <span><a href="{{ book.pdf_file.url}}">PDF</a></span>
-             {% endif %}
-             {% custom_pdf_link_li book %}
-             {% if book.epub_file %}
-             <span><a href="{{ book.epub_file.url}}">EPUB</a></span>
-             {% endif %}
-             {% if book.mobi_file %}
-             <span><a href="{{ book.mobi_file.url}}">MOBI</a></span>
-             {% endif %}
-             {% if  book.fb2_file %}
-             <span><a href="{{ book.fb2_file.url}}">FB2</a></span>
-             {% endif %}
-             {% if  book.txt_file %}
-             <span><a href="{{ book.txt_file.url}}">TXT</a></span>
-             {% endif %}
-             {% download_audio book %}
+              {% trans "Download an ebook" %}:<br>
+              {% if book.pdf_file %}
+                <a href="{{ book.pdf_url}}">PDF</a>
+              {% endif %}
+              {% if book.epub_file %}
+                <a href="{{ book.epub_url}}">EPUB</a>
+              {% endif %}
+              {% if book.mobi_file %}
+                <a href="{{ book.mobi_url}}">MOBI</a>
+              {% endif %}
+              {% if  book.fb2_file %}
+                <a href="{{ book.fb2_url}}">FB2</a>
+              {% endif %}
+              {% if  book.txt_file %}
+                <a href="{{ book.txt_url}}">TXT</a>
+              {% endif %}
             </div>
-        </li>
-    </ul>
-    {% block book-box-extra-info %}{% endblock %}
-    {% block box-append %}
-    {% endblock %}
-</div>
+            {% if book.has_mp3_file %}
+              <div class="book-box-formats">
+                {% trans "Download audiobook" %}:<br>
+                {% download_audio book %}
+              </div>
+            {% endif %}
+            <div class="book-box-formats">
+                {% custom_pdf_link_li book %}
+            </div>
+          </li>
+        </ul>
+      {% else %}
+        {% block preview-info %}
+          <p class="book-box-tools book-box-tools-warn">
+            {% trans "For now this work is only available for our subscribers." %}
+           <a href="/towarzystwo/">Dołącz do Towarzystwa Przyjaciół Wolnych Lektur</a>
+         </p>
+          <div>{% content_warning book %}</div>
+        {% endblock %}
+      {% endif %}
+      {% endcache %}
+      {% block book-box-extra-info %}{% endblock %}
+      {% block box-append %}{% endblock %}
+    </div>
+    {% endwith %}
 
-{% block right-column %}
-    {% if audiobooks %}
-        <div class="right-column">
-            {% include 'catalogue/snippets/jplayer.html' %}
+    {% block right-column %}
+      {% if audiobooks %}{% if book|status:request.user != 'closed' %}
+        <div class="book-right-column">
+          {% include 'catalogue/snippets/jplayer.html' %}
         </div>
+      {% endif %}{% endif %}
+    {% endblock %}
+    {% if book.abstract %}
+      <div class="abstract more-expand">
+        {{ book.abstract|safe }}
+      </div>
     {% endif %}
-{% endblock %}
 
-<div class="clearboth"></div>
-</div>
-</div>
+    <div class="clearboth"></div>
+    </div>
+  </div>
+  {% endwith %}
+  {% endwith %}
 {% endspaceless %}