From 7adab6520975d9a8650a214ca519f2357707bd65 Mon Sep 17 00:00:00 2001 From: bnewbold Date: Tue, 20 Feb 2007 19:22:14 -0800 Subject: git_browse: actually moved heads_table and tags_table to seperate files created shortlog_table --- bn_django/git_browse/models.py | 41 +++++++++++++++++++--- .../git_browse/templates/git_browse/base.html | 9 +++-- .../templates/git_browse/repository_info.html | 4 +-- bn_django/git_browse/views.py | 4 +-- static/style/default.css | 2 ++ static/style/git_browse.css | 39 ++++++++++++++++---- 6 files changed, 78 insertions(+), 21 deletions(-) diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py index be097f8..db69bfc 100644 --- a/bn_django/git_browse/models.py +++ b/bn_django/git_browse/models.py @@ -49,16 +49,47 @@ class Repository(models.Model): heads = dict() for h in os.listdir(GITBROWSE_BASE + self.slug + '/.git/refs/heads/'): f = open(GITBROWSE_BASE + self.slug + '/.git/refs/heads/' + h,'r') - heads[h] = f.readline() - f.close + heads[h.strip()] = f.readline().strip() + f.close() tags = dict() for t in os.listdir(GITBROWSE_BASE + self.slug + '/.git/refs/tags/'): f = open(GITBROWSE_BASE + self.slug + '/.git/refs/tags/' + t,'r') - tags[t] = f.readline() - f.close - + tags[t.strip()] = f.readline().strip() + f.close() return (GITPREFIX, heads, tags) + + def shortlog(self): + import commands + + GITPREFIX = 'cd ' + GITBROWSE_BASE + self.slug + '; ' + GITCOMMAND \ + + ' --git-dir=' + GITBROWSE_BASE + self.slug + '/.git ' + logtxt = commands.getoutput(GITPREFIX + ' log --relative-date --max-count=6 | cat') + log_items = logtxt.split('\ncommit ') + if (log_items[0] == ''): + log_items.pop(0) + if (log_items[0].startswith('commit ')): + log_items[0] = log_items[0][7:] + shortlog = list() + for li in log_items: + logobj = dict() + lines = li.splitlines() + if len(lines) < 3: continue + logobj['hash'] = lines[0].strip() + logobj['shorthash'] = lines[0].strip()[:5] + logobj['author'] = lines[1][8:] + logobj['date'] = lines[2][8:] + if len(lines) > 4: + logobj['description'] = lines[4][4:] + else: + logobj['description'] = '(none)' + # here we truncate commit comments for shortlogs + logobj['shortdescription'] = logobj['description'][:128] + shortlog.append(logobj) + return shortlog + + + class Tree(models.Model): repo = models.ForeignKey(Repository) mode = models.CharField("file mode/permissions", blank=False,maxlength=4) diff --git a/bn_django/git_browse/templates/git_browse/base.html b/bn_django/git_browse/templates/git_browse/base.html index 93814c1..d23ab55 100644 --- a/bn_django/git_browse/templates/git_browse/base.html +++ b/bn_django/git_browse/templates/git_browse/base.html @@ -9,9 +9,11 @@ {% endblock %} {% block path %} - code » +{{ block.super }} {% if object %} - {{ object.name }} + {{ object.name }} + [browse, + log] {% endif %} {% endblock %} @@ -30,9 +32,6 @@ browse tree - full log
- {% if raw %} -
{{raw}}
- {% endif %} {% else %}

No such repository!

{% endif %} diff --git a/bn_django/git_browse/templates/git_browse/repository_info.html b/bn_django/git_browse/templates/git_browse/repository_info.html index 51794d3..f45eeb8 100644 --- a/bn_django/git_browse/templates/git_browse/repository_info.html +++ b/bn_django/git_browse/templates/git_browse/repository_info.html @@ -2,9 +2,8 @@ {% block gitbrowse %} {{ object.description }} -{% if shortlog %}

Shortlog (full log)

-
{{ shortlog }}
+{% include "git_browse/shortlog_table" %}

Heads (browse)

{% include "git_browse/heads_table" %}

Tags (browse)

@@ -12,5 +11,4 @@

Filelist (browse tree)

{% if filelist %}
{{ filelist }}
{% else %}No files!{% endif %} -{% endif %} {% endblock %} diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py index d8e01d7..3439c35 100644 --- a/bn_django/git_browse/views.py +++ b/bn_django/git_browse/views.py @@ -25,10 +25,10 @@ def repo_info(request, repo,branch=None): therepo = get_object_or_404(Repository, slug=repo) (GITPREFIX, heads, tags) = therepo.scan() - shortlog = commands.getoutput(GITPREFIX + ' log | ' + GITCOMMAND \ - + '-shortlog') branches = commands.getoutput(GITPREFIX + ' branch') filelist = commands.getoutput(GITPREFIX + ' ls-files') + shortlog = therepo.shortlog() + return render_to_response('git_browse/repository_info.html', \ dict(object=therepo, \ filelist=filelist, \ diff --git a/static/style/default.css b/static/style/default.css index 8c0cd7e..58c3011 100644 --- a/static/style/default.css +++ b/static/style/default.css @@ -8,6 +8,8 @@ body { background-color: #E3E3E3; } a { text-decoration: none; } +a:hover { + border-bottom: 1px solid blue; } a.subtle { color: black; text-decoration: none; } diff --git a/static/style/git_browse.css b/static/style/git_browse.css index 44b884b..bf9974d 100644 --- a/static/style/git_browse.css +++ b/static/style/git_browse.css @@ -8,25 +8,52 @@ pre.large { table.gitbrowser { width: 100%; - border-spacing: 4px; + border-spacing: 0px; + font-size: 11px; } table.gitbrowser tr { width: 100%; background-color: #EEEEEE; } -table.gitbrowser td { - margin: 0px; - margin-bottom: 2px; -} td.head { font-weight: bold; + padding-left: 13px; width: 130px; overflow: hidden; } - +td.tag { + font-weight: bold; + padding-left: 13px; + width: 130px; + overflow: hidden; +} +td.date { + font-style: italic; + width: 90px; + overflow: hidden; +} +td.author { + font-style: italic; + width: 100px; + overflow: hidden; +} +td.description { + overflow: hidden; +} +td.shorthash { + width: 60px; + overflow: hidden; + text-align: right; + font-family: courier; +} td.hash { width: 100px; overflow: hidden; text-align: right; font-family: courier; } + +a.head { + color: green; } +a.tag { + color: yellow; } -- cgit v1.2.3