changeset 146:751ebb4ff42b

modernized theme: killed "More" menu, put everything into editbar (for now) this is just a first step and there needs to be more work done to make this more pretty / more usable. killed the actionsMenuInit js code (was a bit unpretty anyway, caused jumping of editbar) killed actions_menu_options method from the theme support (not needed any more) reordered editbar so that some groups appear (separated by *): * read views * modify views * global views
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 20 Mar 2011 17:00:45 +0100
parents eade7d9989a1
children c7e83ed2ee4b
files MoinMoin/config/default.py MoinMoin/static/js/common.js MoinMoin/templates/base.html MoinMoin/templates/editbar.html MoinMoin/themes/__init__.py
diffstat 5 files changed, 66 insertions(+), 90 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/config/default.py	Sun Mar 20 06:57:17 2011 -0700
+++ b/MoinMoin/config/default.py	Sun Mar 20 17:00:45 2011 +0100
@@ -355,7 +355,7 @@
     ('trail_size', 5,
      "Number of items in the trail of recently visited items"),
 
-    ('edit_bar', ['Show', 'Highlight', 'Meta', 'Modify', 'Comments', 'Download', 'History', 'Subscribe', 'Quicklink', 'Index', 'Supplementation', 'ActionsMenu'],
+    ('edit_bar', ['Show', 'Highlight', 'Meta', 'Modify', 'Comments', 'Download', 'History', 'Subscribe', 'Quicklink', 'Index', 'Supplementation', 'GlobalHistory', 'GlobalIndex', 'GlobalTags', 'WhatRefersHere', 'SiteMap', 'SimilarItems', 'Copy', 'Rename', 'Delete', 'Destroy', 'Administration', ],
      'list of edit bar entries'),
     ('history_count', (100, 200), "number of revisions shown for info/history action (default_count_shown, max_count_shown)"),
 
--- a/MoinMoin/static/js/common.js	Sun Mar 20 06:57:17 2011 -0700
+++ b/MoinMoin/static/js/common.js	Sun Mar 20 17:00:45 2011 +0100
@@ -42,31 +42,6 @@
     }
 }
 
