changeset 2378:bff46cb932d1

Refactoring rendering of local tabs, local panel, fixes #21
author sharky93 <rishabhr123@gmail.com>
date Wed, 14 Aug 2013 20:26:44 +0530
parents 605b3327c016
children 095250a9fd84
files MoinMoin/themes/basic/templates/itemviews.html MoinMoin/themes/basic/templates/show.html
diffstat 2 files changed, 50 insertions(+), 110 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/themes/basic/templates/itemviews.html	Sun Aug 11 12:16:36 2013 +0530
+++ b/MoinMoin/themes/basic/templates/itemviews.html	Wed Aug 14 20:26:44 2013 +0530
@@ -1,82 +1,59 @@
 {% set exists = storage.has_item(item_name) %}
 {% set current_endpoint = request.endpoint %}
 
+{% set icon = {'frontend.show_item' : "icon-eye-open",
+               'frontend.modify_item' : "icon-pencil",
+               'frontend.history' : "icon-time",
+               'frontend.show_item_meta' : "icon-wrench",
+               'frontend.highlight_item' : "icon-picture",
+               'frontend.backrefs' : "icon-share",
+               'special.comments' : "icon-comment",
+               'special.transclusions' : "icon-edit",
+           } %}
+
+{% set navtabs = ['frontend.show_item', 'frontend.modify_item', 'frontend.history',
+                  'frontend.show_item_meta', 'frontend.highlight_item', 'frontend.backrefs',
+                  'special.comments', 'special.transclusions',] %}
+
 {% block views %}
 
     <ul class="moin-nav nav-tabs moin-shadow">
         {%- for endpoint, label, title, check_exists in cfg.item_views if not endpoint in cfg.endpoints_excluded %}
             {%- if not check_exists or check_exists and exists %}
 
-                {%- if endpoint == 'frontend.show_item' %}
-                    <li {% if endpoint == current_endpoint %} class="active"{% endif %}>
-                        <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        <span class="icon-eye-open"></span>
-                            {{ label }}
-                        </a>
-                    </li>
-                {%- endif %}
-
                 {%- if endpoint == 'frontend.modify_item' and user.may.write(item_name) %}
                     <li {% if endpoint == current_endpoint %} class="active"{% endif %}>
                         <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                         <span class="icon-pencil"></span>   {{ label }}
-                        </a>
-                    </li>
-                {%- endif %}
-
-                {%- if endpoint == 'frontend.history' %}
-                    <li {% if endpoint == current_endpoint %} class="active"{% endif %}>
-                        <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        <span class="icon-time"></span>
-                            {{ label }}
-                        </a>
-                    </li>
-                {%- endif %}
-
-                {%- if endpoint == 'frontend.show_item_meta' %}
-                    <li {% if endpoint == current_endpoint %} class="active"{% endif %}>
-                        <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        <span class="icon-wrench"></span>
+                         <span class={{icon[endpoint]}}></span>   
                             {{ label }}
                         </a>
                     </li>
-                {%- endif %}
 
-                {%- if endpoint == 'frontend.highlight_item' %}
-                    <li {% if endpoint == current_endpoint %} class="active"{% endif %}>
-                        <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        <span class="icon-picture"></span>
+                {%- elif endpoint == 'special.comments' %}
+                    <li class="moin-toggle-comments-button">
+                        <a href="#" title="{{ title }}">
+                        <span class={{icon[endpoint]}}></span>
                             {{ label }}
                         </a>
                     </li>
-                {%- endif %}
 
-                {%- if endpoint == 'frontend.backrefs' %}
-                    <li {% if endpoint == current_endpoint %} class="active"{% endif %}>
-                        <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        <span class="icon-share"></span>
+                {% elif endpoint == 'special.transclusions' -%}
+                    <li class="moin-transclusions-button">
+                        <a href="#" title="{{ title }}">
+                        <span class={{icon[endpoint]}}></span>
                             {{ label }}
                         </a>
                     </li>
-                {%- endif %}
 
-                {%- if endpoint == 'special.comments' %}
-                    <li class="moin-toggle-comments-button">
-                        <a href="#" title="{{ title }}">
-                        <span class="icon-comment"></span>
+                {%- elif endpoint in navtabs %}
+                    <li {% if endpoint == current_endpoint %} class="active"{% endif %}>
+                        <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
+                        <span class={{icon[endpoint]}}></span>
                             {{ label }}
                         </a>
                     </li>
                 {%- endif %}
 
