From: Radek Czajka Date: Tue, 12 Jun 2012 09:54:40 +0000 (+0200) Subject: closes #2165: license icon on book page X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/57a20265fc4e83cdaa26d8c05af2e4d9a77afea0 closes #2165: license icon on book page --- 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 000000000..81977e8d1 Binary files /dev/null and b/apps/wolnelektury_core/static/img/licenses/cc-by-sa.png differ diff --git a/apps/wolnelektury_core/static/img/licenses/cc-by-sa.svg b/apps/wolnelektury_core/static/img/licenses/cc-by-sa.svg new file mode 100644 index 000000000..85199f2e3 --- /dev/null +++ b/apps/wolnelektury_core/static/img/licenses/cc-by-sa.svg @@ -0,0 +1,469 @@ + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +