17
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
from paste.request import path_info_pop
23
26
from paste.httpexceptions import HTTPBadRequest
25
from loggerhead.controllers import TemplatedBranchView
26
28
from loggerhead import util
29
from loggerhead.templatefunctions import templatefunctions
30
from loggerhead.zptsupport import load_template
33
log = logging.getLogger("loggerhead.controllers")
30
36
while path.endswith('/'):
32
38
path = posixpath.dirname(path)
35
class AnnotateUI (TemplatedBranchView):
37
template_path = 'loggerhead.templates.annotate'
39
def get_values(self, h, args, kw, headers):
41
revid = h.fix_revid(args[0])
47
path = '/'.join(args[1:])
48
if not path.startswith('/'):
51
file_id = kw.get('file_id', None)
52
if (file_id is None) and (path is None):
53
raise HTTPBadRequest('No file_id or filename provided to annotate')
56
file_id = h.get_file_id(revid, path)
58
# no navbar for revisions
59
navigation = util.Container()
62
path = h.get_path(revid, file_id)
63
filename = os.path.basename(path)
70
'navigation': navigation,
71
'change': h.get_changes([ revid ])[0],
72
'contents': list(h.annotate_file(file_id, revid)),
73
'fileview_active': True,
42
class AnnotateUI (object):
44
def __init__(self, branch):
49
def default(self, request, response):
51
h = self._branch.history
59
arg = path_info_pop(request.environ)
65
revid = h.fix_revid(args[0])
71
path = '/'.join(args[1:])
72
if not path.startswith('/'):
75
file_id = kw.get('file_id', None)
76
if (file_id is None) and (path is None):
77
raise HTTPBadRequest('No file_id or filename provided to annotate')
80
file_id = h.get_file_id(revid, path)
82
# no navbar for revisions
83
navigation = util.Container()
86
path = h.get_path(revid, file_id)
87
filename = os.path.basename(path)
90
'branch': self._branch,
97
'navigation': navigation,
98
'change': h.get_changes([ revid ])[0],
99
'contents': list(h.annotate_file(file_id, revid)),
100
'url': self._branch.context_url,
102
vals.update(templatefunctions)
103
self.log.info('/annotate: %r secs' % (time.time() - z,))
104
response.headers['Content-Type'] = 'text/html'
105
template = load_template('loggerhead.templates.annotate')
106
template.expand_into(response, **vals)