From 8edff291f17ce3e0899f9d5993443e4886e2bda1 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Mon, 22 Nov 2010 00:15:20 -0500 Subject: [PATCH 1/9] Added a browse function --- browser/vcs.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/browser/vcs.py b/browser/vcs.py index 84ca734..cc06e67 100644 --- a/browser/vcs.py +++ b/browser/vcs.py @@ -176,6 +176,26 @@ class Git(VCS): diff.b_blob.data_stream.read()) result.append(d) return result + def browse(self, commit=None, path=''): + if not commit: + commit = self.ref() + files = [] + dirs = [] + # Locate the tree matching the requested path + tree = self._repo.commit(commit).tree + if path: + for i in tree.traverse(): + if type(i) == git.objects.Tree and i.path == path: + tree = i + if path != tree.path: + raise Exception('Path not found') + + for node in tree: + if type(node) == git.objects.Blob: + files.append(node.path) + elif type(node) == git.objects.Tree: + dirs.append(node.path) + return dirs, files if __name__ == '__main__': g = Git('/home/correlr/code/voiceaxis') From e7285b23249f7b03ee1a35224fde21a4cb44ba18 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Mon, 22 Nov 2010 00:48:29 -0500 Subject: [PATCH 2/9] Added a navigation sidebar --- media/default.css | 9 +++++++++ templates/browser/log.html | 6 +++++- templates/dashboard/index.html | 2 +- templates/layouts/default.html | 2 ++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/media/default.css b/media/default.css index 87c38e4..c5ed04d 100644 --- a/media/default.css +++ b/media/default.css @@ -5,6 +5,15 @@ body, th, td { a { color: black; } +div.navigation { + width: 200px; + float: left; + background-color: #ddd; +} +div.content { + margin-left: 200px; + background-color: #eee; +} span.marker { display: block; float: left; diff --git a/templates/browser/log.html b/templates/browser/log.html index 76d5908..441fbd3 100644 --- a/templates/browser/log.html +++ b/templates/browser/log.html @@ -1,7 +1,11 @@ {% extends "layouts/default.html" %} {% load gravatar %} - {% load vcs %} + +{% block navigation %} +{% include "browser/navigation.html" %} +{% endblock %} + {% block content %}

Commit Log

Branches: diff --git a/templates/dashboard/index.html b/templates/dashboard/index.html index 9076031..055dee2 100644 --- a/templates/dashboard/index.html +++ b/templates/dashboard/index.html @@ -1,6 +1,6 @@ {% extends "layouts/default.html" %} -{% block content %} +{% block navigation %}

Repositories