"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
- 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()))
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
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()
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
- 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>' % (
- self.get_media(ebook_format).url,
+ "", #self.get_media(ebook_format).url,
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]
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
]
#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
'css/main_page.css',
'css/dialogs.css',
'css/book_box.css',
+ 'css/catalogue.css',
'css/sponsors.css',
],
'output_filename': 'css/all.min?.css',
+/* 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;
-.book-mini-box {
+.book-mini-box, .book-box {
display: inline-block;
margin: 0;
- width: 12.5em;
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;
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;
+}
+.book-mini-box img {
margin-bottom: .3em;
}
+.book-box img {
+ float: left;
+ margin-right: 1.5em;
+}
.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;
+}
--- /dev/null
+#books-list ol {
+ margin: 0;
+ padding: 0;
+ list-style: none;
+}
+
+#books-list li {
+ display: inline-block;
+ margin: 0;
+ padding: 0;
+}
#lang-button:after {
- content: url(/static/img/lang-arrow.png);
padding-left: .5em;
+ content: "↓";
+ font-family: WL-Nav;
+ vertical-align: middle;
}
#lang-menu {
position: relative;
<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" %}
-{% load i18n %}
{% load thumbnail %}
<div class="book-mini-box">
<a href="{{ book.get_absolute_url }}">
{% empty %}
{{ book.cover.url }}
{% endthumbnail %}
- " alt="{% trans "Book cover" %}" />
+ " alt="Cover" />
{% endif %}
{% for author in authors %}
<div class="mono author">{{ author }}</div>
{% 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 %}
- <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" %}: </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" %}: </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" %}: </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>
\ 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>
{% endif %}
{% if object_list %}
+ {% spaceless %}
<ol>
{% for book in object_list %}
<li>
{{ book.short_html }}</li>
{% endfor %}
</ol>
+ {% endspaceless %}
{% paginate %}
{% else %}
{% trans "Sorry! Search cirteria did not match any resources." %}