You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by tv...@apache.org on 2013/04/23 18:42:50 UTC
[46/50] [abbrv] 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/fff1980f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/fff1980f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/fff1980f
Branch: refs/heads/cj/5120
Commit: fff1980fe3d7e00633ab5d5f0a305440c94a71c8
Parents: 28b8a14
Author: Cory Johns <cj...@slashdotmedia.com>
Authored: Wed Apr 10 16:14:45 2013 +0000
Committer: Tim Van Steenburgh <tv...@gmail.com>
Committed: Tue Apr 23 13:35:53 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/fff1980f/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/fff1980f/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/fff1980f/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 %}