changeset 1546:a0ffc13ab580

Itemviews duplicated code removed from foobar theme
author Jaiditya Mathur <jaiditya.mathur@gmail.com>
date Thu, 19 Jul 2012 03:34:42 +0530
parents 0f1edeab79c9
children db4b1477d53d
files MoinMoin/themes/foobar/templates/itemviews.html MoinMoin/themes/foobar/templates/local.html
diffstat 2 files changed, 2 insertions(+), 186 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/themes/foobar/templates/itemviews.html	Thu Jul 19 03:20:17 2012 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-{% set exists = storage.has_item(item_name) %}
-<ul class="moin-itemviews">
-    {%- 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 in [
-                'frontend.show_item', 'frontend.index', 'frontend.highlight_item',
-                'frontend.show_item_meta', 'frontend.download_item',
-                'frontend.history', 'frontend.backrefs', 'frontend.sitemap',
-                'frontend.similar_names', 'frontend.copy_item',
-            ] %}
-                <li>
-                    <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                </li>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.modify_item' and user.may.write(item_name) %}
-                <li>
-                    <a class="moin-modify-button" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                </li>
-            {%- endif %}
-
-            {%- if endpoint in [
-                'frontend.rename_item', 'frontend.delete_item',
-            ] and user.may.write(item_name) %}
-                <li>
-                    <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                </li>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.destroy_item' and user.may.destroy(item_name) %}
-                <li>
-                    <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                </li>
-            {%- endif %}
-
-            {%- if endpoint in [
-                'frontend.global_history', 'frontend.global_index', 'frontend.global_tags',
-                'admin.index', 'admin.index_user',
-            ] %}
-                <li>
-                    <a href="{{ url_for(endpoint) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                </li>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.quicklink_item' and user.valid %}
-                <li>
-                    <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        {%- if user.is_quicklinked_to([item_name]) %}
-                            {{ _('Remove Link') }}
-                        {%- else %}
-                            {{ _('Add Link') }}
-                        {%- endif %}
-                    </a>
-                </li>
-            {%- endif %}
-
-            {%- if endpoint == 'frontend.subscribe_item' and user.valid %}
-                <li>
-                    <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                        {%- if user.is_subscribed_to([item_name]) %}
-                            {{ _('Unsubscribe') }}
-                        {%- else %}
-                            {{ _('Subscribe') }}
-                        {%- endif %}
-                    </a>
-                </li>
-            {%- endif %}
-
-            {%- if endpoint == 'special.comments' %}
-                <li class="toggleCommentsButton" style="display:none;">
-                    <a href="#" onClick="toggleComments();return false;" title="{{ title }}">{{ label }}</a>
-                </li>
-            {%- endif %}
-
-            {%- if endpoint == 'special.supplementation' %}
-                {%- for sub_item_name in cfg.supplementation_item_names %}
-                    {%- set current_sub = item_name.rsplit('/', 1)[-1] %}
-                    {%- if not current_sub in cfg.supplementation_item_names %}
-                        {%- set supp_name = '%s/%s' % (item_name, sub_item_name) %}
-                        {%- if storage.has_item(supp_name) or user.may.write(supp_name) %}
-                            <li>
-                                <a href="{{ url_for('frontend.show_item', item_name=supp_name) }}" rel="nofollow">{{ _(sub_item_name) }}</a>
-                            </li>
-                        {%- endif %}
-                    {%- endif %}
-                {%- endfor %}
-            {%- endif %}
-        {%- endif %}
-    {%- endfor %}
-</ul>
--- a/MoinMoin/themes/foobar/templates/local.html	Thu Jul 19 03:20:17 2012 +0530
+++ b/MoinMoin/themes/foobar/templates/local.html	Thu Jul 19 03:34:42 2012 +0530
@@ -1,5 +1,6 @@
 {% extends theme("layout.html") %}
 {% import "utils.html" as utils %}
+{% import "itemviews.html" as itemviews with context %}
 
 {% block content_container %}
 <div id="moin-content" lang="{{ theme_supp.content_lang }}" dir="{{ theme_supp.content_dir }}">
