From: Radek Czajka Date: Wed, 21 Dec 2011 08:00:58 +0000 (+0100) Subject: new book.short_html, unfinished X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/7cf1f5926f871122e6e240432531ae942c4f9df1?ds=inline;hp=-c new book.short_html, unfinished --- 7cf1f5926f871122e6e240432531ae942c4f9df1 diff --git a/apps/catalogue/migrations/0021_build_covers.py b/apps/catalogue/migrations/0021_build_covers.py index 126417d5f..319decb18 100644 --- a/apps/catalogue/migrations/0021_build_covers.py +++ b/apps/catalogue/migrations/0021_build_covers.py @@ -10,15 +10,20 @@ class Migration(DataMigration): "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())) diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 6470ebb83..d615fb65b 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -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 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 @@ -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.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() @@ -504,22 +505,17 @@ class Book(models.Model): 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'%s' % (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'%s' % (reverse('book_text', args=[self.fileid()]), _('Read online'))) for ebook_format in self.ebook_formats: if self.has_media(ebook_format): formats.append(u'%s' % ( - 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'%s' % (m.file.url, m.type.upper())) formats = [mark_safe(format) for format in formats] @@ -532,7 +528,7 @@ class Book(models.Model): 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 diff --git a/wolnelektury/settings.py b/wolnelektury/settings.py index 40b45be04..b597e3347 100644 --- a/wolnelektury/settings.py +++ b/wolnelektury/settings.py @@ -156,7 +156,7 @@ INSTALLED_APPS = [ ] #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 @@ -171,6 +171,7 @@ COMPRESS_CSS = { 'css/main_page.css', 'css/dialogs.css', 'css/book_box.css', + 'css/catalogue.css', 'css/sponsors.css', ], 'output_filename': 'css/all.min?.css', diff --git a/wolnelektury/static/css/base.css b/wolnelektury/static/css/base.css index 067d9fd0d..35aed2ea8 100755 --- a/wolnelektury/static/css/base.css +++ b/wolnelektury/static/css/base.css @@ -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; diff --git a/wolnelektury/static/css/book_box.css b/wolnelektury/static/css/book_box.css index a959d849c..2faa1a2d8 100755 --- a/wolnelektury/static/css/book_box.css +++ b/wolnelektury/static/css/book_box.css @@ -1,11 +1,19 @@ -.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; @@ -19,12 +27,73 @@ 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; +} diff --git a/wolnelektury/static/css/catalogue.css b/wolnelektury/static/css/catalogue.css new file mode 100755 index 000000000..c971ca80b --- /dev/null +++ b/wolnelektury/static/css/catalogue.css @@ -0,0 +1,11 @@ +#books-list ol { + margin: 0; + padding: 0; + list-style: none; +} + +#books-list li { + display: inline-block; + margin: 0; + padding: 0; +} diff --git a/wolnelektury/static/css/header.css b/wolnelektury/static/css/header.css index abea73cc7..9e81463df 100755 --- a/wolnelektury/static/css/header.css +++ b/wolnelektury/static/css/header.css @@ -130,8 +130,10 @@ ul#catalogue a { #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; diff --git a/wolnelektury/static/fonts/WL-Nav.ttf b/wolnelektury/static/fonts/WL-Nav.ttf new file mode 100644 index 000000000..05282b866 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 index c79e3f1b2..000000000 Binary files a/wolnelektury/static/img/lang-arrow.png and /dev/null differ diff --git a/wolnelektury/templates/base.html b/wolnelektury/templates/base.html index 19c808a1e..534f5cfc1 100644 --- a/wolnelektury/templates/base.html +++ b/wolnelektury/templates/base.html @@ -7,8 +7,8 @@ - {% trans "Wolne Lektury" %} :: - {% block titleextra %}{% endblock %} + {% block title %}{% trans "Wolne Lektury" %} :: + {% block titleextra %}{% endblock %}{% endblock %} {% compressed_css "all" %} diff --git a/wolnelektury/templates/catalogue/book_mini_box.html b/wolnelektury/templates/catalogue/book_mini_box.html index 6728be84a..9b61283e7 100755 --- a/wolnelektury/templates/catalogue/book_mini_box.html +++ b/wolnelektury/templates/catalogue/book_mini_box.html @@ -1,4 +1,3 @@ -{% load i18n %} {% load thumbnail %}
@@ -9,7 +8,7 @@ {% empty %} {{ book.cover.url }} {% endthumbnail %} - " alt="{% trans "Book cover" %}" /> + " alt="Cover" /> {% endif %} {% for author in authors %}
{{ author }}
diff --git a/wolnelektury/templates/catalogue/book_short.html b/wolnelektury/templates/catalogue/book_short.html index aced8bf48..1b6466648 100644 --- a/wolnelektury/templates/catalogue/book_short.html +++ b/wolnelektury/templates/catalogue/book_short.html @@ -1,18 +1,71 @@ {% load i18n %} -
- - {% if book.children.all|length %} -
- {% else %} -
- {% endif %} -
-

{{ book.title }}

- {% if formats %} -

{% trans "Jump to" %}: {{ formats|join:", " }}

+{% load thumbnail %} +
+
+ + {% if book.cover %} + Cover {% endif %} -

{% trans "Categories" %}: {{ tags|join:", " }}

+
+
+
+
+ {% for author in tags.author %} + {{ author }} + {% endfor %} +
+
{{ book.title }}
+
+
+ {% spaceless %} + + {% trans "Epoch" %}:  + + {% for tag in tags.epoch %} + {{ tag.name }} + {% endfor %} + + + {% trans "Kind" %}:  + + {% for tag in tags.kind %} + {{ tag.name }} + {% endfor %} + + + {% trans "Genre" %}:  + + {% for tag in tags.genre %} + {{ tag.name }} + {% endfor %} + + + {% endspaceless %} +
-
\ No newline at end of file + +
+
diff --git a/wolnelektury/templates/catalogue/tagged_object_list.html b/wolnelektury/templates/catalogue/tagged_object_list.html index bff937463..7cae9ebed 100644 --- a/wolnelektury/templates/catalogue/tagged_object_list.html +++ b/wolnelektury/templates/catalogue/tagged_object_list.html @@ -88,6 +88,7 @@ {% endif %} {% if object_list %} + {% spaceless %}
    {% for book in object_list %}
  1. @@ -97,6 +98,7 @@ {{ book.short_html }}
  2. {% endfor %}
+ {% endspaceless %} {% paginate %} {% else %} {% trans "Sorry! Search cirteria did not match any resources." %}