X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=web%2Fbzrbrowse%2Fbzrbrowse.cgi;h=2e3bf3c8471c703e360a8c714dd5b3c0da4ad53a;hb=dbf1ac48c3a1f5147dfcd457a7847a03de26a6c7;hp=334ce50c3635b34dd40cfc0b5d6181f7fc0f6ab3;hpb=f849631ebbff9f495d5ea51dfa201faa13ecf625;p=ccan diff --git a/web/bzrbrowse/bzrbrowse.cgi b/web/bzrbrowse/bzrbrowse.cgi index 334ce50c..2e3bf3c8 100755 --- a/web/bzrbrowse/bzrbrowse.cgi +++ b/web/bzrbrowse/bzrbrowse.cgi @@ -19,18 +19,18 @@ # CHANGE THIS: config = { - 'root': '/home/lukas/projects', - 'base_url': '/~lukas/bzrbrowse.cgi', - 'images_url': '/~lukas/bzrbrowse', - 'branch_url': 'http://bzr.oxygene.sk', + 'root': '/home/ccan/ccan', + 'base_url': '/browse', + 'images_url': '', + 'branch_url': 'http://ccan.ozlabs.org/repo', } -import os, sys +import os, sys, string from bzrlib.branch import Branch from bzrlib.errors import NotBranchError from bzrlib import urlutils, osutils -__version__ = '0.0.1' +__version__ = '0.0.1-rusty' class HTTPError(Exception): @@ -55,6 +55,7 @@ class BzrBrowse(object): icons = { 'file': 'file.png', 'directory': 'folder.png', + 'symlink': 'symlink.png', } page_tmpl = ''' @@ -147,12 +148,24 @@ code { background-color: #000; color: #FFF; font-size: 90%%;} linenumbers + '
' + escape_html(text) +
                 '
') + # Symlinks in ccan contain .., and bzr refuses to serve that. Simplify. + def squish(self, linkname): + result = [] + for elem in string.split(linkname, os.sep): + if elem == '..': + result = result[:-1] + else: + result.append(elem) + return string.join(result, os.sep) + def list_branch_directory(self, branch, path, relpath): tree = branch.basis_tree() file_id = tree.path2id(relpath) ie = tree.inventory[file_id] if ie.kind == 'file': return self.view_branch_file(tree, ie) + if ie.kind == 'symlink': + return self.list_branch_directory(branch, path, self.squish(osutils.dirname(relpath) + os.sep + ie.symlink_target)) entries = [] if path: entries.append({