@@ -15,102 +16,7 @@
 {% block local %}
 <ul>
     <li>Views
-        {% set exists = storage.has_item(item_name) %}
-        <ul class="moin-itemviews">
-            {%- 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 in [
-                        'frontend.show_item', 'frontend.index', 'frontend.highlight_item',
-                        'frontend.show_item_meta', 'frontend.download_item',
-                        'frontend.history', 'frontend.backrefs', 'frontend.sitemap',
-                        'frontend.similar_names', 'frontend.copy_item',
-                    ] %}
-                        <li>
-                            <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                        </li>
-                    {%- endif %}
-
-                    {%- if endpoint == 'frontend.modify_item' and user.may.write(item_name) %}
-                        <li>
-                            <a class="moin-modify-button" href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                        </li>
-                    {%- endif %}
-
-                    {%- if endpoint in [
-                        'frontend.rename_item', 'frontend.delete_item',
-                    ] and user.may.write(item_name) %}
-                        <li>
-                            <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                        </li>
-                    {%- endif %}
-
-                    {%- if endpoint == 'frontend.destroy_item' and user.may.destroy(item_name) %}
-                        <li>
-                            <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                        </li>
-                    {%- endif %}
-
-                    {%- if endpoint in [
-                        'frontend.global_history', 'frontend.global_index', 'frontend.global_tags',
-                        'admin.index', 'admin.index_user',
-                    ] %}
-                        <li>
-                            <a href="{{ url_for(endpoint) }}" title="{{ title }}" rel="nofollow">{{ label }}</a>
-                        </li>
-                    {%- endif %}
-
-                    {%- if endpoint == 'frontend.quicklink_item' and user.valid %}
-                        <li>
-                            <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                                {%- if user.is_quicklinked_to([item_name]) %}
-                                    {{ _('Remove Link') }}
-                                {%- else %}
-                                    {{ _('Add Link') }}
-                                {%- endif %}
-                            </a>
-                        </li>
-                    {%- endif %}
-
-                    {%- if endpoint == 'frontend.subscribe_item' and user.valid %}
-                        <li>
-                            <a href="{{ url_for(endpoint, item_name=item_name) }}" title="{{ title }}" rel="nofollow">
-                                {%- if user.is_subscribed_to([item_name]) %}
-                                    {{ _('Unsubscribe') }}
-                                {%- else %}
-                                    {{ _('Subscribe') }}
-                                {%- endif %}
-                            </a>
-                        </li>
-                    {%- endif %}
-
-                    {%- if endpoint == 'special.comments' %}
-                        <li class="moin-toggle-comments-button" style="display:none;">
-                            <a href="#" onClick="toggleComments();return false;" title="{{ title }}">{{ label }}</a>
-                        </li>
-                    {%- endif %}
-                 
-                {% if endpoint == 'special.transclusions' -%}
-                    <li class="moin-transclusions-button" style="display:none;">
-                    <a href="#" onClick="toggleTransclusionOverlays();return false;" title="{{ title }}">{{ label }}</a>
-                    </li>
-                {%- endif %}                    
-
-                    {%- if endpoint == 'special.supplementation' %}
-                        {%- for sub_item_name in cfg.supplementation_item_names %}
-                            {%- set current_sub = item_name.rsplit('/', 1)[-1] %}
-                            {%- if not current_sub in cfg.supplementation_item_names %}
-                                {%- set supp_name = '%s/%s' % (item_name, sub_item_name) %}
-                                {%- if storage.has_item(supp_name) or user.may.write(supp_name) %}
-                                    <li>
-                                        <a href="{{ url_for('frontend.show_item', item_name=supp_name) }}" rel="nofollow">{{ _(sub_item_name) }}</a>
-                                    </li>
-                                {%- endif %}
-                            {%- endif %}
-                        {%- endfor %}
-                    {%- endif %}
-                {%- endif %}
-            {%- endfor %}
-        </ul>
+        {{ itemviews }}    
     </li>
     {% if rev %}
     <li>Metadata