def book_text(request, slug):
book = get_object_or_404(models.Book, slug=slug)
+ book_themes = {}
+ for fragment in book.fragments.all():
+ for theme in fragment.tags.filter(category='theme'):
+ book_themes.setdefault(theme, []).append(fragment)
+ book_themes = book_themes.items()
+ book_themes.sort(key=lambda s: s[0].sort_key)
return render_to_response('catalogue/book_text.html', locals(),
context_instance=RequestContext(request))
height: 1.5em;
background: #333;
color: #FFF;
+ opacity: 0.9;
}
#menu ul {
background: #FFF url(/media/img/arrow-up.png) no-repeat center right;
}
-#toc {
+#toc, #themes {
position: fixed;
left: 0em;
top: 1.5em;
height: 16em;
overflow-x: hidden;
overflow-y: auto;
+ opacity: 0.9;
}
-#toc ol {
+#toc ol, #themes ol {
list-style: none;
padding: 0;
margin: 0;
$('#menu li a[href="#toc"]').remove();
}
- $('#toc a').click(function(event) {
+ $('#toc a, #themes a').click(function(event) {
event.preventDefault();
- $('#menu li a.selected[href="#toc"]').click();
+ $('#menu li a.selected').click();
$.scrollTo('a[name="' + $(this).attr('href').slice(1) + '"]', {offset: {top: -50, left: 0}});
});
<div id="menu">
<ul>
<li><a href="#toc">Spis treści</a></li>
- <li><a href="#">Motywy</a></li>
+ <li><a href="#themes">Motywy</a></li>
</ul>
</div>
<div id="header">
<a href="/"><img src="/media/img/logo.png" alt="WolneLektury.pl - logo" /></a>
</div>
</div>
+ <div id="themes">
+ <ol>
+ {% for theme, fragments in book_themes %}
+ <li>{{ theme }}:
+ {% for fragment in fragments %}
+ <a href="#m{{ fragment.anchor }}">{{ forloop.counter }}</a>
+ {% endfor %}
+ <li>
+ {% endfor %}
+ </ol>
+ </div>
{{ book.html_file.read|safe }}
</body>
</html>