##// END OF EJS Templates
hgweb: make templater mostly compatible with log templates...
Yuya Nishihara -
r36535:7937850a default
parent child Browse files
Show More
@@ -27,6 +27,7 b' from .request import wsgirequest'
27 from .. import (
27 from .. import (
28 encoding,
28 encoding,
29 error,
29 error,
30 formatter,
30 hg,
31 hg,
31 hook,
32 hook,
32 profiling,
33 profiling,
@@ -197,7 +198,7 b' class requestcontext(object):'
197 return templatefilters.websub(text, self.websubtable)
198 return templatefilters.websub(text, self.websubtable)
198
199
199 # create the templater
200 # create the templater
200
201 # TODO: export all keywords: defaults = templatekw.keywords.copy()
201 defaults = {
202 defaults = {
202 'url': req.url,
203 'url': req.url,
203 'logourl': logourl,
204 'logourl': logourl,
@@ -212,9 +213,11 b' class requestcontext(object):'
212 'style': style,
213 'style': style,
213 'nonce': self.nonce,
214 'nonce': self.nonce,
214 }
215 }
216 tres = formatter.templateresources(self.repo.ui, self.repo)
215 tmpl = templater.templater.frommapfile(mapfile,
217 tmpl = templater.templater.frommapfile(mapfile,
216 filters={'websub': websubfilter},
218 filters={'websub': websubfilter},
217 defaults=defaults)
219 defaults=defaults,
220 resources=tres)
218 return tmpl
221 return tmpl
219
222
220
223
@@ -352,8 +352,8 b' def linerange(req):'
352 def formatlinerange(fromline, toline):
352 def formatlinerange(fromline, toline):
353 return '%d:%d' % (fromline + 1, toline)
353 return '%d:%d' % (fromline + 1, toline)
354
354
355 def succsandmarkers(repo, ctx):
355 def succsandmarkers(repo, ctx, **args):
356 for item in templatekw.showsuccsandmarkers(repo, ctx):
356 for item in templatekw.showsuccsandmarkers(repo, ctx, **args):
357 item['successors'] = _siblings(repo[successor]
357 item['successors'] = _siblings(repo[successor]
358 for successor in item['successors'])
358 for successor in item['successors'])
359 yield item
359 yield item
@@ -361,6 +361,11 b' def succsandmarkers(repo, ctx):'
361 def commonentry(repo, ctx):
361 def commonentry(repo, ctx):
362 node = ctx.node()
362 node = ctx.node()
363 return {
363 return {
364 # TODO: perhaps ctx.changectx() should be assigned if ctx is a
365 # filectx, but I'm not pretty sure if that would always work because
366 # fctx.parents() != fctx.changectx.parents() for example.
367 'ctx': ctx,
368 'revcache': {},
364 'rev': ctx.rev(),
369 'rev': ctx.rev(),
365 'node': hex(node),
370 'node': hex(node),
366 'author': ctx.user(),
371 'author': ctx.user(),
@@ -369,7 +374,7 b' def commonentry(repo, ctx):'
369 'extra': ctx.extra(),
374 'extra': ctx.extra(),
370 'phase': ctx.phasestr(),
375 'phase': ctx.phasestr(),
371 'obsolete': ctx.obsolete(),
376 'obsolete': ctx.obsolete(),
372 'succsandmarkers': lambda **x: succsandmarkers(repo, ctx),
377 'succsandmarkers': succsandmarkers,
373 'instabilities': [{"instability": i} for i in ctx.instabilities()],
378 'instabilities': [{"instability": i} for i in ctx.instabilities()],
374 'branch': nodebranchnodefault(ctx),
379 'branch': nodebranchnodefault(ctx),
375 'inbranch': nodeinbranch(repo, ctx),
380 'inbranch': nodeinbranch(repo, ctx),
General Comments 0
You need to be logged in to leave comments. Login now