aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbnewbold <bnewbold@manus.(none)>2007-02-20 02:21:25 -0800
committerbnewbold <bnewbold@manus.(none)>2007-02-20 02:21:25 -0800
commit3d203c153301d4dd9c3285e7dea86ee09eb3b0c5 (patch)
tree47bf5bb676c5f25def0a4a37852c1783961a03e6
parent566473abe7aac915429a633e996bdb719f1a308b (diff)
downloadbnewnet-3d203c153301d4dd9c3285e7dea86ee09eb3b0c5.tar.gz
bnewnet-3d203c153301d4dd9c3285e7dea86ee09eb3b0c5.zip
mid-progress, work on git-browser
fan is dying, more work to do though! TODO: seperate style for git_browser, use "block.super"
-rw-r--r--bn_django/git_browse/models.py25
-rw-r--r--bn_django/git_browse/templates/git_browse/obj.html2
-rw-r--r--bn_django/git_browse/templates/git_browse/repository_info.html52
-rw-r--r--bn_django/git_browse/urls.py11
-rw-r--r--bn_django/git_browse/views.py33
-rw-r--r--bn_django/settings.py1
-rw-r--r--bn_django/templates/base.html2
-rw-r--r--bn_django/templates/frontpage.html3
-rw-r--r--static/style/default.css33
9 files changed, 140 insertions, 22 deletions
diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py
index 765fe02..be097f8 100644
--- a/bn_django/git_browse/models.py
+++ b/bn_django/git_browse/models.py
@@ -5,6 +5,13 @@ try:
GITBROWSE_BASE = settings.GITBROWSE_BASE
except AttributeError:
GITBROWSE_BASE='/home'
+if GITBROWSE_BASE[-1] != '/':
+ GITBROWSE_BASE += '/'
+
+try:
+ GITCOMMAND = settings.GITCOMMAND
+except AttributeError:
+ GITCOMMAND='git'
try:
ADMIN_URL = settings.ADMIN_URL
@@ -34,6 +41,24 @@ class Repository(models.Model):
def get_admin_url(self):
return "%s/code/repository/%s/" % (ADMIN_URL, self.slug)
+ def scan(self):
+ import os
+
+ GITPREFIX = 'cd ' + GITBROWSE_BASE + self.slug + '; ' + GITCOMMAND \
+ + ' --git-dir=' + GITBROWSE_BASE + self.slug + '/.git '
+ 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
+ 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
+
+ return (GITPREFIX, heads, tags)
+
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/obj.html b/bn_django/git_browse/templates/git_browse/obj.html
index be0b556..0170eab 100644
--- a/bn_django/git_browse/templates/git_browse/obj.html
+++ b/bn_django/git_browse/templates/git_browse/obj.html
@@ -3,7 +3,7 @@
{% block gitbrowse %}
{% if contents %}
<h3>Object sha1 hash: {{ hash }}<br />
- Size: {{ size }} kB<br />
+ Size: {{ size|filesizeformat }}<br />
Type: "{{ type }}"</h3>
<pre>{{ contents }}</pre>
{% else %}
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 72f30b1..b3028a2 100644
--- a/bn_django/git_browse/templates/git_browse/repository_info.html
+++ b/bn_django/git_browse/templates/git_browse/repository_info.html
@@ -5,7 +5,55 @@
{% if shortlog %}
<h3>Shortlog (<a href="/code/{{object.slug}}/log/">full log</a>)</h3>
<pre>{{ shortlog }}</pre>
-<h3>Filelist (<a href="/code/{{object.slug}}/tree/">browse</a>)</h3>
-<pre>{{ filelist }}</pre>
+<h3>Heads (<a href="/code/{{object.slug}}/tree/">browse</a>)</h3>
+{% if heads %}
+<table class="gitbrowser">
+{% for h in heads.iteritems %}
+<tr>
+ <td class="head">
+ <a href="/code/{{object.slug}}/commit/{{ h.1 }}" class="subtle">
+ {{ h.0 }}</a></td>
+ <td class="links">
+ <a href="/code/{{object.slug}}/commit/{{ h.1 }}">commit</a> |
+ <a href="/code/{{object.slug}}/commit/{{ h.1 }}/zip"> zip </a></td>
+ <td class="commit_hash">
+ <a href="/code/{{object.slug}}/obj/{{ h.1 }}" class="subtle">
+ {{ h.1 }}</a>
+ {% for t in tags.iteritems %}
+ {% ifequal h.1 t.1 %}
+ <a href="/code/{{object.slug}}/tag/{{ h.1 }}/" class="tag">
+ [{{ t.0 }}]</a>
+ {% endifequal %}{% endfor %}
+ </td></tr>
+{% endfor %}
+</table>
+{% else %}No heads!{% endif %}
+<h3>Tags (<a href="/code/{{object.slug}}/tree/">browse</a>)</h3>
+{% if tags %}
+<table class="gitbrowser">
+{% for t in tags.iteritems %}
+<tr>
+ <td class="tag">
+ <a href="/code/{{object.slug}}/tag/{{ h.1 }}" class="subtle">
+ {{ t.0 }}</a></td>
+ <td class="links">
+ <a href="/code/{{object.slug}}/tag/{{ t.1 }}">tag</a> |
+ <a href="/code/{{object.slug}}/commit/{{ t.1 }}">commit</a> |
+ <a href="/code/{{object.slug}}/commit/{{ t.1 }}/zip"> zip </a></td>
+ <td class="commit_hash">
+ <a href="/code/{{object.slug}}/obj/{{ t.1 }}" class="subtle">
+ <span class="hash">{{ t.1 }}</span></a>
+ {% for t in tags.iteritems %}
+ {% ifequal h.1 t.1 %}
+ <a href="/code/{{object.slug}}/tag/{{ h.1 }}/" class="tag">
+ [{{ t.0 }}]</a>
+ {% endifequal %}</td></tr>
+ {% endfor %}
+{% endfor %}
+</table>
+{% else %}No tags!{% endif %}
+<h3>Filelist (<a href="/code/{{object.slug}}/tree/">browse tree</a>)</h3>
+{% if filelist %} <pre class="large">{{ filelist }}</pre>
+{% else %}No files!{% endif %}
{% endif %}
{% endblock %}
diff --git a/bn_django/git_browse/urls.py b/bn_django/git_browse/urls.py
index 909bfcd..77fabd3 100644
--- a/bn_django/git_browse/urls.py
+++ b/bn_django/git_browse/urls.py
@@ -32,10 +32,17 @@ urlpatterns = patterns('django.views.generic.list_detail',
urlpatterns += patterns('bn_django.git_browse.views',
(r'^(?P<repo>[\w\-\_]*)/$', 'repo_info',),
- (r'^(?P<repo>[\w\-\_]*)/tree/$', 'view_tree',),
(r'^(?P<repo>[\w\-\_]*)/branches/$', 'view_branches',),
- (r'^(?P<repo>[\w\-\_]*)/history/$', 'view_history',),
(r'^(?P<repo>[\w\-\_]*)/log/$', 'view_log',),
(r'^(?P<repo>[\w\-\_]*)/obj/(?P<hash>[0-9a-z]{40})/$', 'view_obj',),
+ (r'^(?P<repo>[\w\-\_]*)/obj/(?P<hash>[0-9a-z]{40})/log/$', 'view_log',),
+ (r'^(?P<repo>[\w\-\_]*)/commit/(?P<hash>[0-9a-z]{40})/$', 'view_commit',),
+ (r'^(?P<repo>[\w\-\_]*)/commit/$', 'view_commit',),
+ (r'^(?P<repo>[\w\-\_]*)/tag/(?P<hash>[0-9a-z]{40})/$', 'view_tag',),
+ (r'^(?P<repo>[\w\-\_]*)/blob/(?P<hash>[0-9a-z]{40})/$', 'view_blob',),
+ (r'^(?P<repo>[\w\-\_]*)/blob/(?P<hash>[0-9a-z]{40})/raw/$', 'view_blob',),
+ (r'^(?P<repo>[\w\-\_]*)/tree/$', 'view_tree',),
(r'^(?P<repo>[\w\-\_]*)/tree/(?P<hash>[0-9a-z]{40})/$', 'view_tree',),
+ (r'^(?P<repo>[\w\-\_]*)/tree/(?P<hash>[0-9a-z]{40})/gz/$', 'view_tree',),
+ (r'^(?P<repo>[\w\-\_]*)/tree/(?P<hash>[0-9a-z]{40})/tar/$', 'view_tree',),
)
diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py
index c8a7a40..d8e01d7 100644
--- a/bn_django/git_browse/views.py
+++ b/bn_django/git_browse/views.py
@@ -23,26 +23,29 @@ except AttributeError:
def repo_info(request, repo,branch=None):
therepo = get_object_or_404(Repository, slug=repo)
+ (GITPREFIX, heads, tags) = therepo.scan()
- GITPREFIX = 'cd ' + GITBROWSE_BASE + therepo.slug + '; ' + GITCOMMAND + ' --git-dir=' + GITBROWSE_BASE + therepo.slug + '/.git '
-
- shortlog = commands.getoutput(GITPREFIX + ' log | ' + GITCOMMAND + '-shortlog')
+ shortlog = commands.getoutput(GITPREFIX + ' log | ' + GITCOMMAND \
+ + '-shortlog')
+ branches = commands.getoutput(GITPREFIX + ' branch')
filelist = commands.getoutput(GITPREFIX + ' ls-files')
-
- return render_to_response('git_browse/repository_info.html',
- dict(object=therepo,
- filelist=filelist,
+ return render_to_response('git_browse/repository_info.html', \
+ dict(object=therepo, \
+ filelist=filelist, \
+ tags=tags, \
+ heads=heads, \
shortlog=shortlog,))
def view_tree(request, repo, hash=None,branch=None):
therepo = get_object_or_404(Repository, slug=repo)
+ (GITPREFIX, heads, tags) = therepo.scan()
- GITPREFIX = 'cd ' + GITBROWSE_BASE + therepo.slug + '; ' + GITCOMMAND + ' --git-dir=' + GITBROWSE_BASE + therepo.slug + '/.git '
-
if(hash == None):
- head_ref = commands.getoutput('cd ' + GITBROWSE_BASE + therepo.slug +'/.git; cat HEAD')
+ head_ref = commands.getoutput('cd ' + GITBROWSE_BASE \
+ + therepo.slug +'/.git; cat HEAD')
head_ref = head_ref.split()[1]
- hash = commands.getoutput('cd ' + GITBROWSE_BASE + therepo.slug +'/.git; cat ' + head_ref)
+ hash = commands.getoutput('cd ' + GITBROWSE_BASE + therepo.slug \
+ +'/.git; cat ' + head_ref)
tree_ls = commands.getoutput(GITPREFIX + ' ls-tree ' + hash)
tree_objs = list()
@@ -65,8 +68,10 @@ def view_tree(request, repo, hash=None,branch=None):
def view_log(request, repo, tree_hash=None, branch=None):
therepo = get_object_or_404(Repository, slug=repo)
+ (GITPREFIX, heads, tags) = therepo.scan()
- GITPREFIX = 'cd ' + GITBROWSE_BASE + therepo.slug + '; ' + GITCOMMAND + ' --git-dir=' + GITBROWSE_BASE + therepo.slug + '/.git '
+ GITPREFIX = 'cd ' + GITBROWSE_BASE + therepo.slug + '; ' + GITCOMMAND \
+ + ' --git-dir=' + GITBROWSE_BASE + therepo.slug + '/.git '
logtxt = commands.getoutput(GITPREFIX + ' log | cat')
log_items = logtxt.split('\ncommit ')
@@ -94,8 +99,8 @@ def view_log(request, repo, tree_hash=None, branch=None):
def view_obj(request, repo, hash, branch=None):
therepo = get_object_or_404(Repository, slug=repo)
+ (GITPREFIX, heads, tags) = therepo.scan()
- GITPREFIX = 'cd ' + GITBROWSE_BASE + therepo.slug + '; ' + GITCOMMAND + ' --git-dir=' + GITBROWSE_BASE + therepo.slug + '/.git '
obj_type = commands.getoutput(GITPREFIX + ' cat-file -t ' + hash)
#if(obj_type == 'tree'):
# redirect_to('../tree/' + hash);
@@ -109,5 +114,5 @@ def view_obj(request, repo, hash, branch=None):
dict(object=therepo,
hash=hash,
type=obj_type,
- size=float(obj_size)/1024.0,
+ size=float(obj_size),
contents=obj_contents))
diff --git a/bn_django/settings.py b/bn_django/settings.py
index 9c26c1a..4e6c1b0 100644
--- a/bn_django/settings.py
+++ b/bn_django/settings.py
@@ -60,6 +60,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
+ 'django.contrib.csrf.middleware.CsrfMiddleware',
'django.middleware.doc.XViewMiddleware',
)
diff --git a/bn_django/templates/base.html b/bn_django/templates/base.html
index 9416150..9375027 100644
--- a/bn_django/templates/base.html
+++ b/bn_django/templates/base.html
@@ -4,7 +4,7 @@
<head>
<link rel="STYLESHEET" type="text/css" href="style/default.css">
<link rel="STYLESHEET" type="text/css" href="/style/default.css">
-<link rel="STYLESHEET" type="text/css" href="http://static.bryannewbold.com/style/default.css">
+<!--<link rel="STYLESHEET" type="text/css" href="http://static.bryannewbold.com/style/default.css">-->
<title>bryannewbold.com</title>
</head>
<body>
diff --git a/bn_django/templates/frontpage.html b/bn_django/templates/frontpage.html
index 9dacccd..057d0c8 100644
--- a/bn_django/templates/frontpage.html
+++ b/bn_django/templates/frontpage.html
@@ -27,7 +27,8 @@ For 2007 i'm taking a year break from <a href="http://web.mit.edu">MIT</a>...
-->
as of February i'm living in Seattle working at <a href="http://azalea.com/AboutUs">Azalea Software</a> doing tech work. Starting in mid-May i'll be working at the Moss Landing Marine Labs in California, followed in October by field work in Antartica. I will be back at MIT for the spring 2008 semester.
-<hr />
+<br />
+<br />
<div class="right_stuff">
diff --git a/static/style/default.css b/static/style/default.css
index 585b54d..27915a9 100644
--- a/static/style/default.css
+++ b/static/style/default.css
@@ -8,6 +8,9 @@ body {
background-color: #E3E3E3; }
a {
text-decoration: none; }
+a.subtle {
+ color: black;
+ text-decoration: none; }
h1 {
font-size: 16pt;
font-weight: bold;
@@ -34,7 +37,7 @@ hr {
border-right: 55px solid #FFFFFF; }
dt {
font-weight: bold; }
-pre {
+pre.large {
font-family: courier;
margin: 10px;
padding: 6px;
@@ -182,6 +185,34 @@ pre {
width: 160px;
height: 180px; }
+table.gitbrowser {
+ width: 100%;
+ border-spacing: 0px;
+}
+table.gitbrowser tr {
+ width: 100%;
+ margin-bottom: 2px;
+}
+table.gitbrowser td {
+ margin: 0px;
+ border: 1px solid black;
+ margin: 0px;
+}
+td.head {
+ font-weight: bold;
+ width: 130px;
+ overflow: hidden;
+}
+
+td.hash {
+ width: 100px;
+ overflow: hidden;
+ text-align: right;
+}
+span.hash {
+ font-family: courier;
+}
+
#top_bar {
height: 22px;
background-color: #993333;