-                {% if endpoint == 'special.transclusions' -%}
-                    <li class="moin-transclusions-button">
-                        <a href="#" title="{{ title }}">
-                        <span class="icon-edit"></span>
-                            {{ label }}</a>
-                    </li>
-                {%- endif %}
-
             {%- endif %}
         {% endfor %}
 
--- a/MoinMoin/themes/basic/templates/show.html	Sun Aug 11 12:16:36 2013 +0530
+++ b/MoinMoin/themes/basic/templates/show.html	Wed Aug 14 20:26:44 2013 +0530
@@ -3,6 +3,23 @@
 {% import theme("itemviews.html") as itemviews with context %}
 {% set exists = storage.has_item(item_name) %}
 
+{% set icon = {'frontend.quicklink_item' : "icon-star-empty",
+               'frontend.subscribe_item' : "icon-envelope",
+               'frontend.index' : "icon-list-alt",
+               'frontend.sitemap' : "icon-map-marker",
+               'frontend.rename_item' : "icon-tag",
+               'frontend.delete_item' : "icon-trash",
+               'frontend.destroy_item' : "icon-fire",
+               'frontend.similar_names' : "icon-search",
+               'frontend.download_item' : "icon-download-alt",
+               'frontend.copy_item' : "icon-comment",
+           } %}
+
+{% set item_navigation = ['frontend.index', 'frontend.sitemap', ] %}
+
+{% set item_actions = ['frontend.rename_item', 'frontend.delete_item', 'frontend.destroy_item',
+                       'frontend.similar_names', 'frontend.download_item', 'frontend.copy_item',] %}
+
 {% block views %}
     {{ itemviews }}
 {% endblock %}
@@ -27,7 +44,7 @@
             {%- if endpoint == 'frontend.quicklink_item' and user.valid %}
                 <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
                     <span class="icon-stack">
-                        <i class="icon-star-empty"></i>
+                        <i class={{icon[endpoint]}}></i>
                     </span>
                     {%- if user.is_quicklinked_to([item_name]) %}
                         {{ _('Remove Link') }}
@@ -40,7 +57,7 @@
             {%- if endpoint == 'frontend.subscribe_item' and user.valid %}
                 <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
                     <span class="icon-stack">
-                        <i class="icon-envelope"></i>
+                        <i class={{icon[endpoint]}}></i>
                     </span>
                     {%- if user.is_subscribed_to([item_name]) %}
                         {{ _('Unsubscribe') }}
@@ -58,19 +75,10 @@
     {%- for endpoint, label, title, check_exists in cfg.item_views if not endpoint in cfg.endpoints_excluded %}
         {%- if not check_exists or check_exists and exists %}
 
-            {%- if endpoint == 'frontend.index' %}
+            {%- if endpoint in item_navigation %}
                 <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
                 <span class="icon-stack">    
-                    <i class="icon-list-alt"></i>
-                </span>
-                    {{ label }}
-                </a>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.sitemap' %}
-                <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                <span class="icon-stack">
-                    <i class="icon-map-marker"></i>
+                    <i class={{icon[endpoint]}}></i>
                 </span>
                     {{ label }}
                 </a>
@@ -85,55 +93,10 @@
     {%- for endpoint, label, title, check_exists in cfg.item_views if not endpoint in cfg.endpoints_excluded %}
         {%- if not check_exists or check_exists and exists %}
 
-            {%- if endpoint == 'frontend.rename_item' and user.may.write(item_name) %}
-                <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                <span class="icon-stack">
-                    <i class="icon-tag"></i>
-                </span>
-                    {{ label }}
-                </a>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.delete_item' and user.may.write(item_name) %}
-                <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                <span class="icon-stack">
-                    <i class="icon-trash"></i>
-                </span>
-                    {{ label }}
-                </a>
-            {% endif %}
-
-            {%- if endpoint == 'frontend.destroy_item' and user.may.destroy(item_name) %}
+            {%- if endpoint in item_actions and user.may.write(item_name) %}
                 <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
                 <span class="icon-stack">
-                    <i class="icon-fire"></i>
-                </span>
-                    {{ label }}
-                </a>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.similar_names' and user.may.write(item_name) %}
-                <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                <span class="icon-stack">
-                    <i class="icon-search"></i>
-                </span>
-                    {{ label }}
-                </a>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.download_item' and user.may.write(item_name) %}
-                <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                <span class="icon-stack">
-                    <i class="icon-download-alt"></i>
-                </span>
-                    {{ label }}
-                </a>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.copy_item' and user.may.write(item_name) %}
-                <a class="list-group-item" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                <span class="icon-stack">
-                    <i class="icon-comment"></i>
+                    <i class={{icon[endpoint]}}></i>
                 </span>
                     {{ label }}
                 </a>