Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A2054D2DD for ; Mon, 17 Dec 2012 16:57:28 +0000 (UTC) Received: (qmail 70289 invoked by uid 500); 17 Dec 2012 16:57:28 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 69903 invoked by uid 500); 17 Dec 2012 16:57:27 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 69456 invoked by uid 99); 17 Dec 2012 16:57:27 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Dec 2012 16:57:27 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5550E81DD3F; Mon, 17 Dec 2012 16:57:27 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tvansteenburgh@apache.org To: allura-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: git commit: [#4957] Group multiple tools of same type in navbar Message-Id: <20121217165727.5550E81DD3F@tyr.zones.apache.org> Date: Mon, 17 Dec 2012 16:57:27 +0000 (UTC) Updated Branches: refs/heads/tv/4957 27e8ee92c -> 7484b98a1 (forced update) [#4957] Group multiple tools of same type in navbar Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/7484b98a Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/7484b98a Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/7484b98a Branch: refs/heads/tv/4957 Commit: 7484b98a1b4335bd8353a9ecf9094dd89c87bc9f Parents: 60a070d Author: Tim Van Steenburgh Authored: Fri Dec 14 22:42:50 2012 +0000 Committer: Tim Van Steenburgh Committed: Mon Dec 17 16:55:43 2012 +0000 ---------------------------------------------------------------------- Allura/allura/app.py | 8 +++++- Allura/allura/controllers/project.py | 8 +++++ Allura/allura/model/project.py | 20 +++++++++++++- Allura/allura/nf/allura/css/site_style.css | 23 ++++++++++++++++ Allura/allura/templates/jinja_master/top_nav.html | 8 ++++- Allura/allura/templates/tool_list.html | 21 ++++++++++++++ 6 files changed, 84 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7484b98a/Allura/allura/app.py ---------------------------------------------------------------------- diff --git a/Allura/allura/app.py b/Allura/allura/app.py index 613e88d..9b2d43c 100644 --- a/Allura/allura/app.py +++ b/Allura/allura/app.py @@ -33,7 +33,8 @@ class ConfigOption(object): class SitemapEntry(object): - def __init__(self, label, url=None, children=None, className=None, ui_icon=None, small=None): + def __init__(self, label, url=None, children=None, className=None, + ui_icon=None, small=None, tool_name=None): self.label = label self.className = className if url is not None: @@ -44,6 +45,8 @@ class SitemapEntry(object): if children is None: children = [] self.children = children + self.tool_name = tool_name + self.matching_urls = [] def __getitem__(self, x): """ @@ -92,6 +95,9 @@ class SitemapEntry(object): self.children.append(e) child_index[lbl] = e + def matches_url(self, request): + return self.url in request.upath_info or any([ + url in request.upath_info for url in self.matching_urls]) class Application(object): """ http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7484b98a/Allura/allura/controllers/project.py ---------------------------------------------------------------------- diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py index 9c3c5c5..85cde3a 100644 --- a/Allura/allura/controllers/project.py +++ b/Allura/allura/controllers/project.py @@ -254,6 +254,13 @@ class HostNeighborhoodController(WsgiDispatchController, NeighborhoodController) nf = NewForgeController() search = SearchController() +class ToolListController(object): + @expose('jinja:allura:templates/tool_list.html') + def _default(self, tool_name, *args, **kw): + tool_name = tool_name.lower() + entries = [e for e in c.project.sitemap() if e.tool_name.lower() == tool_name] + return dict(entries=entries, type=entries[0].tool_name if entries else None) + class ProjectController(object): def __init__(self): @@ -261,6 +268,7 @@ class ProjectController(object): setattr(self, 'feed.atom', self.feed) setattr(self, '_nav.json', self._nav) self.screenshot = ScreenshotsController() + self._list = ToolListController() @expose('json:') def _nav(self): http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7484b98a/Allura/allura/model/project.py ---------------------------------------------------------------------- diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py index c3ac033..58fb20b 100644 --- a/Allura/allura/model/project.py +++ b/Allura/allura/model/project.py @@ -418,7 +418,8 @@ class Project(MappedClass, ActivityNode, ActivityObject): if app.is_visible_to(c.user): for sm in app.main_menu(): entry = sm.bind_app(app) - entry.ui_icon='tool-%s' % ac.tool_name.lower() + entry.tool_name = ac.tool_name + entry.ui_icon = 'tool-%s' % entry.tool_name.lower() ordinal = int(ac.options.get('ordinal', 0)) + delta_ordinal if ordinal > max_ordinal: max_ordinal = ordinal @@ -431,6 +432,23 @@ class Project(MappedClass, ActivityNode, ActivityObject): entries = sorted(entries, key=lambda e: e['ordinal']) return [e['entry'] for e in entries] + def grouped_sitemap(self): + from collections import Counter + sitemap = self.sitemap() + seen_types = dict() + counts = Counter([e.tool_name.lower() for e in sitemap]) + for e in sitemap: + tool_name = e.tool_name.lower() + if tool_name not in seen_types: + if counts.get(tool_name, 1) > 1: + e.label = e.tool_name + e.matching_urls.append(e.url) + e.url = self.url() + '_list/' + tool_name + seen_types[tool_name] = e + else: + seen_types[tool_name].matching_urls.append(e.url) + return seen_types.values() + def parent_iter(self): yield self pp = self.parent_project http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7484b98a/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 c5dec9e..ebe842a 100644 --- a/Allura/allura/nf/allura/css/site_style.css +++ b/Allura/allura/nf/allura/css/site_style.css @@ -370,6 +370,29 @@ td, td img { transform: rotate(45deg); } +.tool-count { + display: block; + position: absolute; + z-index: 2; + height: 13px; + width: 13px; + line-height: 13px; + bottom: 17px; + left: 64%; + font-size: 11px; + font-weight: bold; + color: white; + padding: 1px; + border: 1px solid #9F0000; + background-color: #A70000; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -o-border-radius: 2px; + -ms-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; +} + .nowrap { white-space: nowrap; } http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7484b98a/Allura/allura/templates/jinja_master/top_nav.html ---------------------------------------------------------------------- diff --git a/Allura/allura/templates/jinja_master/top_nav.html b/Allura/allura/templates/jinja_master/top_nav.html index dfa288a..ce836b4 100644 --- a/Allura/allura/templates/jinja_master/top_nav.html +++ b/Allura/allura/templates/jinja_master/top_nav.html @@ -1,5 +1,5 @@ {% if c.project %} - {% for s in c.project.sitemap() %} + {% for s in c.project.grouped_sitemap() %} {{s.label}} {% if s.label == 'Home' %} @@ -8,10 +8,14 @@ {% endif %} {% else %} - {% if s.url in request.upath_info or c.project.neighborhood.url()+'_admin' in request.upath_info %} + {% if s.matches_url(request) or c.project.neighborhood.url()+'_admin' in request.upath_info %} {% endif %} {% endif %} + {% set grouped_tool_count = s.matching_urls|length %} + {% if grouped_tool_count %} + {{grouped_tool_count}} + {% endif %} {% endfor %}
http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/7484b98a/Allura/allura/templates/tool_list.html ---------------------------------------------------------------------- diff --git a/Allura/allura/templates/tool_list.html b/Allura/allura/templates/tool_list.html new file mode 100644 index 0000000..67ab8df --- /dev/null +++ b/Allura/allura/templates/tool_list.html @@ -0,0 +1,21 @@ +{% set hide_left_bar = True %} +{% extends g.theme.master %} + +{% block title %}{{c.project.name}} / {{type}} tools{% endblock %} + +{% block extra_css %} +{% endblock %} + +{% block inner_grid %}{% endblock %} +{% block header_classes %} colored title{% endblock %} +{% block header %}{{type}} tools{% endblock %} + +{% block content %} +
+
    + {% for e in entries %} +
  • {{e.label}}
  • + {% endfor %} +
+
+{% endblock %}