new book.short_html, unfinished
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 21 Dec 2011 08:00:58 +0000 (09:00 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 21 Dec 2011 08:00:58 +0000 (09:00 +0100)
13 files changed:
apps/catalogue/migrations/0021_build_covers.py
apps/catalogue/models.py
wolnelektury/settings.py
wolnelektury/static/css/base.css
wolnelektury/static/css/book_box.css
wolnelektury/static/css/catalogue.css [new file with mode: 0755]
wolnelektury/static/css/header.css
wolnelektury/static/fonts/WL-Nav.ttf [new file with mode: 0644]
wolnelektury/static/img/lang-arrow.png [deleted file]
wolnelektury/templates/base.html
wolnelektury/templates/catalogue/book_mini_box.html
wolnelektury/templates/catalogue/book_short.html
wolnelektury/templates/catalogue/tagged_object_list.html

index 126417d..319decb 100644 (file)
@@ -10,15 +10,20 @@ class Migration(DataMigration):
         "Write your forwards methods here."
         from StringIO import StringIO
         from django.core.files.base import ContentFile
         "Write your forwards methods here."
         from StringIO import StringIO
         from django.core.files.base import ContentFile
+        from librarian import ValidationError
         from librarian.cover import WLCover
         from librarian.dcparser import BookInfo
 
         from librarian.cover import WLCover
         from librarian.dcparser import BookInfo
 
-        for book in orm.Book.objects.filter(cover=''):
-            book_info = BookInfo.from_file(book.xml_file.path)
-            cover = WLCover(book_info).image()
-            imgstr = StringIO()
-            cover.save(imgstr, 'png')
-            book.cover.save('book/png/%s.png' % book.slug,
+        for book in orm.Book.objects.filter(cover=None):
+            try:
+                book_info = BookInfo.from_file(book.xml_file.path)
+            except ValidationError:
+                pass
+            else:
+                cover = WLCover(book_info).image()
+                imgstr = StringIO()
+                cover.save(imgstr, 'png')
+                book.cover.save('book/png/%s.png' % book.slug,
                     ContentFile(imgstr.getvalue()))
 
 
                     ContentFile(imgstr.getvalue()))
 
 
index 6470ebb..d615fb6 100644 (file)
@@ -23,7 +23,7 @@ from django.conf import settings
 from newtagging.models import TagBase, tags_updated
 from newtagging import managers
 from catalogue.fields import JSONField, OverwritingFileField
 from newtagging.models import TagBase, tags_updated
 from newtagging import managers
 from catalogue.fields import JSONField, OverwritingFileField
-from catalogue.utils import create_zip
+from catalogue.utils import create_zip, split_tags
 from catalogue.tasks import touch_tag
 from shutil import copy
 from glob import glob
 from catalogue.tasks import touch_tag
 from shutil import copy
 from glob import glob
@@ -490,6 +490,7 @@ class Book(models.Model):
         cache_key = "Book.short_html/%d/%s"
         for lang, langname in settings.LANGUAGES:
             cache.delete(cache_key % (self.id, lang))
         cache_key = "Book.short_html/%d/%s"
         for lang, langname in settings.LANGUAGES:
             cache.delete(cache_key % (self.id, lang))
+        cache.delete(cache_key = "Book.mini_box/%d" % (self.id, ))
         # Fragment.short_html relies on book's tags, so reset it here too
         for fragm in self.fragments.all():
             fragm.reset_short_html()
         # Fragment.short_html relies on book's tags, so reset it here too
         for fragm in self.fragments.all():
             fragm.reset_short_html()
@@ -504,22 +505,17 @@ class Book(models.Model):
         if short_html is not None:
             return mark_safe(short_html)
         else:
         if short_html is not None:
             return mark_safe(short_html)
         else:
-            tags = self.tags.filter(~Q(category__in=('set', 'theme', 'book')))
-            tags = [mark_safe(u'<a href="%s">%s</a>' % (tag.get_absolute_url(), tag.name)) for tag in tags]
+            tags = self.tags.filter(category__in=('author', 'kind', 'genre', 'epoch'))
+            tags = split_tags(tags)
 
             formats = []
             # files generated during publication
 
             formats = []
             # files generated during publication
-            if self.has_media("html"):
-                formats.append(u'<a href="%s">%s</a>' % (reverse('book_text', args=[self.fileid()]), _('Read online')))
             for ebook_format in self.ebook_formats:
                 if self.has_media(ebook_format):
                     formats.append(u'<a href="%s">%s</a>' % (
             for ebook_format in self.ebook_formats:
                 if self.has_media(ebook_format):
                     formats.append(u'<a href="%s">%s</a>' % (
-                        self.get_media(ebook_format).url,
+                        "", #self.get_media(ebook_format).url,
                         ebook_format.upper()
                     ))
                         ebook_format.upper()
                     ))
-            # other files
-            for m in self.media.order_by('type'):
-                formats.append(u'<a href="%s">%s</a>' % (m.file.url, m.type.upper()))
 
             formats = [mark_safe(format) for format in formats]
 
 
             formats = [mark_safe(format) for format in formats]
 
@@ -532,7 +528,7 @@ class Book(models.Model):
 
     def mini_box(self):
         if self.id:
 
     def mini_box(self):
         if self.id:
-            cache_key = "Book.mini_boxs/%d" % (self.id, )
+            cache_key = "Book.mini_box/%d" % (self.id, )
             short_html = cache.get(cache_key)
         else:
             short_html = None
             short_html = cache.get(cache_key)
         else:
             short_html = None
index 40b45be..b597e33 100644 (file)
@@ -156,7 +156,7 @@ INSTALLED_APPS = [
 ]
 
 #CACHE_BACKEND = 'locmem:///?max_entries=3000'
 ]
 
 #CACHE_BACKEND = 'locmem:///?max_entries=3000'
-CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
+#CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
 CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True
 
 # CSS and JavaScript file groups
 CACHE_MIDDLEWARE_ANONYMOUS_ONLY=True
 
 # CSS and JavaScript file groups
@@ -171,6 +171,7 @@ COMPRESS_CSS = {
             'css/main_page.css',
             'css/dialogs.css',
             'css/book_box.css',
             'css/main_page.css',
             'css/dialogs.css',
             'css/book_box.css',
+            'css/catalogue.css',
             'css/sponsors.css',
         ],
         'output_filename': 'css/all.min?.css',
             'css/sponsors.css',
         ],
         'output_filename': 'css/all.min?.css',
index 067d9fd..35aed2e 100755 (executable)
@@ -1,3 +1,15 @@
+/* Logo font */
+@font-face {
+    /* IE version */
+    font-family: WL-Logo;
+    src: url(/static/fonts/WL.eot);
+}
+@font-face {
+  font-family: WL-Nav;
+  src: url(/static/fonts/WL-Nav.ttf) format("truetype");
+}
+
+
 html {
     margin: 0;
     padding: 0;
 html {
     margin: 0;
     padding: 0;
index a959d84..2faa1a2 100755 (executable)
@@ -1,11 +1,19 @@
-.book-mini-box {
+.book-mini-box, .book-box {
     display: inline-block;
     margin: 0;
     display: inline-block;
     margin: 0;
-    width: 12.5em;
     vertical-align: top;
 }
 
     vertical-align: top;
 }
 
-.book-mini-box a {
+
+.book-box {
+    width: 37.5em;
+}
+
+.book-mini-box {
+    width: 12.5em;
+}
+
+.book-mini-box a, .book-box-inner {
     display: block;
     color: black;
     border: 1px solid #ddd;
     display: block;
     color: black;
     border: 1px solid #ddd;
     overflow: hidden;
 }
 
     overflow: hidden;
 }
 
-.book-mini-box img {
+.book-mini-box a {
+    height: 20em;
+    margin: .1em;
+}
+.book-box-inner {
+    height: 14.4em;
+    margin: .5em;
+}
+
+.book-mini-box img, .book-box img {
     width: 10.8em;
     height: 14.4em;
     width: 10.8em;
     height: 14.4em;
+}
+.book-mini-box img {
     margin-bottom: .3em;
 }
     margin-bottom: .3em;
 }
+.book-box img {
+    float: left;
+    margin-right: 1.5em;
+}
 
 .book-mini-box .author {
     color: #777;
 
 .book-mini-box .author {
     color: #777;
-}
\ No newline at end of file
+}
+
+
+.book-box-body {
+    height: 13em;
+    overflow: hidden;
+}
+.book-box-head {
+    min-height: 7em;
+}
+.book-box-tag {
+    font-size: .8em;
+    margin-right: .5em;
+}
+.book-box-download {
+    position: relative;
+}
+.book-box-formats {
+    display: none;
+    top: -2em;
+    position: absolute;
+    height: 2em;
+    width: 100em;
+}
+.book-box-formats a {
+    margin-right: 1em;
+}
+.book-box-download:hover .book-box-formats {
+    display: block;
+}
+
+.book-box-tools a:before {
+    content: "⇩";
+    font-family: WL-Nav;
+    font-size: 2em;
+    margin-right: .25em;
+    vertical-align: middle;
+}
+.book-box-read {
+    width: 10em;
+}
+.book-box-download {
+    width: 6em;
+}
+.book-box-audiobook {
+    width: 6em;
+}
diff --git a/wolnelektury/static/css/catalogue.css b/wolnelektury/static/css/catalogue.css
new file mode 100755 (executable)
index 0000000..c971ca8
--- /dev/null
@@ -0,0 +1,11 @@
+#books-list ol {
+    margin: 0;
+    padding: 0;
+    list-style: none;
+}
+
+#books-list li {
+    display: inline-block;
+    margin: 0;
+    padding: 0;
+}
index abea73c..9e81463 100755 (executable)
@@ -130,8 +130,10 @@ ul#catalogue a {
 
 
 #lang-button:after {
 
 
 #lang-button:after {
