From dbac994bfb1dbf4b1d6f035ad14bebd465a56741 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 30 Jun 2014 10:50:14 +0200 Subject: [PATCH] Support for source names, developmentStage. --- apps/catalogue/constants.py | 6 ++ .../catalogue/locale/pl/LC_MESSAGES/django.mo | Bin 11366 -> 11537 bytes .../catalogue/locale/pl/LC_MESSAGES/django.po | 102 ++++++++++-------- apps/catalogue/models/book.py | 9 ++ .../templates/catalogue/book_short.html | 6 ++ .../templates/catalogue/book_wide.html | 5 +- apps/catalogue/templatetags/catalogue_tags.py | 15 ++- lib/librarian | 2 +- 8 files changed, 96 insertions(+), 49 deletions(-) diff --git a/apps/catalogue/constants.py b/apps/catalogue/constants.py index 36f4f5dd3..56fe93936 100644 --- a/apps/catalogue/constants.py +++ b/apps/catalogue/constants.py @@ -36,3 +36,9 @@ LANGUAGES_3TO2 = { 'rus': 'ru', 'ukr': 'uk', } + +SOURCE_NAMES = { + u'pl.wikisource.org': _(u'Wikisource'), + u'de.wikisource.org': _(u'Wikisource'), + u'www.polona.pl': u'CBN Polona', +} diff --git a/apps/catalogue/locale/pl/LC_MESSAGES/django.mo b/apps/catalogue/locale/pl/LC_MESSAGES/django.mo index 66ae6880c7f5d73e18c3e40e2f5e2744dcd8f264..5605ea8e99f980be8ba39b4f988ade75339aee89 100644 GIT binary patch delta 3866 zcmY+_d2q~U9LMn|9M zVLL|J5m%HkKjWwM_`}w}p)sv66=QG;*2S6F6B*nwI24(jnTE~KWzR1~O{Caf zKZ1JxG`7HtsEK`xvGi~LVMh(bG!0*9iz?+X)J(=Bw-`5Spng=zSJ>;TQ8U_&n&D@t zN>rdGP>HJ8b=32>QP1DOKm&H}vhy-NM%~zy(L`b!)B_zbQ~^{ed!lAC3iZy+Mm@I- z)o>wdsn($?aS&Cp^Qej4K;8dCGwL5204FrV$EcDwG8$A5$u8&P?foh%+dUT>Mybd^`}qMl2+Pcchn7|kk`V@KsB@gHIPEo47Xqj zmZ4tWcy3aK5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@qGd#Oh(N#3pLX*I1Z=aP;5f&?FCfBS5TkRUDUhKF)d&;KFo11Y>(^Eg&R>TwH0~9 z?8RS#*#F~H)Zklej2b$Dn(vc*0<~9}mG~Pos5Xzepg7K)1l28LowdeCu9S=vn1LN)Wa#RO3_IfRL;CM4? zVmnap)IJQu_tB?@PEgSjeP%D5M|FI~p1*-wk=v*N{)K8dJToxRXw(YCV=!je^Ziln zV=NA**L8tBAKzJEP1ofGPy41;h9=}$OxMy}OS(XZT6vWv_kE#xsWpQx-Muaha{ zInq{!QK=-)lTBnQ8AJBdznM&hUqa{KX>dw2f0x<%PU|2XOJ)$w{zZ~c788}_WPnrS zyT^%SA$f(YCb?uQDIzLQ6R-CF0O>>8N|mkbu%@frOKhq=L*P zD*8%Po+A9KZuIYuQ}kV`j3Na@pIKX3PbGz{ARCE(-}U)CN@|J9$^a$}Yi#{BoJF#U zhs2O+, YEAR. +# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # msgid "" msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" +"Project-Id-Version: WolneLektury\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-05 11:21+0100\n" -"PO-Revision-Date: 2014-02-05 11:21+0100\n" +"POT-Creation-Date: 2014-06-30 10:37+0200\n" +"PO-Revision-Date: 2014-06-30 10:34+0100\n" "Last-Translator: Radek Czajka \n" -"Language-Team: LANGUAGE \n" +"Language-Team: Fundacja Nowoczesna Polska \n" +"Language: pl\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,6 +22,10 @@ msgid "Creative Commons Attribution-ShareAlike 3.0 Unported" msgstr "" "Creative Commons Uznanie autorstwa – Na tych samych warunkach 3.0 Unported" +#: constants.py:41 constants.py:42 +msgid "Wikisource" +msgstr "Wikiźródła" + #: forms.py:27 msgid "Please supply an XML." msgstr "Proszę podać XML." @@ -74,7 +78,7 @@ msgstr "Duży" msgid "Queue is full. Please try again later." msgstr "Kolejka jest pełna. Proszę spróbować ponownie później." -#: views.py:597 +#: views.py:588 #, python-format msgid "" "An error occurred: %(exception)s\n" @@ -85,91 +89,95 @@ msgstr "" "\n" "%(tb)s" -#: views.py:598 +#: views.py:589 msgid "Book imported successfully" msgstr "Książka zaimportowana" -#: views.py:600 +#: views.py:591 #, python-format msgid "Error importing file: %r" msgstr "Błąd podczas importowania pliku: %r" -#: views.py:632 +#: views.py:623 msgid "Download custom PDF" msgstr "Stwórz własny PDF" -#: views.py:633 templates/catalogue/book_short.html:97 -#: templates/catalogue/book_wide.html:63 +#: views.py:624 templates/catalogue/book_short.html:103 +#: templates/catalogue/book_wide.html:64 msgid "Download" msgstr "Pobierz" -#: models/book.py:28 models/collection.py:11 +#: models/book.py:30 models/collection.py:11 msgid "title" msgstr "tytuł" -#: models/book.py:29 models/tag.py:34 +#: models/book.py:31 models/tag.py:34 msgid "sort key" msgstr "klucz sortowania" -#: models/book.py:30 +#: models/book.py:32 #, fuzzy msgid "sort key by author" msgstr "Znalezieni autorzy" -#: models/book.py:31 models/book.py:33 models/collection.py:12 +#: models/book.py:33 models/book.py:35 models/collection.py:12 #: models/collection.py:15 models/tag.py:33 msgid "slug" msgstr "slug" -#: models/book.py:34 +#: models/book.py:36 msgid "language code" msgstr "Kod języka" -#: models/book.py:36 models/book.py:164 models/collection.py:13 +#: models/book.py:38 models/book.py:170 models/collection.py:13 #: models/tag.py:37 models/tag.py:94 msgid "description" msgstr "opis" -#: models/book.py:37 models/book.py:38 models/bookmedia.py:29 models/tag.py:46 +#: models/book.py:39 models/book.py:40 models/bookmedia.py:31 models/tag.py:46 #: models/tag.py:47 msgid "creation date" msgstr "data utworzenia" -#: models/book.py:39 +#: models/book.py:41 msgid "parent number" msgstr "numer rodzica" -#: models/book.py:40 models/bookmedia.py:30 +#: models/book.py:42 models/bookmedia.py:32 msgid "extra information" msgstr "dodatkowe informacje" -#: models/book.py:45 +#: models/book.py:47 msgid "cover" msgstr "okładka" -#: models/book.py:48 +#: models/book.py:52 msgid "cover thumbnail" msgstr "podgląd okładki" -#: models/book.py:70 models/collection.py:18 models/tag.py:22 +#: models/book.py:76 models/collection.py:18 models/tag.py:22 msgid "book" msgstr "książka" -#: models/book.py:71 +#: models/book.py:77 msgid "books" msgstr "książki" -#: models/book.py:262 +#: models/book.py:268 #, python-format msgid "Book \"%s\" does not exist." msgstr "Utwór \"%s\" nie istnieje." -#: models/book.py:276 +#: models/book.py:282 #, python-format msgid "Book %s already exists" msgstr "Książka %s już istnieje" -#: models/book.py:625 models/bookmedia.py:23 +#: models/book.py:618 +msgid "This work needs modernisation" +msgstr "Ten utwór wymaga uwspółcześnienia" + +#: models/book.py:637 models/bookmedia.py:23 #, python-format msgid "%s file" msgstr "plik %s" @@ -186,7 +194,7 @@ msgstr "nazwa" msgid "file" msgstr "plik" -#: models/bookmedia.py:39 models/bookmedia.py:40 +#: models/bookmedia.py:41 models/bookmedia.py:42 msgid "book media" msgstr "media książki" @@ -371,31 +379,31 @@ msgstr "Gatunek" msgid "Language" msgstr "Język" -#: templates/catalogue/book_short.html:93 +#: templates/catalogue/book_short.html:99 msgid "Read online" msgstr "Czytaj online" -#: templates/catalogue/book_short.html:100 +#: templates/catalogue/book_short.html:106 msgid "to print" msgstr "do druku" -#: templates/catalogue/book_short.html:103 +#: templates/catalogue/book_short.html:109 msgid "for an e-book reader" msgstr "na czytnik e-booków" -#: templates/catalogue/book_short.html:106 +#: templates/catalogue/book_short.html:112 msgid "for Kindle" msgstr "na Kindle" -#: templates/catalogue/book_short.html:109 +#: templates/catalogue/book_short.html:115 msgid "FictionBook" msgstr "FictionBook" -#: templates/catalogue/book_short.html:112 +#: templates/catalogue/book_short.html:118 msgid "for advanced usage" msgstr "do zadań specjalnych" -#: templates/catalogue/book_short.html:118 +#: templates/catalogue/book_short.html:124 msgid "Listen" msgstr "Słuchaj" @@ -465,31 +473,35 @@ msgstr "Źródło" msgid "of the book" msgstr "utworu" -#: templates/catalogue/book_wide.html:49 +#: templates/catalogue/book_wide.html:48 +msgid "in" +msgstr "w serwisie" + +#: templates/catalogue/book_wide.html:50 msgid "Source XML file" msgstr "Źródłowy plik XML" -#: templates/catalogue/book_wide.html:51 +#: templates/catalogue/book_wide.html:52 msgid "Book on" msgstr "Utwór na" -#: templates/catalogue/book_wide.html:51 +#: templates/catalogue/book_wide.html:52 msgid "Editor's Platform" msgstr "Platformie Redakcyjnej" -#: templates/catalogue/book_wide.html:54 +#: templates/catalogue/book_wide.html:55 msgid "Book description on Lektury.Gazeta.pl" msgstr "Opis lektury w Lektury.Gazeta.pl" -#: templates/catalogue/book_wide.html:57 +#: templates/catalogue/book_wide.html:58 msgid "Book description on Wikipedia" msgstr "Opis lektury w Wikipedii" -#: templates/catalogue/book_wide.html:59 +#: templates/catalogue/book_wide.html:60 msgid "Mix this book" msgstr "Miksuj treść utworu" -#: templates/catalogue/book_wide.html:67 +#: templates/catalogue/book_wide.html:68 msgid "Download all audiobooks for this book" msgstr "Pobierz wszystkie audiobooki tego utworu" diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index 414d1effb..27240fbd5 100644 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -8,6 +8,7 @@ from django.core.cache import get_cache from django.db import models from django.db.models import permalink import django.dispatch +from django.core.urlresolvers import reverse from django.utils.datastructures import SortedDict from django.utils.translation import ugettext_lazy as _ import jsonfield @@ -612,6 +613,14 @@ class Book(models.Model): audiences = sorted(set([self._audiences_pl.get(a, (99, a)) for a in audiences])) return [a[1] for a in audiences] + def stage_note(self): + stage = self.extra_info.get('stage') + if stage and stage < '0.4': + return (_('This work needs modernisation'), + reverse('infopage', args=['wymagajace-uwspolczesnienia'])) + else: + return None, None + def choose_fragment(self): tag = self.book_tag() fragments = Fragment.tagged.with_any([tag]) diff --git a/apps/catalogue/templates/catalogue/book_short.html b/apps/catalogue/templates/catalogue/book_short.html index 3a0d37a86..9c90bddc8 100644 --- a/apps/catalogue/templates/catalogue/book_short.html +++ b/apps/catalogue/templates/catalogue/book_short.html @@ -82,6 +82,12 @@ {% endif %} + {% if stage_note %} +
+ {{ stage_note }}
+ + {% endif %} + {% endspaceless %} diff --git a/apps/catalogue/templates/catalogue/book_wide.html b/apps/catalogue/templates/catalogue/book_wide.html index 13df555b9..5ce66a3cb 100644 --- a/apps/catalogue/templates/catalogue/book_wide.html +++ b/apps/catalogue/templates/catalogue/book_wide.html @@ -1,6 +1,6 @@ {% extends "catalogue/book_short.html" %} {% load i18n %} -{% load download_audio tag_list custom_pdf_link_li license_icon from catalogue_tags %} +{% load download_audio tag_list custom_pdf_link_li license_icon source_name from catalogue_tags %} {% load cite_promo from social_tags %} @@ -44,7 +44,8 @@

