From 57a20265fc4e83cdaa26d8c05af2e4d9a77afea0 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 12 Jun 2012 11:54:40 +0200 Subject: [PATCH] closes #2165: license icon on book page --- apps/catalogue/constants.py | 12 + .../templates/catalogue/book_mini_box.html | 2 +- .../templates/catalogue/book_short.html | 17 +- .../templates/catalogue/book_wide.html | 10 +- .../catalogue/snippets/license_icon.html | 10 + apps/catalogue/templatetags/catalogue_tags.py | 14 + apps/reporting/templates/reporting/main.html | 10 + apps/reporting/views.py | 3 + .../wolnelektury_core/static/css/book_box.css | 16 +- .../static/img/licenses/cc-by-sa.png | Bin 0 -> 2829 bytes .../static/img/licenses/cc-by-sa.svg | 469 ++++++++++++++++++ 11 files changed, 552 insertions(+), 11 deletions(-) create mode 100755 apps/catalogue/constants.py create mode 100755 apps/catalogue/templates/catalogue/snippets/license_icon.html create mode 100644 apps/wolnelektury_core/static/img/licenses/cc-by-sa.png create mode 100644 apps/wolnelektury_core/static/img/licenses/cc-by-sa.svg diff --git a/apps/catalogue/constants.py b/apps/catalogue/constants.py new file mode 100755 index 000000000..e1c92f8cd --- /dev/null +++ b/apps/catalogue/constants.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# +from django.utils.translation import ugettext_lazy as _ + +LICENSES = { + 'http://creativecommons.org/licenses/by-sa/3.0/': { + 'icon': 'cc-by-sa', + 'description': _('Creative Commons Attribution-ShareAlike 3.0 Unported'), + }, +} diff --git a/apps/catalogue/templates/catalogue/book_mini_box.html b/apps/catalogue/templates/catalogue/book_mini_box.html index 830c08e27..731a8d334 100755 --- a/apps/catalogue/templates/catalogue/book_mini_box.html +++ b/apps/catalogue/templates/catalogue/book_mini_box.html @@ -8,7 +8,7 @@ {% empty %} {{ book.cover.url }} {% endthumbnail %} - " alt="Cover" /> + " alt="Cover" class="cover" /> {% endif %}
diff --git a/apps/catalogue/templates/catalogue/book_short.html b/apps/catalogue/templates/catalogue/book_short.html index 6942bc499..f0d0ca502 100644 --- a/apps/catalogue/templates/catalogue/book_short.html +++ b/apps/catalogue/templates/catalogue/book_short.html @@ -5,18 +5,23 @@
- {% if main_link %}{% endif %} - {% if book.cover %} +
+ {% if book.cover %} + {% if main_link %}{% endif %} Cover - {% endif %} - {% if main_link %}{% endif %} -
+ " alt="Cover" class="cover" /> + {% if main_link %}{% endif %} + {% endif %} + {% block cover-area-extra %}{% endblock %} +
+ + +
diff --git a/apps/catalogue/templates/catalogue/book_wide.html b/apps/catalogue/templates/catalogue/book_wide.html index 8d8341385..0e5201977 100644 --- a/apps/catalogue/templates/catalogue/book_wide.html +++ b/apps/catalogue/templates/catalogue/book_wide.html @@ -1,12 +1,20 @@ {% extends "catalogue/book_short.html" %} {% load i18n %} -{% load download_audio tag_list custom_pdf_link_li from catalogue_tags %} +{% load download_audio tag_list custom_pdf_link_li license_icon from catalogue_tags %} {% load cite_promo from social_tags %} {% block box-class %}book-wide-box{% endblock %} +{% block cover-area-extra %} +{% if extra_info.license %} + {% license_icon extra_info.license %} +{% endif %} +{% endblock %} + + + {% block book-box-extra-info %} {% if themes %}
diff --git a/apps/catalogue/templates/catalogue/snippets/license_icon.html b/apps/catalogue/templates/catalogue/snippets/license_icon.html new file mode 100755 index 000000000..732e3bf92 --- /dev/null +++ b/apps/catalogue/templates/catalogue/snippets/license_icon.html @@ -0,0 +1,10 @@ +{% load i18n %} +{% load static from staticfiles %} + +{% if license_url %} + + {% trans + +{% endif %} diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index 139aa54ce..ad60962c5 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -15,6 +15,7 @@ from django.utils.translation import ugettext as _ from catalogue.utils import split_tags from catalogue.models import Book, BookMedia, Fragment, Tag +from catalogue.constants import LICENSES register = template.Library() @@ -436,3 +437,16 @@ def custom_pdf_link_li(book): 'book': book, 'NO_CUSTOM_PDF': settings.NO_CUSTOM_PDF, } + + +@register.inclusion_tag("catalogue/snippets/license_icon.html") +def license_icon(license_url): + """Creates a license icon, if the license_url is known.""" + known = LICENSES.get(license_url) + if known is None: + return {} + return { + "license_url": license_url, + "icon": "img/licenses/%s.png" % known['icon'], + "license_description": known['description'], + } diff --git a/apps/reporting/templates/reporting/main.html b/apps/reporting/templates/reporting/main.html index 485610dd7..46d49c9ea 100755 --- a/apps/reporting/templates/reporting/main.html +++ b/apps/reporting/templates/reporting/main.html @@ -12,6 +12,8 @@
+

Audiobooki

+ @@ -33,6 +35,14 @@ {% endfor %}
Utwory
Utwory:{% count_books %}
+

Licencje

+
    + {% for license, license_description in licenses %} +
  • {{ license }} ({{ license_description }})
  • + {% endfor %} +
+ +
{% endblock %} diff --git a/apps/reporting/views.py b/apps/reporting/views.py index 961a682a1..a23252ec2 100644 --- a/apps/reporting/views.py +++ b/apps/reporting/views.py @@ -30,6 +30,9 @@ def stats_page(request): else: mt['deprecated'] = '-' + licenses = set(((b.extra_info.get('license'), b.extra_info.get('license_description')) + for b in Book.objects.all().iterator() if b.extra_info.get('license'))) + return render_to_response('reporting/main.html', locals(), context_instance=RequestContext(request)) diff --git a/apps/wolnelektury_core/static/css/book_box.css b/apps/wolnelektury_core/static/css/book_box.css index e23847fb1..74b710aff 100755 --- a/apps/wolnelektury_core/static/css/book_box.css +++ b/apps/wolnelektury_core/static/css/book_box.css @@ -88,14 +88,19 @@ } */ -.book-mini-box img, .book-box img, .book-wide-box img, .search-result img { +.book-mini-box img.cover, +.book-box img.cover, +.book-wide-box img.cover, +.search-result img.cover { width: 13.9em; height: 19.3em; } -.book-mini-box img { +.book-mini-box img.cover { margin-bottom: 1.8em; } -.book-box-inner img, .book-wide-box img { +.book-box-inner .cover-area, +.book-wide-box .cover-area +{ float: left; margin-right: 1.5em; } @@ -283,6 +288,11 @@ ul.inline-items li { } +.book-wide-box .license-icon { + display:block; + margin-top: .5em +} + .star { font-size: 2.25em; diff --git a/apps/wolnelektury_core/static/img/licenses/cc-by-sa.png b/apps/wolnelektury_core/static/img/licenses/cc-by-sa.png new file mode 100644 index 0000000000000000000000000000000000000000..81977e8d159fbbb562202d885a2e24a439b8b36f GIT binary patch literal 2829 zcmV+o3-a`dP)WaYwj@r|U4qONv z2GrAA0oO6ZbMfe>&H@UW^nJ>dTwcofJ0-UQwNHmd3#JD&qg0%iaU?DJj+exa&g_kdjp zEC)`pygq|D)UB!-7LgQSBIZWjggNxxz8dZMtk;(ra~xWch`C~l(Xz98Sf2p=4rsS~ zmh`axLA&l-d>RY%h3-5810uGzC@WwZu^ z+sNw3OP}8YsY#GG9y0rY8-z#@5=Q{Z(6$vqwNT#xwapNAT8J=_`9_1{XvST@AA$A2 zd8*oUEKTz4D*)C3{ehXP`az5}lQCMh7nq@{2Rw5*7!B(OT&b$dJaY-av%uBBl|{EaB1sD)>0!w1*J(P+s;k-A8YFA~B@Ey4EL+yk zV%~2%Sh2DZB39rz*Fj=`=qmtYDC@>7K#_gWW{(i=!Z^!|fqdXK5xG)CZUQQRtAG)} zG7*U$;1`%MYeEeCI#sRn3(*RA8YW7Zh>3L0jj;~P512^Ei;a)>i9o6S`!8Urs@AD$ z1uzez-ATZ2Vqg~qB92oe13OGemzLCNqstrW8JLtwcFSpu3?1gwgS8ClsN>^L9a@9U zR^Tm=Hql%b5TujAXq)7Hpoj=?3($tKWz#Tm_bb4ynCmuPRZD>jFd-JI8o?YymWYh9 zSi^xqo|o~rSUx1CU%@y*pd0^_EI(U4w2_$55};f?NtdeD1E1NyUjI;uF-Jv#NI0Ay z$O=Qmg>Mc*-4XaEiBLx}+3jOV&8j1>F_DBYv>o0-^We9+d+kyl`S(*s;K`%VB*MW@ zSa;+ZE~yc@#q*$(?6}j8IhNTfRc%()h^oGcad1O`{i=G%GXIv(!|$@=7(3?Mu_}%L zd()!W`5sz6@TID@L2BdJjz*U$buHUwQ7x13X;uG;i&CAKYeW-$`gYNnbxrY0Jl47l89) zyhK#!M}QzOUPQ71tj$ixWO^e-WSFJ@$cApw7JY$gJ4O$1TwDDtK2~-7K$0-ljc4mgq(FEZJN>Wo9oEm1>uwArI-bCdEWdsYl zc)4iI>EJd(dnFy)J7|@JpZ==v9uAoY_-=UZMOV$+HnyXBqDVp@|B1z^8$#-Np#&h zuM7$>cDy{1aJbw#;#?PLbO`jZ8s4&(DQQEgPDz2R29h!&B({fZ7Lu$}?1)?rny~RU|zDF^z)?ywKkzJTV)a4?w9TS$8&~=c}2*i(F zp6G@`8#EHpmNhE<&a?H8;6VbC$Ym)x; zP@$>~o~ez11KcPgOFZG)zCdD zsxKwjBt=yJHduA#6xG!~(2kWqQQbRVwf0x4yJo3wNmgf-=)O#}hR*&#jHF?*WjY9q zJ%NN~u4Q&NzDgRV5?5*GXU5oj6vzSQEz7Mur@(urbB1rFQPIIM~S;Td%-{G3Eu6 z)Fj84n`8N|jw(s#WNl*N^crvv3_;uP^a;ESZF^L-eVJ&}ZK8+H>?UNb0cST9A46zK zn0QrzL%@%F5OT8Bs<7R&sE76U*md=o`b(5P3^>R3$sT%ds(yuZRsEI#eS6>~Zq={b z!aXp(2C8cUX#E^Cyr@gq^>dCAaJ28NfzyveOEZBNJesxwxCZ0xld+XO;P;pWMlpq+ z>%mkfkAW?if>rcdzYAQB2@9h&`y4CuhcHe|fxjQmO~W|J?R1rh7XW8O4+&$=CIdHM z!d%7!4IJ + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.20.1