-    content: url(/static/img/lang-arrow.png);
     padding-left: .5em;
     padding-left: .5em;
+    content: "↓";
+    font-family: WL-Nav;
+    vertical-align: middle;
 }
 #lang-menu {
     position: relative;
 }
 #lang-menu {
     position: relative;
diff --git a/wolnelektury/static/fonts/WL-Nav.ttf b/wolnelektury/static/fonts/WL-Nav.ttf
new file mode 100644 (file)
index 0000000..05282b8
Binary files /dev/null and b/wolnelektury/static/fonts/WL-Nav.ttf differ
diff --git a/wolnelektury/static/img/lang-arrow.png b/wolnelektury/static/img/lang-arrow.png
deleted file mode 100644 (file)
index c79e3f1..0000000
Binary files a/wolnelektury/static/img/lang-arrow.png and /dev/null differ
index 19c808a..534f5cf 100644 (file)
@@ -7,8 +7,8 @@
         <meta http-equiv="Content-Style-Type" content="text/css" />
         <meta name="description" 
             content="{% block metadescription %}Darmowe opracowane, pełne teksty lektur, e-booki, audiobooki i pliki DAISY na wolnej licencji.{% endblock %}" />
         <meta http-equiv="Content-Style-Type" content="text/css" />
         <meta name="description" 
             content="{% block metadescription %}Darmowe opracowane, pełne teksty lektur, e-booki, audiobooki i pliki DAISY na wolnej licencji.{% endblock %}" />
-        <title>{% trans "Wolne Lektury" %} :: 
-            {% block titleextra %}{% endblock %}</title>
+        <title>{% block title %}{% trans "Wolne Lektury" %} :: 
+            {% block titleextra %}{% endblock %}{% endblock %}</title>
         <link rel="icon" href="{{ STATIC_URL }}img/favicon.png" type="image/png" />
         <link rel="search" type="application/opensearchdescription+xml" title="Wolne Lektury" href="{{ STATIC_URL }}opensearch.xml" />
         {% compressed_css "all" %}
         <link rel="icon" href="{{ STATIC_URL }}img/favicon.png" type="image/png" />
         <link rel="search" type="application/opensearchdescription+xml" title="Wolne Lektury" href="{{ STATIC_URL }}opensearch.xml" />
         {% compressed_css "all" %}
index 6728be8..9b61283 100755 (executable)
@@ -1,4 +1,3 @@
-{% load i18n %}
 {% load thumbnail %}
 <div class="book-mini-box">
     <a href="{{ book.get_absolute_url }}">
 {% load thumbnail %}
 <div class="book-mini-box">
     <a href="{{ book.get_absolute_url }}">
@@ -9,7 +8,7 @@
                 {% empty %}
                     {{ book.cover.url }}
                 {% endthumbnail %}
                 {% empty %}
                     {{ book.cover.url }}
                 {% endthumbnail %}
