Permalink
Browse files

Shorten SHA1 sums in breadcrumbs and branch selector.

  • Loading branch information...
1 parent 4992391 commit 1e5f497d4e4c7f9338006aa3f6cd0b20f312c252 @jonashaag committed Oct 14, 2011
Showing with 10 additions and 5 deletions.
  1. +6 −1 klaus.py
  2. +2 −2 templates/base.html
  3. +1 −1 templates/tree.inc.html
  4. +1 −1 templates/view_blob.html
View
@@ -176,9 +176,14 @@ def extract_author_name(email):
return match.group(1).strip()
return email
+def shorten_sha1(sha1):
+ if re.match('[a-z\d]{20,40}', sha1):
+ sha1 = sha1[:10]
+ return sha1
+
app.jinja_env.filters['u'] = force_unicode
app.jinja_env.filters['timesince'] = timesince
-app.jinja_env.filters['shorten_id'] = lambda id: id[:7] if len(id) in {20, 40} else id
+app.jinja_env.filters['shorten_sha1'] = shorten_sha1
app.jinja_env.filters['shorten_message'] = lambda msg: msg.split('\n')[0]
app.jinja_env.filters['pygmentize'] = pygmentize
app.jinja_env.filters['is_binary'] = guess_is_binary
View
@@ -4,7 +4,7 @@
<span>
<a href="{{ build_url('history', commit_id='master') }}">{{ repo.name }}</a>
<span class=slash>/</span>
- <a href="{{ build_url('history') }}">{{ commit_id }}</a>
+ <a href="{{ build_url('history') }}">{{ commit_id|shorten_sha1 }}</a>
</span>
{% if subpaths %}
@@ -23,7 +23,7 @@
{% block extra_header %}
<div class=branch-selector>
- <span>{{ commit_id }}</span>
+ <span>{{ commit_id|shorten_sha1 }}</span>
<ul>
{% for branch in branches %}
<li><a href="{{ build_url(commit_id=branch, path=path) }}">{{ branch }}</a></li>
View
@@ -1,5 +1,5 @@
<div class=tree>
- <h2>Tree @<a href="{{ build_url('view_commit') }}">{{ commit_id|shorten_id }}</a></h2>
+ <h2>Tree @<a href="{{ build_url('view_commit') }}">{{ commit_id|shorten_sha1 }}</a></h2>
<ul>
{% for _, name, fullpath in tree.dirs %}
<li><a href="{{ build_url('history', path=fullpath) }}" class=dir>{{ name|u }}</a></li>
View
@@ -7,7 +7,7 @@
<h2>
{{ filename|u }}
<span>
- @<a href="{{ build_url('view_commit') }}">{{ commit_id|shorten_id }}</a>
+ @<a href="{{ build_url('view_commit') }}">{{ commit_id|shorten_sha1 }}</a>
(<a href="{{ raw_url }}">raw</a>
&middot; <a href="{{ build_url('history', path=path) }}">history</a>)
</span>

0 comments on commit 1e5f497

Please sign in to comment.