You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by jo...@apache.org on 2013/04/10 18:15:01 UTC
[2/2] git commit: [#5120] Only show first 10 branches, like with tags
[#5120] Only show first 10 branches, like with tags
Signed-off-by: Cory Johns <cj...@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/5a72eb23
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/5a72eb23
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/5a72eb23
Branch: refs/heads/cj/5120
Commit: 5a72eb233a314cf462e3cce380070acbbf616d55
Parents: 3fe91a2
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Apr 10 16:14:45 2013 +0000
Committer: Cory Johns <cj...@slashdotmedia.com>
Committed: Wed Apr 10 16:14:45 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/5a72eb23/Allura/allura/controllers/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index dca0ceb..f2935a9 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -392,6 +392,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/5a72eb23/Allura/allura/lib/repository.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 79a6b33..dfcaf4f 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -80,13 +80,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']))
@@ -118,27 +111,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/5a72eb23/Allura/allura/templates/repo/tags.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/repo/tags.html b/Allura/allura/templates/repo/tags.html
index 148c28f..8252733 100644
--- a/Allura/allura/templates/repo/tags.html
+++ b/Allura/allura/templates/repo/tags.html
@@ -2,18 +2,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 %}