incubator-allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tvansteenbu...@apache.org
Subject [5/5] git commit: [#5120] Only show first 10 branches, like with tags
Date Tue, 23 Apr 2013 21:11:06 GMT
[#5120] Only show first 10 branches, like with tags

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/0dcf37f4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/0dcf37f4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/0dcf37f4

Branch: refs/heads/master
Commit: 0dcf37f4215d876deb60b350bebd3eb1d962c8dc
Parents: 2eefae8
Author: Cory Johns <cjohns@slashdotmedia.com>
Authored: Wed Apr 10 16:14:45 2013 +0000
Committer: Tim Van Steenburgh <tvansteenburgh@gmail.com>
Committed: Tue Apr 23 17:03:34 2013 +0000

----------------------------------------------------------------------
 Allura/allura/controllers/repository.py |    5 +++
 Allura/allura/lib/repository.py         |   41 ++++++++++++-------------
 Allura/allura/templates/repo/tags.html  |   10 +++---
 3 files changed, 30 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0dcf37f4/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 80605be..ef678f5 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -409,6 +409,11 @@ class BranchBrowser(BaseController):
     def tags(self, **kw):
         return dict(tags=c.app.repo.repo_tags)
 
+    @expose('jinja:allura:templates/repo/tags.html')
+    @with_trailing_slash
+    def branches(self, **kw):
+        return dict(title='Branches', tags=c.app.repo.branches)
+
     @expose()
     @with_trailing_slash
     def log(self, **kw):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0dcf37f4/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index b16392d..f59ec04 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -97,13 +97,6 @@ class RepositoryApp(Application):
     def sidebar_menu(self):
         if not self.repo or self.repo.status != 'ready':
             return []
-        if self.default_branch_name:
-            default_branch_url = (
-                c.app.url
-                + url(quote(self.default_branch_name + self.END_OF_REF_ESCAPE))
-                + '/')
-        else:
-            default_branch_url = c.app.url
         links = [SitemapEntry('Browse Commits', c.app.url + 'commit_browser', ui_icon=g.icons['folder'])]
         if self.forkable and self.repo.status == 'ready':
             links.append(SitemapEntry('Fork', c.app.url + 'fork', ui_icon=g.icons['fork']))
@@ -135,27 +128,33 @@ class RepositoryApp(Application):
                         'Pending Merges',
                         self.repo.upstream_repo.name + 'merge-requests/',
                         small=pending_upstream_merges))
+        ref_url = self.repo.url_for_commit(self.default_branch_name, url_type='ref')
         if self.repo.branches:
             links.append(SitemapEntry('Branches'))
-            for b in self.repo.branches:
+            max_branches = 10
+            for b in self.repo.branches[:max_branches]:
                 links.append(SitemapEntry(
-                        b.name, url('%sci/%s/tree/' % (c.app.url, quote(b.name, safe=''))),
+                        b.name, self.repo.url_for_commit(b.name)+'tree/',
                         small=b.count))
+            if len(self.repo.branches) > max_branches:
+                links.append(
+                    SitemapEntry(
+                        'More Branches',
+                        ref_url + 'branches/',
+                        ))
         if self.repo.repo_tags:
             links.append(SitemapEntry('Tags'))
             max_tags = 10
-            for i, b in enumerate(self.repo.repo_tags):
-                if i < max_tags:
-                    links.append(SitemapEntry(
-                            b.name, url('%sci/%s/tree/' % (c.app.url, quote(b.name, safe=''))),
-                            small=b.count))
-                elif i == max_tags:
-                    links.append(
-                        SitemapEntry(
-                            'More Tags',
-                            default_branch_url+'tags/',
-                            ))
-                    break
+            for b in self.repo.repo_tags[:max_tags]:
+                links.append(SitemapEntry(
+                        b.name, self.repo.url_for_commit(b.name)+'tree/',
+                        small=b.count))
+            if len(self.repo.repo_tags) > max_tags:
+                links.append(
+                    SitemapEntry(
+                        'More Tags',
+                        ref_url + 'tags/',
+                        ))
         return links
 
     def install(self, project):

http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/0dcf37f4/Allura/allura/templates/repo/tags.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tags.html b/Allura/allura/templates/repo/tags.html
index ef4640e..579b294 100644
--- a/Allura/allura/templates/repo/tags.html
+++ b/Allura/allura/templates/repo/tags.html
@@ -20,18 +20,18 @@
 
 {% block title %}
   {% if c.app.repo %}
-    Tags: {{c.app.repo.name}}
+    {{title or 'Tags'}}: {{c.app.repo.name}}
   {% else %}
-    Tags
+    {{title or 'Tags'}}
   {% endif %}
 {% endblock %}
 
-{% block header %}{{c.app.config.options.mount_label}} Tags{% endblock %}
+{% block header %}{{c.app.config.options.mount_label}} {{title or 'Tags'}}{% endblock %}
 
 {% block content %}
   <div class="grid-19">
-  {% for b in c.app.repo.repo_tags %}
-    <a href="{{c.app.url}}?branch=ref/{{b.name}}">{{b.name}}</a><br>
+  {% for b in tags %}
+    <a href="{{c.app.repo.url_for_commit(b.name)}}tree/">{{b.name}}</a><br>
   {% endfor %}
   </div>
 {% endblock %}


Mime
View raw message