-            " alt="{% trans "Book cover" %}" />
+            " alt="Cover" />
         {% endif %}
         {% for author in authors %}
             <div class="mono author">{{ author }}</div>
         {% endif %}
         {% for author in authors %}
             <div class="mono author">{{ author }}</div>
index aced8bf..1b64666 100644 (file)
@@ -1,18 +1,71 @@
 {% load i18n %}
 {% load i18n %}
-<div class="book">
-    <div class="change-sets">
-        <a href="{% url catalogue.views.book_sets book.urlid %}" class="jqm-trigger">{% trans "Put on the shelf!" %}</a>
-    </div>
-    {% if book.children.all|length %}
-        <div class="book-parent-thumbnail"></div>
-    {% else %}
-        <div class="book-thumbnail"></div>
-    {% endif %}
-    <div class="book-description">
-        <h2><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></h2>
-        {% if formats %}
-            <p style="margin: 0">{% trans "Jump to" %}: {{ formats|join:", " }}</p>
+{% load thumbnail %}
+<div class="book-box">
+<div class="book-box-inner">
+    <a href="{{ book.get_absolute_url }}">
+        {% if book.cover %}
+            <img src="
+                {% thumbnail book.cover "216x288" as thumb %}
+                    {{ thumb.url }}
+                {% empty %}
+                    {{ book.cover.url }}
+                {% endthumbnail %}
+            " alt="Cover" />
         {% endif %}
         {% endif %}
-        <p style="margin: 0">{% trans "Categories" %}: {{ tags|join:", " }}</p>
+    </a>
+    <div class="book-box-body">
+        <div class="book-box-head">
+            <div class="mono author">
+            {% for author in tags.author %}
+                {{ author }}
+            {% endfor %}
+            </div>
+            <div class="title">{{ book.title }}</div>
+        </div>
+        <div class="tags">
+            {% spaceless %}
+
+            <span class="mono">{% trans "Epoch" %}:&nbsp;</span>
+            <span class="book-box-tag">
+                {% for tag in tags.epoch %}
+                    <a href="{{ tag.get_absolute_url }}">{{ tag.name }} </a>
+                {% endfor %}
+            </span>
+
+            <span class="mono">{% trans "Kind" %}:&nbsp;</span>
+            <span class="book-box-tag">
+                {% for tag in tags.kind %}
+                    <a href="{{ tag.get_absolute_url }}">{{ tag.name }} </a>
+                {% endfor %}
+            </span>
+
+            <span class="mono">{% trans "Genre" %}:&nbsp;</span>
+            <span class="book-box-tag">
+                {% for tag in tags.genre %}
+                    <a href="{{ tag.get_absolute_url }}">{{ tag.name }} </a>
+                {% endfor %}
+            </span>
+
+            {% endspaceless %}
+        </div>
     </div>
     </div>
-</div>
\ No newline at end of file
+    <ul class="book-box-tools">
+        <li class="book-box-read">
+        {% if book.html_file %}
+            <a href="" class="mono">{% trans "Read online" %}</a>
+        {% endif %}
+        </li>
+        <li class="book-box-download">
+            <a class="mono">{% trans "Download" %}</a>
+            <div class="book-box-formats mono">
+                {{ formats|join:"" }}
+            </div>
+        </li>
+        <li class="book-box-audiobook">
+        {% if book.has_mp3_file %}
+            <a href="" class="mono">{% trans "Audiobook" %}</a>
+        {% endif %}
+        </li>
+    </ul>
+</div>
+</div>
index bff9374..7cae9eb 100644 (file)
@@ -88,6 +88,7 @@
         {% endif %}
 
         {% if object_list %}
         {% endif %}
 
         {% if object_list %}
+            {% spaceless %}
             <ol>
             {% for book in object_list %}
                 <li>
             <ol>
             {% for book in object_list %}
                 <li>
@@ -97,6 +98,7 @@
                     {{ book.short_html }}</li>
             {% endfor %}
             </ol>
                     {{ book.short_html }}</li>
             {% endfor %}
             </ol>
+            {% endspaceless %}
             {% paginate %}
         {% else %}
             {% trans "Sorry! Search cirteria did not match any resources." %}
             {% paginate %}
         {% else %}
             {% trans "Sorry! Search cirteria did not match any resources." %}