allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john...@apache.org
Subject [48/50] git commit: [#5913] Added breadcrumb navigation to project header
Date Tue, 28 May 2013 16:01:40 GMT
[#5913] Added breadcrumb navigation to project header

Signed-off-by: Cory Johns <cjohns@slashdotmedia.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/d154a867
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/d154a867
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/d154a867

Branch: refs/heads/cj/5913
Commit: d154a867930d995a86c783ed81822078c4c35700
Parents: b4a9f1b
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Tue May 21 23:18:06 2013 +0000
Committer: Cory Johns <cjohns@slashdotmedia.com>
Committed: Tue May 28 15:54:58 2013 +0000

----------------------------------------------------------------------
 Allura/allura/model/project.py                     |   18 ++++++++++++
 Allura/allura/nf/allura/css/site_style.css         |   22 +++++++++++++++
 Allura/allura/templates/jinja_master/nav_menu.html |    2 +
 .../templates/jinja_master/theme_macros.html       |   18 ++++++++++++
 4 files changed, 60 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d154a867/Allura/allura/model/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index e98b44c..c11c148 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -117,6 +117,24 @@ class TroveCategory(MappedClass):
             trove = trove.parent_category
         return trove.shortname
 
+    @LazyProperty
+    def ancestors(self):
+        ancestors = []
+        trove = self
+        while trove:
+            ancestors.append(trove)
+            trove = trove.parent_category
+        return ancestors
+
+    @LazyProperty
+    def breadcrumbs(self):
+        url = '/directory/'
+        crumbs = []
+        for trove in reversed(self.ancestors[:-1]):
+            url += trove.shortname + '/'
+            crumbs.append((trove.fullname, url))
+        return crumbs
+
 class ProjectMapperExtension(MapperExtension):
     def after_insert(self, obj, st, sess):
         g.zarkov_event('project_create', project=obj)

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d154a867/Allura/allura/nf/allura/css/site_style.css
----------------------------------------------------------------------
diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css
index b067f6d..cfbfc9e 100644
--- a/Allura/allura/nf/allura/css/site_style.css
+++ b/Allura/allura/nf/allura/css/site_style.css
@@ -2095,6 +2095,28 @@ nav .ico {
     margin: 0 0 15px;
 }
 
+#nav_menu_holder #breadcrumbs {
+    margin-bottom: 5px;
+}
+
+#nav_menu_holder #breadcrumbs ul {
+    list-style: none;
+    margin: 0;
+}
+
+#nav_menu_holder #breadcrumbs li {
+    display: inline;
+    font-size: 11px;
+}
+
+#nav_menu_holder #breadcrumbs li:after {
+    content: ' / ';
+}
+
+#nav_menu_holder #breadcrumbs li:last-child:after {
+    content: '';
+}
+
 #nav_menu_holder h1.project_title {
   line-height: 1em;
   font-size: 32px;

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d154a867/Allura/allura/templates/jinja_master/nav_menu.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html
index 74f7509..724ca1c 100644
--- a/Allura/allura/templates/jinja_master/nav_menu.html
+++ b/Allura/allura/templates/jinja_master/nav_menu.html
@@ -17,10 +17,12 @@
        under the License.
 -#}
 {% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+{% import g.theme.jinja_macros as theme_macros with context %}
 {% set n = c.project.neighborhood %}
 {% if not c.project or (n.neighborhood_project == c.project and not n.show_title) %}
   <div id="nav_menu_missing"></div>
 {% else %}
+  {{ theme_macros.breadcrumbs(c.project, c.app) }}
   {% if c.project.neighborhood.icon %}
     <a href="{{c.project.neighborhood.url()}}"><img src="{{c.project.neighborhood.url()}}/icon"
class="neighborhood_icon"
        alt="Return to {{c.project.neighborhood.name}}" title="Return to {{c.project.neighborhood.name}}"></a>

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/d154a867/Allura/allura/templates/jinja_master/theme_macros.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/jinja_master/theme_macros.html b/Allura/allura/templates/jinja_master/theme_macros.html
index e1c9903..a493075 100644
--- a/Allura/allura/templates/jinja_master/theme_macros.html
+++ b/Allura/allura/templates/jinja_master/theme_macros.html
@@ -78,3 +78,21 @@
 {%- macro extra_header(path_to_static) %}
 
 {%- endmacro %}
+
+{%- macro breadcrumbs(project, app) %}
+    <nav id="breadcrumbs">
+        <ul>
+            <li><a href="/">Home</a></li>
+            {% for label,url in project.breadcrumbs() %}
+                {% if not loop.last or app %}
+                    <li><a href="{{ url }}">{{ label }}</a></li>
+                {% else %}
+                    <li>{{ label }}</li>
+                {% endif %}
+            {% endfor %}
+            {% if app %}
+                <li>{{ app.config.options.mount_label }}</li>
+            {% endif %}
+        </ul>
+    </nav>
+{%- endmacro %}


Mime
View raw message