changeset 2253:46b74c363c6f

UI for indicating multiple names and switching namespaces.
author Ashutosh Singla <ashu1461@gmail.com>
date Mon, 02 Sep 2013 17:41:54 +0530
parents ecd43cdbb9b6
children 1ba1a9c6c3b2
files MoinMoin/templates/layout.html MoinMoin/themes/__init__.py MoinMoin/themes/modernized/static/css/stylus/main.styl
diffstat 3 files changed, 85 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/templates/layout.html	Tue Aug 27 19:11:15 2013 +0530
+++ b/MoinMoin/templates/layout.html	Mon Sep 02 17:41:54 2013 +0530
@@ -71,22 +71,40 @@
         <span id="moin-pagelocation">
             <span class="moin-pagepath">
             {% block pagepath %}
-                {% for segment_name, segment_path, exists in theme_supp.location_breadcrumbs(fqname) -%}
-                    {% 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_fqname }}
-                        </a>
-                        <span class="sep">/</span>
-                    {% else %}
-                        {% if title_name %}
-                            {{ title_name }}
-                        {% else %}
-                        <a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}>
-                            {{ segment_name|shorten_fqname }}
-                        </a>
-                        {%- endif %}
-                    {%- endif %}
-                {%- endfor %}
+            {% for segment_name, segment_path, exists in theme_supp.location_breadcrumbs(fqname) -%}
+                {% if loop.first %}
+                    <ul class="moin-bcs-item"><li>
+                {% endif %}
+                {% 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_fqname }}
+                    </a>
+                    {% if loop.first %}
+                        <ul class="moin-bcs-subitems">
+                            {% for namespace, root in theme_supp.get_namespaces(segment_name) -%}
+                            <li><a href="{{ url_for('frontend.show_item', item_name=root) }}">{{ namespace }}</a></li>
+                           {%- endfor %}
+                        </ul></li>
+                        </ul>
+                    {% endif %}
+                    <span class="sep">/</span>
+                {% else %}
+                     {% if title_name %}
+                        {{ title_name }}
+                     {% else %}
+                        <ul class="moin-bcs-item">
+                            <li><a href="{{ url_for('frontend.show_item', item_name=segment_path) }}" {% if not exists %}class="moin-nonexistent"{% endif %}>
+                                {{ segment_name|shorten_fqname }}</a>
+                                <ul class="moin-bcs-subitems">
+                                    {% for fq_name in theme_supp.get_fqnames(segment_name) -%}
+                                        <li><a href="{{ url_for('frontend.show_item', item_name=fq_name) }}">{{ fq_name|shorten_fqname(length=7) }}</a></li>
+                                    {%- endfor %}
+                                </ul>
+                            </li>
+                        </ul>
+                     {%- endif %}
+                {%- endif %}
+            {%- endfor %}
             {% endblock %}
             </span>
         </span>
--- a/MoinMoin/themes/__init__.py	Tue Aug 27 19:11:15 2013 +0530
+++ b/MoinMoin/themes/__init__.py	Mon Sep 02 17:41:54 2013 +0530
@@ -298,6 +298,31 @@
             url = url or url_for('frontend.login')
         return url
 
+    def get_fqnames(self, fqname):
+        """
+        Return the list of other fqnames associated with the item.
+        """
+        if fqname.field != NAME_EXACT:
+            return []
+        item = self.storage.get_item(**fqname.query)
+        fqnames = item.fqnames
+        fqnames.remove(fqname)
+        return fqnames or []
+
+    def get_namespaces(self, ns):
+        """
+        Return the list of tuples (composite name, namespace) referring to namespaces other
+        than the current namespace.
+        """
+        ns = u'' if ns.value == '~' else ns.value
+        namespace_root_mapping = []
+        for namespace, _ in app.cfg.namespace_mapping:
+            namespace = namespace.rstrip('/')
+            if namespace != ns:
+                fq_namespace = CompositeName(namespace, NAME_EXACT, u'')
+                namespace_root_mapping.append((namespace or '~', fq_namespace.get_root_fqname()))
+        return namespace_root_mapping
+
 
 def get_editor_info(meta, external=False):
     addr = meta.get(ADDRESS)
--- a/MoinMoin/themes/modernized/static/css/stylus/main.styl	Tue Aug 27 19:11:15 2013 +0530
+++ b/MoinMoin/themes/modernized/static/css/stylus/main.styl	Mon Sep 02 17:41:54 2013 +0530
@@ -1622,3 +1622,29 @@
     #moin-header, #moin-sidebar, #moin-footer, #moin-timings, #moin-credits, #moin-interwiki,
     #moin-pagelocation, #moin-pageinfo
         display none
+
+ul.moin-bcs-item ul.moin-bcs-subitems
+    background-color panel_color
+
+ul.moin-bcs-item, ul.moin-bcs-item ul.moin-bcs-subitems
+    padding 0
+    margin 0
+    display inline-block
+
+ul.moin-bcs-item li, ul.moin-bcs-item ul.moin-bcs-subitems li
+    list-style-type none
+    display block
+
+ul.moin-bcs-item li a, ul.moin-bcs-item li ul.moin-bcs-subitems li a
+    padding 5px
+    display inline-block
+
+ul.moin-bcs-item li
+    position relative
+
+ul.moin-bcs-item li ul.moin-bcs-subitems
+    display none
+    position absolute
+
+ul.moin-bcs-item li:hover ul.moin-bcs-subitems
+    display block