zaznaczanie pozycji w menu
authorJan Szejko <j-sz@o2.pl>
Thu, 11 Feb 2016 16:00:48 +0000 (17:00 +0100)
committerJan Szejko <j-sz@o2.pl>
Thu, 11 Feb 2016 16:00:48 +0000 (17:00 +0100)
src/catalogue/templates/catalogue/tagged_object_list.html
src/catalogue/templatetags/catalogue_tags.py
src/catalogue/views.py
src/wolnelektury/static/scss/main/menu.scss
src/wolnelektury/templates/superbase.html

index 06947e3..b8eea9c 100644 (file)
@@ -46,7 +46,7 @@
     {% endif %}
 </div>
 
     {% endif %}
 </div>
 
-{% if list_type == 'default' and not tags %}
+{% if list_type == 'books' and not tags %}
     <section>
         <h1>{% trans "Recent publications" %}</h1>
             {% for book in last_published %}
     <section>
         <h1>{% trans "Recent publications" %}</h1>
             {% for book in last_published %}
index 105306e..947fbf2 100644 (file)
@@ -302,7 +302,7 @@ class CatalogueURLNode(Node):
 
 
 # @register.inclusion_tag('catalogue/tag_list.html')
 
 
 # @register.inclusion_tag('catalogue/tag_list.html')
-def tag_list(tags, choices=None, category=None, list_type='default'):
+def tag_list(tags, choices=None, category=None, list_type='books'):
     # print(tags, choices, category)
     if choices is None:
         choices = []
     # print(tags, choices, category)
     if choices is None:
         choices = []
@@ -339,7 +339,7 @@ def tag_list(tags, choices=None, category=None, list_type='default'):
 
 
 @register.inclusion_tag('catalogue/inline_tag_list.html')
 
 
 @register.inclusion_tag('catalogue/inline_tag_list.html')
-def inline_tag_list(tags, choices=None, category=None, list_type='default'):
+def inline_tag_list(tags, choices=None, category=None, list_type='books'):
     return tag_list(tags, choices, category, list_type)
 
 
     return tag_list(tags, choices, category, list_type)
 
 
@@ -363,7 +363,7 @@ def work_list(context, object_list):
 
 
 @register.inclusion_tag('catalogue/plain_list.html', takes_context=True)
 
 
 @register.inclusion_tag('catalogue/plain_list.html', takes_context=True)
-def plain_list(context, object_list, with_initials=True, by_author=False, choice=None, book=None, list_type='default',
+def plain_list(context, object_list, with_initials=True, by_author=False, choice=None, book=None, list_type='books',
                paged=True, initial_blocks=False):
     names = [('', [])]
     last_initial = None
                paged=True, initial_blocks=False):
     names = [('', [])]
     last_initial = None
index 4770624..b39bb87 100644 (file)
@@ -38,6 +38,7 @@ def catalogue(request):
         'books': Book.objects.filter(parent=None).order_by('sort_key_author', 'sort_key'),
         'pictures': Picture.objects.order_by('sort_key_author', 'sort_key'),
         'collections': Collection.objects.all(),
         'books': Book.objects.filter(parent=None).order_by('sort_key_author', 'sort_key'),
         'pictures': Picture.objects.order_by('sort_key_author', 'sort_key'),
         'collections': Collection.objects.all(),
+        'active_menu_item': 'all_works',
     })
 
 
     })
 
 
@@ -107,7 +108,7 @@ def differentiate_tags(request, tags, ambiguous_slugs):
 
 
 # TODO: Rewrite this hellish piece of code which tries to do everything
 
 
 # TODO: Rewrite this hellish piece of code which tries to do everything
-def tagged_object_list(request, tags='', list_type='default'):
+def tagged_object_list(request, tags='', list_type='books'):
     raw_tags = tags
     # preliminary tests and conditions
     gallery = list_type == 'gallery'
     raw_tags = tags
     # preliminary tests and conditions
     gallery = list_type == 'gallery'
@@ -233,7 +234,7 @@ def tagged_object_list(request, tags='', list_type='default'):
             return redirect('tagged_object_list_gallery', raw_tags)
 
     # this is becoming more and more hacky
             return redirect('tagged_object_list_gallery', raw_tags)
 
     # this is becoming more and more hacky
-    if list_type == 'default' and not tags:
+    if list_type == 'books' and not tags:
         last_published = Book.objects.exclude(cover_thumb='').filter(parent=None).order_by('-created_at')[:20]
     else:
         last_published = None
         last_published = Book.objects.exclude(cover_thumb='').filter(parent=None).order_by('-created_at')[:20]
     else:
         last_published = None
@@ -253,6 +254,7 @@ def tagged_object_list(request, tags='', list_type='default'):
             'list_type': list_type,
             'daisy': daisy,
             'last_published': last_published,
             'list_type': list_type,
             'daisy': daisy,
             'last_published': last_published,
+            'active_menu_item': 'theme' if theme_is_set else list_type,
         },
         context_instance=RequestContext(request))
 
         },
         context_instance=RequestContext(request))
 
@@ -759,6 +761,7 @@ def tag_catalogue(request, category):
         'best': best,
         'title': constants.CATEGORIES_NAME_PLURAL[category],
         'whole_category': constants.WHOLE_CATEGORY[category],
         'best': best,
         'title': constants.CATEGORIES_NAME_PLURAL[category],
         'whole_category': constants.WHOLE_CATEGORY[category],
+        'active_menu_item': 'theme' if category == 'theme' else None,
     })
 
 
     })
 
 
index c2f708a..daede5c 100755 (executable)
@@ -129,6 +129,10 @@ body.menu-on {
             display: inline-block;
             @include size(width, 20%);
 
             display: inline-block;
             @include size(width, 20%);
 
+            &.active {
+                background-color: white;
+            }
+
             a {
                 text-align: center;
                 display: block;
             a {
                 text-align: center;
                 display: block;
index fde574b..f8be8a7 100644 (file)
 
 
             <ul id="main-menu">
 
 
             <ul id="main-menu">
-                <li><a href="{% url 'book_list' %}">{% trans "Literature" %}</a></li>
-                <li><a href="{% url 'theme_catalogue' %}">{% trans "Themes" %}</a></li>
-                <li><a href="{% url 'audiobook_list' %}">{% trans "Audiobooks" %}</a></li>
-                <li><a href="{% url 'gallery' %}">{% trans "Gallery" %}</a></li>
-                <li><a href="{% url 'catalogue' %}">Wszystkie utwory</a></li>
+                <li{% if active_menu_item == 'books' %} class="active"{% endif %}>
+                    <a href="{% url 'book_list' %}">{% trans "Literature" %}</a>
+                </li>
+                <li{% if active_menu_item == 'theme' %} class="active"{% endif %}>
+                    <a href="{% url 'theme_catalogue' %}">{% trans "Themes" %}</a>
+                </li>
+                <li{% if active_menu_item == 'audiobooks' %} class="active"{% endif %}>
+                    <a href="{% url 'audiobook_list' %}">{% trans "Audiobooks" %}</a>
+                </li>
+                <li{% if active_menu_item == 'gallery' %} class="active"{% endif %}>
+                    <a href="{% url 'gallery' %}">{% trans "Gallery" %}</a>
+                </li>
+                <li{% if active_menu_item == 'all_works' %} class="active"{% endif %}>
+                    <a href="{% url 'catalogue' %}">{% trans "All works" %}</a>
+                </li>
             </ul>
 
 
             </ul>