{% trans "See" %}

    {% if extra_info.source_url %} -
  • {% trans "Source" %} {% trans "of the book" %}
  • +
  • {% trans "Source" %} {% trans "of the book" %} + {% trans "in" %} {% source_name extra_info.source_url %}
  • {% endif %}
  • {% trans "Source XML file" %}
  • {% if extra_info.about and not hide_about %} diff --git a/apps/catalogue/templatetags/catalogue_tags.py b/apps/catalogue/templatetags/catalogue_tags.py index bbd9f0719..5555711ef 100644 --- a/apps/catalogue/templatetags/catalogue_tags.py +++ b/apps/catalogue/templatetags/catalogue_tags.py @@ -5,6 +5,7 @@ import datetime import feedparser from random import randint +from urlparse import urlparse from django.conf import settings from django import template @@ -16,7 +17,7 @@ from django.utils.translation import ugettext as _ from catalogue.utils import related_tag_name as _related_tag_name from catalogue.models import Book, BookMedia, Fragment, Tag -from catalogue.constants import LICENSES +from catalogue.constants import LICENSES, SOURCE_NAMES register = template.Library() @@ -326,6 +327,7 @@ def book_wide(context, book): book_themes = book.related_themes() extra_info = book.extra_info hide_about = extra_info.get('about', '').startswith('http://wiki.wolnepodreczniki.pl') + stage_note, stage_note_url = book.stage_note() return { 'book': book, @@ -336,17 +338,23 @@ def book_wide(context, book): 'themes': book_themes, 'request': context.get('request'), 'show_lang': book.language_code() != settings.LANGUAGE_CODE, + 'stage_note': stage_note, + 'stage_note_url': stage_note_url, } @register.inclusion_tag('catalogue/book_short.html', takes_context=True) def book_short(context, book): + stage_note, stage_note_url = book.stage_note() + return { 'book': book, 'main_link': book.get_absolute_url(), 'related': book.related_info(), 'request': context.get('request'), 'show_lang': book.language_code() != settings.LANGUAGE_CODE, + 'stage_note': stage_note, + 'stage_note_url': stage_note_url, } @@ -473,3 +481,8 @@ def related_tag_name(tag, lang=None): def class_name(obj): return obj.__class__.__name__ + +@register.simple_tag +def source_name(url): + netloc = urlparse(url).netloc + return SOURCE_NAMES.get(netloc, netloc) diff --git a/lib/librarian b/lib/librarian index 13b88a3bf..2a4236f2d 160000 --- a/lib/librarian +++ b/lib/librarian @@ -1 +1 @@ -Subproject commit 13b88a3bfdd4fa3cf5c92368aa5cb60fa832eda6 +Subproject commit 2a4236f2ddbe95d07ba7fcbe750451340c38c2b9 -- 2.20.1