new covers
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 7 Jun 2022 10:54:01 +0000 (12:54 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 7 Jun 2022 10:54:01 +0000 (12:54 +0200)
requirements/requirements.txt
src/cover/views.py
src/documents/templates/documents/book_detail.html

index 0861384..a7a944e 100644 (file)
@@ -10,7 +10,7 @@ python-slugify
 python-docx==0.8.10
 Wikidata==0.6.1
 
-librarian==2.4.2
+librarian==2.4.3
 
 ## Django
 Django==3.2.12
index 620ad1a..660909d 100644 (file)
@@ -50,14 +50,15 @@ def preview(request, book, chunk=None, rev=None):
     width = int(width) if width else None
     height=request.GET.get('height')
     height = int(height) if height else None
-    cover = make_cover(info, width=width, height=height)
-    #cover = make_cover(info)
+
+    if not (height or width):
+        width, height = PREVIEW_SIZE
+
+    cover_class = request.GET.get('cover_class', 'default')
+
+    cover = make_cover(info, cover_class=cover_class, width=width, height=height)
     response = HttpResponse(content_type=cover.mime_type())
-    if height or width:
-        size = (width, height)
-    else:
-        size = PREVIEW_SIZE
-    img = cover.image().resize(size, Image.ANTIALIAS)
+    img = cover.final_image()
     img.save(response, cover.format)
 
     if 'download' in request.GET:
index 1c06f97..7737754 100644 (file)
   </div>
 <div class="card-body">
   <div class="row">
-<div class="col-lg-3">
-<img class="cover-preview" src="{% url 'cover_preview' book.slug %}" />
-{% if book.dc_cover_image %}
-  <a href="{{ book.dc_cover_image.get_absolute_url }}">{{ book.dc_cover_image }}</a>
-{% endif %}
-<br><br>
-
-<form action="{% url 'cover_quick_import' book.pk %}" method="post">
-  {% csrf_token %}
-  <input type="url" name="url">
-  <button type="submit" class="btn btn-sm btn-info">></button>
-</form>
-
-
-<br><br>
-<form action="{% url 'cover_preview' book.slug %}">
-<input type="hidden" name="download" value="1">
-Okładka w rozmiarze
-<input name="width" type="number" required value="600"> x <input name="height" type="number" required value="833">
-<button type="submit" class="btn btn-sm btn-primary">Pobierz</button>
-</form>
-</div>
-<div class="col-lg-9">
+    <div class="col-lg-3">
+      <img class="cover-preview" src="{% url 'cover_preview' book.slug %}" />
+      {% if book.dc_cover_image %}
+        <a href="{{ book.dc_cover_image.get_absolute_url }}">{{ book.dc_cover_image }}</a>
+      {% endif %}
+      <br><br>
+
+      <form action="{% url 'cover_quick_import' book.pk %}" method="post">
+        {% csrf_token %}
+        <div class="input-group">
+          <input type="url" name="url" class="form-control" placeholder="URL okładki">
+          <button type="submit" class="btn btn-sm btn-info">Ustaw</button>
+        </div>
+      </form>
+
+
+      <br><br>
+      <form action="{% url 'cover_preview' book.slug %}">
+        <input type="hidden" name="download" value="1">
+        Pobierz okładkę:
+        <div class="input-group">
+          <select class="form-control" name='cover_class'>
+            <option value="default">tradycyjna</option>
+            <option value="m">nowa</option>
+          </select><br>
+          <input class="form-control" name="width" type="number" required value="600" size="3" placeholder="szer.">
+          <input class="form-control" name="height" type="number" size="3" placeholder="wys.">
+          <button type="submit" class="btn btn-sm btn-primary">🡇</button>
+        </div>
+      </form>
+    </div>
+    <div class="col-lg-9">
 <p>{% trans "Last published" %}:
     {% if book.last_published %}
         {{ book.last_published }}