return self._related_info
else:
rel = {'tags': {}, 'media': {}}
+
tags = self.tags.filter(category__in=(
'author', 'kind', 'genre', 'epoch'))
tags = split_tags(tags)
for category in tags:
rel['tags'][category] = [
(t.name, t.get_absolute_url()) for t in tags[category]]
+
for media_format in BookMedia.formats:
rel['media'][media_format] = self.has_media(media_format)
+
+ book = self
+ parents = []
+ while book.parent:
+ parents.append((book.parent.title, book.parent.slug))
+ book = book.parent
+ parents = parents[::-1]
+ if parents:
+ rel['parents'] = parents
+
if self.pk:
type(self).objects.filter(pk=self.pk).update(_related_info=rel)
return rel
from django.template.defaultfilters import stringfilter
from django.utils.translation import ugettext as _
+from catalogue import forms
from catalogue.utils import split_tags
-from catalogue.models import Book, Fragment
+from catalogue.models import Book, Fragment, Tag
register = template.Library()
@register.inclusion_tag('catalogue/book_wide.html', takes_context=True)
def book_wide(context, book):
- formats = {}
- # files generated during publication
- for ebook_format in book.ebook_formats:
- if book.has_media(ebook_format):
- formats[ebook_format] = book.get_media(ebook_format)
+ theme_counter = book.theme_counter
+ book_themes = Tag.objects.filter(pk__in=theme_counter.keys())
+ for tag in book_themes:
+ tag.count = theme_counter[tag.pk]
+ extra_info = book.get_extra_info_value()
+ hide_about = extra_info.get('about', '').startswith('http://wiki.wolnepodreczniki.pl')
return {
- 'related': book.related_info(),
'book': book,
- 'formats': formats,
+ 'related': book.related_info(),
'extra_info': book.get_extra_info_value(),
+ 'hide_about': hide_about,
+ 'themes': book_themes,
+ 'custom_pdf_form': forms.CustomPDFForm(),
'request': context.get('request'),
- 'fragment': book.choose_fragment(),
}
@register.inclusion_tag('catalogue/book_short.html', takes_context=True)
def book_short(context, book):
return {
- 'related': book.related_info(),
'book': book,
+ 'related': book.related_info(),
'request': context.get('request'),
}
@register.inclusion_tag('catalogue/book_mini_box.html')
def book_mini(book):
return {
- 'related': book.related_info(),
'book': book,
+ 'related': book.related_info(),
}
try:
book = models.Book.objects.get(slug=slug)
except models.Book.DoesNotExist:
- return pdcounter_views.book_stub_detail(request, kwargs['slug'])
+ return pdcounter_views.book_stub_detail(request, slug)
- book_tag = book.book_tag()
- tags = list(book.tags.filter(~Q(category='set')))
- categories = split_tags(tags)
book_children = book.children.all().order_by('parent_number', 'sort_key')
-
- _book = book
- parents = []
- while _book.parent:
- parents.append(_book.parent)
- _book = _book.parent
- parents = reversed(parents)
-
- theme_counter = book.theme_counter
- book_themes = models.Tag.objects.filter(pk__in=theme_counter.keys())
- for tag in book_themes:
- tag.count = theme_counter[tag.pk]
-
- extra_info = book.get_extra_info_value()
- hide_about = extra_info.get('about', '').startswith('http://wiki.wolnepodreczniki.pl')
-
- custom_pdf_form = forms.CustomPDFForm()
return render_to_response('catalogue/book_detail.html', locals(),
context_instance=RequestContext(request))
@classmethod
def for_book(cls, book, length=3):
- from librarian import text
-
# count from this book only
output = StringIO()
- f = open(book.xml_file.path)
- text.transform(f, output, False, ('raw-text',))
- f.close()
+ wldoc = book.wldocument(parse_dublincore=False)
+ output = wldoc.as_text(('raw-text',)).get_string()
+ del wldoc
+
conts = {}
last_word = ''
- for letter in output.getvalue().decode('utf-8').strip().lower():
+ for letter in output.decode('utf-8').strip().lower():
mydict = conts.setdefault(last_word, {})
mydict.setdefault(letter, 0)
mydict[letter] += 1
--- /dev/null
+{% if tags %}
+<ul class='social-shelf-tags'>
+ {% for tag in tags %}
+ <li><a href="{{ tag.get_absolute_url }}">{{ tag.name }}</a></li>
+ {% endfor %}
+</ul>
+{% endif %}
'cite': cites.order_by('?')[0] if cites.exists() else None,
'fallback': fallback,
'ctx': ctx,
- }
\ No newline at end of file
+ }
+
+
+@register.inclusion_tag('social/shelf_tags.html', takes_context=True)
+def shelf_tags(context, book):
+ user = context['request'].user
+ if not user.is_authenticated():
+ tags = []
+ else:
+ tags = book.tags.filter(category='set', user=user).exclude(name='')
+ return {'tags': tags}
'css/book_box.css',
'css/catalogue.css',
'css/sponsors.css',
-
+
+ 'css/social/shelf_tags.css',
'css/ui-lightness/jquery-ui-1.8.16.custom.css',
],
'output_filename': 'css/all.min?.css',
margin-top: .4em
}
+ul.plain {
+ list-style:none;
+ margin: 0;
+ padding: 0;
+}
+
.left-column {
width: 47em;
float: left;
font-size: 1.1em;
color: #707b7a;
display: block;
+ overflow:hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
.book-mini-box .title {
font-size: 1.4em;
}
.book-wide-box .book-box-body {
- height: 21.8em;
+ min-height: 17em;
}
.book-box-head {
margin-top: 1.4em;
margin-bottom: 1em;
}
+.book-box-head a {
+ color: black;
+}
.book-box-head .author {
font-size: 1.1em;
}
margin-left: 14em;
}
+.book-wide-box #themes-list-wrapper {
+ margin-left: 14em;
+}
+
+
+
.book-box-read a:before {
content: "\2609";
font-family: WL-Nav;
font-weight: normal;
}
-.book-box-download a:before {
+.book-box-download a.downarrow:before {
content: "\21E9";
font-family: WL-Nav;
font-size: 2.25em;
.book-wide-box .other-download {
float: left;
- width: 22.5em;
+ width: 22em;
margin: 6em 1.5em 0em 1.5em;
}
--- /dev/null
+.social-shelf-tags {
+ list-style: none;
+ padding: 0;
+ margin: 1em 0;
+}
+
+.social-shelf-tags li {
+ display: inline-block;
+ margin-right:1em;
+}
+
+.social-shelf-tags a {
+ display: block;
+ padding: .3em 1em;
+ background: #ABDADE;
+ color: #0b838d;
+ border-radius: 1em;
+}
$('.target', $window).text(response.message);
setTimeout(function() { $window.jqmHide() }, 1000);
$form.submit();
+ location.reload();
}
else {
$('.error', $window).remove();
};
var ajaxable_callbacks = {
- 'social-book-sets': update_star
+ 'social-book-sets': location.reload
};
<div class="book-box-head">
<div class="mono author">
{% for name, url in related.tags.author %}
- {{ name }}{% if not forloop.last %}, {% endif %}
+ <a href="{{ url }}">{{ name }}</a>{% if not forloop.last %},
+ {% endif %}{% endfor %}{% for title, slug in related.parents %},
+ <a href="{% url book_detail slug %}">{{ title }}</a>
{% endfor %}
</div>
- <div class="title">{{ book.title }}</div>
+ <div class="title"><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></div>
</div>
<div class="tags">
{% spaceless %}
</span>
{% endspaceless %}
+
+ {% shelf_tags book %}
</div>
</div>
+
+ {% block book-box-extra-info %}{% endblock %}
+
<ul class="book-box-tools">
<li class="book-box-read">
{% if book.html_file %}
<li class="book-box-download">
<a class="mono downarrow">{% trans "Download" %}</a>
<div class="book-box-formats mono">
- {% if formats.pdf %}
- <span><a href="{{formats.pdf.url}}">PDF</a> do wydruku</span>
+ {% if book.pdf_file %}
+ <span><a href="{{ book.pdf_file.url}}">PDF</a> do wydruku</span>
{% endif %}
- {% if formats.epub %}
- <span><a href="{{formats.epub.url}}">EPUB</a> na czytnik</span>
+ {% if book.epub_file %}
+ <span><a href="{{ book.epub_file.url}}">EPUB</a> na czytnik</span>
{% endif %}
- {% if formats.mobi %}
- <span><a href="{{formats.mobi.url}}">MOBI</a> na Kindle</span>
+ {% if book.mobi_file %}
+ <span><a href="{{ book.mobi_file.url}}">MOBI</a> na Kindle</span>
{% endif %}
- {% if formats.txt %}
- <span><a href="{{formats.txt.url}}">TXT</a> do zadań specjalnych</span>
+ {% if book.txt_file %}
+ <span><a href="{{ book.txt_file.url}}">TXT</a> do zadań specjalnych</span>
{% endif %}
</div>
</li>
</ul>
{% block box-append %}
{% endblock %}
+ <div class="clearboth"></div>
</div>
</div>
{% extends "catalogue/book_short.html" %}
{% load i18n %}
+{% load tag_list from catalogue_tags %}
{% load cite_promo from social_tags %}
+
{% block box-class %}book-wide-box{% endblock %}
+
+{% block book-box-extra-info %}
+{% if themes %}
+ <div id="themes-list-wrapper">
+ <p><a class="mono" id="themes-list-toggle"
+ href="#">{% trans "motifs and themes" %}</a></p>
+ <div id="themes-list">
+ <ul>
+ {% for theme in themes %}
+ <li><a href="{% url book_fragments book.urlid theme.slug %}">{{ theme }} ({{ theme.count }})</a></li>
+ {% endfor %}
+ </ul>
+ </div>
+ </div>
+{% endif %}
+{% endblock %}
+
+
{% block right-column %}
<div class="right-column">
<div class="quote">
<div class="other-tools">
<h2 class="mono">{% trans "See" %}</h2>
- <ul class="inline-items">
+ <ul class="plain">
{% if extra_info.source_url %}
<li><a href="{{ extra_info.source_url }}">{% trans "Source" %}</a> {% trans "of the book" %}</li>
{% endif %}
+ <li><a href="{{ book.xml_file.url }}">{% trans "Source XML file" %}</a></li>
{% if extra_info.about and not hide_about %}
<li>{% trans "Book on" %} <a href="{{ extra_info.about }}">{% trans "Editor's Platform" %}</a></li>
{% endif %}
{% if book.wiki_link %}
<li><a href="{{ book.wiki_link }}">{% trans "Book description on Wikipedia" %}</a></li>
{% endif %}
+ <li><a href="{% url poem_from_book book.slug %}">{% trans "Mix this book" %}</a></li>
</ul>
</div>
<div class="other-download">
<h2 class="mono">{% trans "Download" %}</h2>
- <ul class="inline-items">
+ <ul class="plain">
<li>
{% if related.media.mp3 or related.media.ogg %}
{% trans "Download all audiobooks for this book" %}:
{% cite_promo tags 1 %}
<div class="see-also">
+ {% if last_tag.gazeta_link or last_tag.wiki_link %}
<h2 class='mono'>{% trans "See also" %}:</h2>
<ul>
- <li><a href="">Wiki</a></li>
- <li><a href="">Gazeta</a></li>
- </ul>
- </div>
-
- <div class="download">
- <h2 class='mono'>{% trans "Download" %}:</h2>
- <ul>
- <li><a href="">wszystko</a></li>
- <li><a href="">część</a></li>
- </ul>
- </div>
-
- </div>
-
- <div class="clearboth"></div>
-
-
-
-
- <div id="books-list">
-
-
{% if last_tag.gazeta_link %}
- <p><a href="{{ last_tag.gazeta_link }}">
+ <li><a href="{{ last_tag.gazeta_link }}">
{% switch last_tag.category %}
{% case "author" %}
{% trans "Read work's study of this author on Lektury.Gazeta.pl" %}
{% else %}
{% trans "Read related study on Lektury.Gazeta.pl" %}
{% endswitch %}
- </a></p>
+ </a></li>
{% endif %}
{% if last_tag.wiki_link %}
- <p><a href="{{ last_tag.wiki_link }}">
+ <li><a href="{{ last_tag.wiki_link }}">
{% switch last_tag.category %}
{% case "author" %}
{% trans "Read article about this author on Wikipedia" %}
{% else %}
{% trans "Read related article on Wikipedia" %}
{% endswitch %}
- </a></p>
+ </a></li>
{% endif %}
+
+
+ </ul>
+ {% endif %}
+ </div>
+
+ <div class="download">
+ {% comment %}
+ <h2 class='mono'>{% trans "Download" %}:</h2>
+ <ul>
+ <li><a href="">wszystko</a></li>
+ <li><a href="">część</a></li>
+ </ul>
+ {% endcomment %}
+ </div>
+
+ </div>
+
+ <div class="clearboth"></div>
+
+
+
+
+ <div id="books-list">
{% if object_list %}
{% work_list object_list %}
{% else %}