-function actionsMenuInit(title) {
-    // Initialize action menu
-    for (i = 0; i < document.forms.length; i++) {
-        var form = document.forms[i];
-        if (form.className == 'moin-actionsmenu') {
-            // Check if this form needs update
-            var div = form.getElementsByTagName('div')[0];
-            var label = div.getElementsByTagName('label')[0];
-            if (label) {
-                // This is the first time: remove label and do buton.
-                div.removeChild(label);
-                var dobutton = div.getElementsByTagName('input')[0];
-                div.removeChild(dobutton);
-                // and add menu title
-                var select = div.getElementsByTagName('select')[0];
-                var item = document.createElement('option');
-                item.appendChild(document.createTextNode(title));
-                item.value = 'frontend.show_item';
-                select.insertBefore(item, select.options[0]);
-                select.selectedIndex = 0;
-            }
-        }
-    }
-}
-
 // use this instead of assigning to window.onload directly:
 function addLoadEvent(func) {
     // alert("addLoadEvent " + func)
--- a/MoinMoin/templates/base.html	Sun Mar 20 06:57:17 2011 -0700
+++ b/MoinMoin/templates/base.html	Sun Mar 20 17:00:45 2011 +0100
@@ -63,7 +63,7 @@
     {% endblock %}
 {% endblock %}
 </head>
-<body onload="actionsMenuInit('{{ _('More') }}'); {% if body_onload %}{{ body_onload }}{% endif %}" lang="{{ theme_supp.ui_lang }}" dir="{{ theme_supp.ui_dir }}">
+<body{% if body_onload %} onload="{{ body_onload }}"{% endif %} lang="{{ theme_supp.ui_lang }}" dir="{{ theme_supp.ui_dir }}">
 {% block layout %}
     <h1>Extend this block only if you want to change layout. If you want to put content, extends layout.html and use placeholders item and content.</h1>
 {% endblock %}
--- a/MoinMoin/templates/editbar.html	Sun Mar 20 06:57:17 2011 -0700
+++ b/MoinMoin/templates/editbar.html	Sun Mar 20 17:00:45 2011 +0100
@@ -15,15 +15,6 @@
         <a href="{{ url_for('frontend.show_item_meta', item_name=item_name) }}" rel="nofollow"> {{ _('Meta') }}</a>
         </li>
     {%- endif %}
-    {% if 'Modify' in cfg.edit_bar and 'modify' not in cfg.actions_excluded -%}
-        <li>
-        {% if user.may.write(item_name) %}
-            <a href="{{ url_for('frontend.modify_item', item_name=item_name) }}" rel="nofollow"> {{ _('Modify') }}</a>
-        {% else %}
-            {{ _('Immutable Item')}}
-        {% endif %}
-        </li>
-    {%- endif %}
     {% if exists and 'Download' in cfg.edit_bar and 'get' not in cfg.actions_excluded -%}
         <li>
             <a href="{{ url_for('frontend.get_item', item_name=item_name) }}" rel="nofollow">{{ _('Download') }}</a>
@@ -81,23 +72,71 @@
             {%- endif %}
         {%- endfor -%}
     {%- endif %}
-    {% if 'ActionsMenu' in cfg.edit_bar %}
+    {% if exists and 'WhatRefersHere' in cfg.edit_bar and 'backrefs' not in cfg.actions_excluded -%}
         <li>
-            <form class="moin-actionsmenu" method="GET" action="{{ url_for('frontend.dispatch') }}">
-                <div>
-                    <label>{{ _('More Actions:') }}</label>
-                    <select name="endpoint" class="moin-actionsmenu-select">
-                        {% for title, disabled, endpoint in theme_supp.actions_menu_options(item_name) %}
-                            <option value="{{ endpoint }}"{% if disabled %} disabled class="disabled"{% endif %}>{{ title }}</option>
-                        {% endfor %}
-                    </select>
-                    <input type="submit" value="{{ _('Do') }}" /> {# XXX current js relies in this being first input elem! #}
-                    <input type="hidden" name="item_name" value="{{ item_name }}" />
-                    {% if rev %}
-                        <input type="hidden" name="rev" value="{{ rev.revno }}" />
-                    {% endif %}
-                </div>
-            </form>
+        <a href="{{ url_for('frontend.backrefs', item_name=item_name) }}" rel="nofollow"> {{ _('What refers here?') }}</a>
+        </li>
+    {%- endif %}
+    {% if exists and 'SiteMap' in cfg.edit_bar and 'sitemap' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.sitemap', item_name=item_name) }}" rel="nofollow"> {{ _('Local Site Map') }}</a>
+        </li>
+    {%- endif %}
+    {% if exists and 'SimilarItems' in cfg.edit_bar and 'similar_names' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.similar_names', item_name=item_name) }}" rel="nofollow"> {{ _('Items with similar names') }}</a>
+        </li>
+    {%- endif %}
+    <li>*</li>
+    {% if 'Modify' in cfg.edit_bar and 'modify' not in cfg.actions_excluded -%}
+        <li>
+        {% if user.may.write(item_name) %}
+            <a href="{{ url_for('frontend.modify_item', item_name=item_name) }}" rel="nofollow"> {{ _('Modify') }}</a>
+        {% else %}
+            {{ _('Immutable Item')}}
+        {% endif %}
+        </li>
+    {%- endif %}
+    {% if exists and 'Copy' in cfg.edit_bar and 'copy' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.copy_item', item_name=item_name) }}" rel="nofollow"> {{ _('Copy') }}</a>
+        </li>
+    {%- endif %}
+    {% if exists and 'Rename' in cfg.edit_bar and 'rename' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.rename_item', item_name=item_name) }}" rel="nofollow"> {{ _('Rename') }}</a>
+        </li>
+    {%- endif %}
+    {% if exists and 'Delete' in cfg.edit_bar and 'delete' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.delete_item', item_name=item_name) }}" rel="nofollow"> {{ _('Delete') }}</a>
+        </li>
+    {%- endif %}
+    {% if exists and 'Destroy' in cfg.edit_bar and 'destroy' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.destroy_item', item_name=item_name) }}" rel="nofollow"> {{ _('Destroy') }}</a>
+        </li>
+    {%- endif %}
+    <li>*</li>
+    {% if 'GlobalHistory' in cfg.edit_bar and 'global_history' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.global_history') }}" rel="nofollow"> {{ _('Global History') }}</a>
+        </li>
+    {%- endif %}
+    {% if 'GlobalIndex' in cfg.edit_bar and 'global_index' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.global_index') }}" rel="nofollow"> {{ _('Global Items Index') }}</a>
+        </li>
+    {%- endif %}
+    {% if 'GlobalTags' in cfg.edit_bar and 'global_tags' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('frontend.global_tags') }}" rel="nofollow"> {{ _('Global Tags Index') }}</a>
+        </li>
+    {%- endif %}
+    <li>*</li>
+    {% if 'Administration' in cfg.edit_bar and 'admin' not in cfg.actions_excluded -%}
+        <li>
+        <a href="{{ url_for('admin.index') }}" rel="nofollow"> {{ _('Administration & Docs') }}</a>
         </li>
     {%- endif %}
 </ul>
--- a/MoinMoin/themes/__init__.py	Sun Mar 20 06:57:17 2011 -0700
+++ b/MoinMoin/themes/__init__.py	Sun Mar 20 17:00:45 2011 +0100
@@ -280,44 +280,6 @@
             url = url or url_for('frontend.login')
         return url
 
-    def actions_menu_options(self, item_name):
-        """
-        Create actions menu list and items data dict
-
-        The menu will contain the same items always, but items that are
-        not available will be disabled (some broken browsers will let
-        you select disabled options though).
-
-        The menu should give best user experience for javascript
-        enabled browsers, and acceptable behavior for those who prefer
-        not to use Javascript.
-
-        :rtype: list
-        :returns: options of actions menu
-        """
-        not_exists = not flaskg.storage.has_item(item_name)
-        menu = [
-            # title, internal name, endpoint, disabled
-            (_('Global History'), 'global_history', 'frontend.global_history', False, ),
-            (_('Global Items Index'), 'global_index', 'frontend.global_index', False, ),
-            (_('Global Tags Index'), 'global_tags', 'frontend.global_tags', False, ),
-            # Translation may need longer or shorter separator:
-            (_('-----------------------------------'), 'show', 'frontend.show_item', True),
-            (_('What refers here?'), 'backrefs', 'frontend.backrefs', False, ),
-            (_('Local Site Map'), 'sitemap', 'frontend.sitemap', not_exists, ),
-            (_('Items with similar names'), 'similar_names', 'frontend.similar_names', False, ),
-            (_('-----------------------------------'), 'show', 'frontend.show_item', True),
-            (_('Copy Item'), 'copy', 'frontend.copy_item', not_exists, ),
-            (_('Rename Item'), 'rename', 'frontend.rename_item', not_exists, ),
-            (_('Delete Item'), 'delete', 'frontend.delete_item', not_exists, ),
-            (_('Destroy Item'), 'destroy', 'frontend.destroy_item', not_exists, ),
-            (_('-----------------------------------'), 'show', 'frontend.show_item', True),
-            (_('Administration & Docs'), 'admin', 'admin.index', False, ),
-        ]
-        return [(title, disabled, endpoint)
-                for title, action, endpoint, disabled in menu
-                if action not in self.cfg.actions_excluded]
-
 
 def get_editor_info(rev, external=False):
     addr = rev.get(ADDRESS)