changeset 1123:ebc4f8213e74

Add a flat subitem index for show item view.
author Sam Toyer <samATqxcvDOTnet>
date Fri, 02 Dec 2011 16:46:24 +1000
parents b02f88f4428e
children f106f50a5d3c
files MoinMoin/templates/layout.html MoinMoin/templates/show.html MoinMoin/themes/__init__.py MoinMoin/themes/modernized/static/css/common.css
diffstat 4 files changed, 59 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/templates/layout.html	Thu Dec 01 21:20:45 2011 +1000
+++ b/MoinMoin/templates/layout.html	Fri Dec 02 16:46:24 2011 +1000
@@ -134,6 +134,8 @@
 
     {% block header_itemviews %}{% endblock %}
 
+    {% block subitem_navigation %}{% endblock %}
+
     {% for category, msg in get_flashed_messages(with_categories=true) %}
         <p class="moin-flash moin-flash-{{ category }}">{{ msg }}</p>
     {% endfor %}
--- a/MoinMoin/templates/show.html	Thu Dec 01 21:20:45 2011 +1000
+++ b/MoinMoin/templates/show.html	Fri Dec 02 16:46:24 2011 +1000
@@ -36,6 +36,33 @@
     </ul>
 {% endmacro %}
 
+{% block subitem_navigation %}
+    <div class="moin-subitem-navigation">
+        <span class="list-header">
+            {% for segment_name, segment_path, exists in theme_supp.location_breadcrumbs(item_name) %}
+                {% if not loop.last %}
+                    <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}"
+                        {% if not exists %}class="moin-nonexistent"{% endif %}>
+                        {{ segment_name | shorten_item_name }}
+                    </a>
+                    <span class="sep">/</span>
+                {% else %}
+                    {{ segment_name | shorten_item_name }}
+                    <span class="sep">/</span>
+                {% endif %}
+            {% endfor %}
+        </span>
+        <ul>
+            {% for item in theme_supp.subitem_index(item_name) %}
+                <li>
+                    <a href="{{ url_for('frontend.show_item', item_name=item[0]) }}">{{ item[1] }}</a>
+                    {% if item[-1] %}<span class="sep">/</span>{% endif %}
+                </li>
+            {% endfor %}
+        </ul>
+    </div>
+{% endblock %}
+
 {% block content %}
     {% if show_navigation %}
         {% block rev_navigation %}
--- a/MoinMoin/themes/__init__.py	Thu Dec 01 21:20:45 2011 +1000
+++ b/MoinMoin/themes/__init__.py	Fri Dec 02 16:46:24 2011 +1000
@@ -10,6 +10,8 @@
 
 import urllib
 
+from operator import itemgetter
+
 from flask import current_app as app
 from flask import g as flaskg
 from flask import url_for, request
@@ -113,6 +115,20 @@
             breadcrumbs.append((wiki_name, item_name, href, exists, err))
         return breadcrumbs
 
+    def subitem_index(self, item_name):
+        """
+        Get a list of subitems for the given item_name
+
+        :rtype: list
+        :returns: list of item tuples (item_name, item_title, item_mime_type, has_children)
+        """
+        from MoinMoin.items import Item
+        item = Item.create(item_name)
+        item_index = item.get_detailed_index(item.flat_index())
+        # Sort items by whether or not they have children, then by name:
+        item_index.sort(key=itemgetter(-1, 0))
+        return item_index
+
     def userhome(self):
         """
         Assemble arguments used to build user homepage link
--- a/MoinMoin/themes/modernized/static/css/common.css	Thu Dec 01 21:20:45 2011 +1000
+++ b/MoinMoin/themes/modernized/static/css/common.css	Fri Dec 02 16:46:24 2011 +1000
@@ -628,6 +628,20 @@
 .moin-itemviews form div { display: inline; margin: 0; }
 .moin-itemviews select { font-size: 100%; vertical-align: middle; }
 
+/* moin-header moin-subitem-navigation */
+.moin-subitem-navigation { clear: both; display: block; margin: 0; background: #C4D9FF; padding: 0; height: auto;
+                  font-size: 0.8em; border-bottom: 1px solid #4D7DA9; border-top: 1px solid #4D7DA9; margin-top: -1px; }
+.moin-subitem-navigation .list-header { display: inline-block; background: #81BBF2; padding: 4px 8px;}
+.moin-subitem-navigation .sep { font-size: 1.2em; margin-left: 0px; }
+.moin-subitem-navigation ul { display: inline-block; margin: 0; padding: 2px 8px; }
+.moin-subitem-navigation li { display: inline-block; padding: 0; margin: 4px 10px; line-height: 1em; }
+.moin-subitem-navigation a,
+.moin-subitem-navigation a:visited { color: #0044B3; }
+.moin-subitem-navigation a:hover { text-decoration: underline; }
+.moin-subitem-navigation form,
+.moin-subitem-navigation form div { display: inline; margin: 0; }
+.moin-subitem-navigation select { font-size: 100%; vertical-align: middle; }
+
 /* moin-page moin-footer */
 #moin-footer { clear: both; margin: 0 0; }
 #moin-footer hr { margin: 0; background-color: #ccc; }