diff options
Diffstat (limited to 'bn_django')
-rw-r--r-- | bn_django/git_browse/models.py | 12 | ||||
-rw-r--r-- | bn_django/git_browse/templates/git_browse/full_log.html | 3 | ||||
-rw-r--r-- | bn_django/git_browse/templates/git_browse/tree.html | 20 | ||||
-rw-r--r-- | bn_django/git_browse/templates/git_browse/tree_table | 52 | ||||
-rw-r--r-- | bn_django/git_browse/views.py | 11 |
5 files changed, 59 insertions, 39 deletions
diff --git a/bn_django/git_browse/models.py b/bn_django/git_browse/models.py index db69bfc..edddf60 100644 --- a/bn_django/git_browse/models.py +++ b/bn_django/git_browse/models.py @@ -119,6 +119,8 @@ class Blob(models.Model): path = models.CharField("relative path from repo base", maxlength=512) id = models.CharField("hash", maxlength=40,blank=False,primary_key=True) name = models.CharField("name of dir", maxlength=128,blank=False) + size = models.IntField("filesize in byte", maxlength=128,blank=False) + contents = models.TextField("ASCII contents of the file") type='blob' class Admin: @@ -130,6 +132,16 @@ class Blob(models.Model): return "/code/%s/%s" % (self.repo.slug, self.hash) def get_admin_url(self): return "%s/code/tree/%s/" % (ADMIN_URL, self.id) + + def update(self): + import commands + + if not self.id: return + self.id = self.id.strip() + self.contents = commands.getoutput(GITPREFIX + ' cat-file -p ' + self.id) + self.size = commands.getoutput(GITPREFIX + ' cat-file -s ' + hash) + + def blob_from_str(s): s = s.split(); diff --git a/bn_django/git_browse/templates/git_browse/full_log.html b/bn_django/git_browse/templates/git_browse/full_log.html index a467ae8..75ea2ab 100644 --- a/bn_django/git_browse/templates/git_browse/full_log.html +++ b/bn_django/git_browse/templates/git_browse/full_log.html @@ -8,7 +8,8 @@ <b>Hash: </b>{{ item.hash }} <br /><b>Author: </b>{{ item.author }} <br /><b>Date: </b>{{ item.date }} - <br /><b>Comment: </b><pre>{{ item.comment }}</pre> + <br /><b>Comment: </b> + <pre class="large">{{ item.comment|wordwrap:80 }}</pre> {% endfor %} {% endif %} {% endblock %} diff --git a/bn_django/git_browse/templates/git_browse/tree.html b/bn_django/git_browse/templates/git_browse/tree.html index 3c8c294..79a8f39 100644 --- a/bn_django/git_browse/templates/git_browse/tree.html +++ b/bn_django/git_browse/templates/git_browse/tree.html @@ -2,22 +2,8 @@ {% block gitbrowse %} - <h3>Tree sha1 hash:</h3><br /> {{ hash }}<br /> + <h3>Tree sha1 hash:</h3> + <span class="hash">{{ hash }}</span> <h3>Directory listing:</h3> - {% include tree_table %} - {% if tree_objs %} - {% for o in tree_objs %} - [{{o.type}}] {{ o.mode }} - {% ifequal o.type 'blob' %} - <a href='/code/{{ object.slug }}/blob/{{ o.id }}/'>{{o.name}}</a> - {% else %} - {% ifequal o.type 'tree' %} - <a href='/code/{{object.slug}}/tree/{{ o.id }}/'>{{o.name}}</a> - {% else %} - <a href='/code/{{object.slug}}/obj/{{ o.id }}/'>{{o.name}}</a> - {% endifequal %}{% endifequal %} - <br /> - {% endfor %} - {% else %}No contents! - {% endif %} + {% include "git_browse/tree_table" %} {% endblock %} diff --git a/bn_django/git_browse/templates/git_browse/tree_table b/bn_django/git_browse/templates/git_browse/tree_table index 7df504a..a472283 100644 --- a/bn_django/git_browse/templates/git_browse/tree_table +++ b/bn_django/git_browse/templates/git_browse/tree_table @@ -1,23 +1,33 @@ -{% if tags %} +{% if tree_objs %} <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="hash"> - {% for h in heads.iteritems %} - {% ifequal h.1 t.1 %} - <a href="/code/{{object.slug}}/head/{{ h.1 }}/" class="head"> - [{{ h.0 }}]</a> - {% endifequal %} - {% endfor %} - <a href="/code/{{object.slug}}/obj/{{ t.1 }}" class="subtle"> - <span class="hash">{{ t.1 }}</span></a></td></tr> -{% endfor %} + {% for o in tree_objs %} + <tr> <td class="objtype"> + {{o.type}}</td> + <td class="filemode"> + {{ o.mode }} </td> + <td class="filename"> + {% ifequal o.type 'blob' %} + <a href='/code/{{ object.slug }}/blob/{{ o.id }}/' class="blob"> + {{o.name}}</a> + </td><td type="links"> + <a href='/code/{{object.slug}}/tree/{{ o.id }}/'>log</a> | + <a href='/code/{{object.slug}}/tree/{{ o.id }}/zip/'>zip</a> + </td> + {% else %} {% ifequal o.type 'tree' %} + <a href='/code/{{object.slug}}/tree/{{ o.id }}/' class="tree"> + {{o.name}}/</a> + </td><td type="links"> + <a href='/code/{{object.slug}}/tree/{{ o.id }}/'>browse</a> | + <a href='/code/{{object.slug}}/tree/{{ o.id }}/zip/'>zip</a> + </td> + {% else %} + <a href='/code/{{object.slug}}/obj/{{ o.id }}/' class="blob"> + {{o.name}}</a> + </td><td type="links"> + </td> + {% endifequal %}{% endifequal %} + </tr> + {% endfor %} </table> -{% else %}No tags!{% endif %} +{% else %}No contents! +{% endif %} diff --git a/bn_django/git_browse/views.py b/bn_django/git_browse/views.py index 8a84241..e27d949 100644 --- a/bn_django/git_browse/views.py +++ b/bn_django/git_browse/views.py @@ -96,6 +96,17 @@ def view_log(request, repo, tree_hash=None, branch=None): return render_to_response('git_browse/full_log.html', dict(object=therepo, log_objs=log_objs,)) +def view_blob(request, repo, hash, branch=None): + therepo = get_object_or_404(Repository, slug=repo) + (GITPREFIX, heads, tags) = therepo.scan() + blob = Blob(hash=hash,repo=therepo) + blob.update() + + return render_to_response('git_browse/obj.html', + dict(object=therepo, + hash=blob.id, + size=blob.size, + contents=blob.contents)) def view_obj(request, repo, hash, branch=None): therepo = get_object_or_404(Repository, slug=repo) |