# # # patch "common.py" # from [0cbdb7bb1e1d01d969e90c7ab26c44f5c040ae0e] # to [bed52f2f106cc51a9c0b8e3f524143a59c629ada] # # patch "file.psp" # from [28f5d897cbd289acf8d43be870f4b3438fb02105] # to [b18003b58deaf7a838a644a0757d57c5e8b69f91] # # patch "html.py" # from [964194d9992461ea80768e0bc9040bf0458ad7b2] # to [306dd5b8e9fc7b0f908a74372b917ff314ffe8c9] # # patch "manifest.psp" # from [fcdfd69429d01f891243d298d3a4eddc268ad7ec] # to [707922f63bdcc200ab716a047b3116afb0ffccf2] # # patch "revision.psp" # from [4af0bccc119512f074c3c639e02ed7acd6e02994] # to [b0be5ff714ff6ecdf9f86b4dd34d8d1fa8044d0e] # # patch "viewmtn.css" # from [ed02217b53a22506e73f4f608a2f902b09f19ea1] # to [6efcadac0d56fb3d77a22786f477ba621f4af33d] # ============================================================ --- common.py 0cbdb7bb1e1d01d969e90c7ab26c44f5c040ae0e +++ common.py bed52f2f106cc51a9c0b8e3f524143a59c629ada @@ -17,7 +17,17 @@ def parse_timecert(value): return apply(datetime.datetime, time.strptime(value, "%Y-%m-%dT%H:%M:%S")[:6]) -def extract_cert_from_certs(certs, certname): +def get_branch_links(mt, branches): + if len(branches) > 1: + branch_links = "branches " + else: + branch_links = "branch " + for branch in branches: + branch_links += link(mt, "branch", branch) + return branch_links + +def extract_cert_from_certs(certs, certname, as_list=False): + rv = [] for cert in certs: name, value = None, None for k, v in cert: @@ -25,7 +35,11 @@ elif k == "value": value = v if name == None or value == None: continue if name == certname: - return value + if not as_list: + return value + else: + rv.append(value) + return rv def determine_date(certs): dateval = extract_cert_from_certs(certs, "date") @@ -124,7 +138,11 @@ else: rv += "head of " + hq(link_to) rv += '' elif link_type == "manifest": - rv = '' % (urllib.quote(link_to)) + if type(link_to) == type([]): + link_to, path = link_to + rv = '' % (urllib.quote(link_to), urllib.quote(path)) + else: + rv = '' % (urllib.quote(link_to)) if description != None: rv += description else: rv += hq(link_to[:8]) + ".." rv += '' ============================================================ --- file.psp 28f5d897cbd289acf8d43be870f4b3438fb02105 +++ file.psp b18003b58deaf7a838a644a0757d57c5e8b69f91 @@ -12,7 +12,7 @@ from enscriptlangs import enscript_langs from html import get_icon, TableWriter from utility import run_command -from common import colourise_code +from common import colourise_code, get_branch_links # file.psp ; provide information about a file # if possible, display it (with syntax highlighting, etc.) @@ -32,7 +32,7 @@ path = form['path'] certs = mt.certs(id) -branch = common.extract_cert_from_certs(certs, "branch") +branches = common.extract_cert_from_certs(certs, "branch", as_list=True) revision = mt.revision(id) if not revision.has_key('new_manifest'): @@ -48,8 +48,18 @@ if matching_file_id == None: raise Exception("File not found in this revision.") +link_components = "" +components = [''] +components += path.split('/') +for idx, component in enumerate(components[:-1]): + link_components += link("manifest", [id, '/'.join(components[:idx+1])], component + '/') +link_components += components[-1] +branch_links = get_branch_links(mt, branches) + info = { - 'title' : "File '/%s' in revision %s" % (hq(path), hq(id)), + 'title' : "File '%s' in revision %s of %s" % (link_components, + link("revision", id), + branch_links) } req.write(template.header(info)) @@ -59,7 +69,7 @@ req.write('

You can also %s the file verbatim. In addition, this %s will always download the latest revision of the file.

' \ % (link("download", [matching_file_id, path], "download"), - link("fileinbranch", [branch, path], "link"))) + link("fileinbranch", [branches[0], path], "link"))) ### FIXME FIXME ### this means having _the entire file_ in memory ============================================================ --- html.py 964194d9992461ea80768e0bc9040bf0458ad7b2 +++ html.py 306dd5b8e9fc7b0f908a74372b917ff314ffe8c9 @@ -43,20 +43,33 @@ def stop(self): self.req.write('') +def strip_html_from(t): + in_tag, rv = False, '' + for c in t: + if in_tag and c == '>': + in_tag = False + elif not in_tag and c == '<': + in_tag = True + elif not in_tag: + rv += c + return rv + class Template: def header(self, info): if not info.has_key("title"): info['title'] = "untitled" - if not info.has_key("extra_header"): info['extra_header'] = '' + if not info.has_key("extra_header"): info['extra_header'] = '' + if not info.has_key("short_title"): + info["short_title"] = strip_html_from(info["title"]) if info.has_key('branch_rss'): for branch in info['branch_rss']: - info['extra_header'] += '\n' % (urllib.quote(branch), hq(branch)) + info['extra_header'] += '\n' % (urllib.quote(branch), hq(branch)) return """\ - ViewMTN: %(title)s + ViewMTN: %(short_title)s @@ -75,7 +88,7 @@ rv = """ ============================================================ --- manifest.psp fcdfd69429d01f891243d298d3a4eddc268ad7ec +++ manifest.psp 707922f63bdcc200ab716a047b3116afb0ffccf2 @@ -7,6 +7,7 @@ import urllib import time from html import get_icon, TableWriter +from common import get_branch_links # # manifest.psp @@ -29,14 +30,26 @@ if path.startswith('/'): path = path[1:] if path.endswith('/'): path = path[-1:] +certs = mt.certs(id) revision = mt.revision(id) if not revision.has_key('new_manifest'): raise Exception("There is no manifest in this revision ID.") manifest_id = revision['new_manifest'][0][1] manifest = mt.manifest(manifest_id) +link_components = "" +components = [''] +components += path.split('/') +for idx, component in enumerate(components[:-1]): + link_components += link("manifest", [id, '/'.join(components[:idx+1])], component + '/') +link_components += components[-1] +branches = common.extract_cert_from_certs(certs, "branch", as_list=True) +branch_links = get_branch_links(mt, branches) + info = { - 'title' : "Dir '/%s' in revision %s" % (hq(path), hq(id)), + 'title' : "Dir '%s' in revision %s of %s" % (link_components, + link("revision", id), + branch_links) } req.write(template.header(info)) %> @@ -157,7 +170,9 @@ tr.write('NameAgeAuthorLast log entry', is_header=True) icon_uri = get_icon('', is_directory=True) for name, subdir in subdirs: - tr.write('%s' % (icon_uri, urllib.quote(id), urllib.quote(subdir), hq(name))) + tr.write('%s' % (icon_uri, + link("manifest", + [id, subdir], name))) for name, file_id, file in files: icon_uri = get_icon(file) if icon_uri != None: ============================================================ --- revision.psp 4af0bccc119512f074c3c639e02ed7acd6e02994 +++ revision.psp b0be5ff714ff6ecdf9f86b4dd34d8d1fa8044d0e @@ -5,7 +5,7 @@ import datetime import common import urllib -from common import parse_timecert, ago_string +from common import parse_timecert, ago_string, get_branch_links # # revision.psp @@ -44,8 +44,13 @@ value = '
'.join(map(hq, value.split('\n'))) cert_table += '%s%s' % (prettify(name), value) +certs = mt.certs(id) +branches = common.extract_cert_from_certs(certs, "branch", as_list=True) +branch_links = get_branch_links(mt, branches) + info = { - 'title' : "Revision %s" % (hq(id)), + 'title' : "Revision '%s' for %s" % (link("revision", id), + branch_links), 'branch_rss' : branches } req.write(template.header(info)) ============================================================ --- viewmtn.css ed02217b53a22506e73f4f608a2f902b09f19ea1 +++ viewmtn.css 6efcadac0d56fb3d77a22786f477ba621f4af33d @@ -69,7 +69,7 @@ } H1#pageTitle { - font-size: 140%; + font-size: 120%; font-family: sans-serif; }