From: Marek Stępniowski Date: Wed, 17 Sep 2008 12:56:29 +0000 (+0200) Subject: Added themes. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/ff423b25bc07b9d248b3f6c0e5b7ae0c0220a19b?ds=inline;hp=cd678a14c6c7b26c5035a1167dd1e6c7bce3656b Added themes. --- diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index bf52dc43c..4f0a8a898 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -142,7 +142,13 @@ def book_detail(request, slug): 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)) diff --git a/wolnelektury/media/css/master.book.css b/wolnelektury/media/css/master.book.css index b789bcd0e..72b1b4630 100644 --- a/wolnelektury/media/css/master.book.css +++ b/wolnelektury/media/css/master.book.css @@ -35,6 +35,7 @@ img { height: 1.5em; background: #333; color: #FFF; + opacity: 0.9; } #menu ul { @@ -63,7 +64,7 @@ img { background: #FFF url(/media/img/arrow-up.png) no-repeat center right; } -#toc { +#toc, #themes { position: fixed; left: 0em; top: 1.5em; @@ -76,9 +77,10 @@ img { height: 16em; overflow-x: hidden; overflow-y: auto; + opacity: 0.9; } -#toc ol { +#toc ol, #themes ol { list-style: none; padding: 0; margin: 0; diff --git a/wolnelektury/media/js/book.js b/wolnelektury/media/js/book.js index cfb9ab088..108c2677b 100644 --- a/wolnelektury/media/js/book.js +++ b/wolnelektury/media/js/book.js @@ -5,9 +5,9 @@ $(function() { $('#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}}); }); diff --git a/wolnelektury/templates/catalogue/book_text.html b/wolnelektury/templates/catalogue/book_text.html index d733555a6..6c505e3b0 100644 --- a/wolnelektury/templates/catalogue/book_text.html +++ b/wolnelektury/templates/catalogue/book_text.html @@ -14,7 +14,7 @@ +
+
    + {% for theme, fragments in book_themes %} +
  1. {{ theme }}: + {% for fragment in fragments %} + {{ forloop.counter }} + {% endfor %} +
  2. + {% endfor %} +
+
{{ book.html_file.read|safe }}