From f17e5ab1f46f52b071f71c799dfa4c755f7c407e Mon Sep 17 00:00:00 2001 From: Lukasz Anwajler Date: Wed, 1 Sep 2010 06:33:01 -0500 Subject: [PATCH 1/1] The Great Listing of all Books improvement (TOC). --- apps/catalogue/views.py | 5 ++++ wolnelektury/static/css/master.css | 24 +++++++++++++++---- wolnelektury/static/js/catalogue.js | 6 +++++ .../templates/catalogue/book_list.html | 17 +++++++++++-- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 556bae1fe..d9ae442aa 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -81,8 +81,13 @@ def book_list(request): orphans = [] books_by_author = SortedDict() + books_nav = SortedDict() for tag in models.Tag.objects.filter(category='author'): books_by_author[tag] = [] + if books_nav.has_key(tag.sort_key[0]): + books_nav[tag.sort_key[0]].append(tag) + else: + books_nav[tag.sort_key[0]] = [tag] for book in books_by_parent[None]: authors = list(book.tags.filter(category='author')) diff --git a/wolnelektury/static/css/master.css b/wolnelektury/static/css/master.css index 80677d214..e9c42dce9 100644 --- a/wolnelektury/static/css/master.css +++ b/wolnelektury/static/css/master.css @@ -784,12 +784,28 @@ div.shown-tags p, div.all-tags p { /* ======================== */ /* = Alphabetic book list = */ /* ======================== */ -#book-a-list #book-list { - -moz-column-width: 24em; - -webkit-column-width: 24em; - column-width: 24em; +#book-list-nav { + position: fixed; + right: 50px; + width: 200px; + border: 2px #325F70 solid; + padding: 10px; + font-size: 1.2em; +} + +#book-list-nav ul { + list-style-type: none; + margin: 5px; + padding: 0; +} + +.book-list-show-index { + display: none; + margin: 0; + padding: 0; } + #book-a-list #book-list ol { padding-left: 1em; margin: 0.3em 0 1.2em 0; diff --git a/wolnelektury/static/js/catalogue.js b/wolnelektury/static/js/catalogue.js index 4b09de8fd..cb31654c9 100644 --- a/wolnelektury/static/js/catalogue.js +++ b/wolnelektury/static/js/catalogue.js @@ -479,6 +479,12 @@ function serverTime() { }) } ); + + $('.book-list-index').click(function(){ + $('.book-list-show-index').hide('slow'); + $(this).parent().next('ul').toggle('slow'); + return false; + }); }); })(jQuery) diff --git a/wolnelektury/templates/catalogue/book_list.html b/wolnelektury/templates/catalogue/book_list.html index 7d49cffa1..f385a19f8 100644 --- a/wolnelektury/templates/catalogue/book_list.html +++ b/wolnelektury/templates/catalogue/book_list.html @@ -11,11 +11,24 @@

{{ form.q }} {% trans "or" %} {% trans "return to main page" %}

- +
+ {% trans "Table of Content" %} + {% for index, authors in books_nav.items %} + + {% endfor %} +
{% book_tree orphans books_by_parent %} {% for author, group in books_by_author.items %} {% if group %} +

{{ author }}

{% book_tree group books_by_parent %} @@ -23,4 +36,4 @@ {% endif %} {% endfor %}
-{% endblock %} \ No newline at end of file +{% endblock %} -- 2.20.1