##// END OF EJS Templates
hgweb: extract function for loading style from request context...
Augie Fackler -
r34516:8afc25e7 default
parent child Browse files
Show More
@@ -30,6 +30,7 b' from .. import ('
30 30 hg,
31 31 hook,
32 32 profiling,
33 pycompat,
33 34 repoview,
34 35 templatefilters,
35 36 templater,
@@ -60,6 +61,17 b' archivespecs = util.sortdict(('
60 61 ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)),
61 62 ))
62 63
64 def getstyle(req, configfn, templatepath):
65 fromreq = req.form.get('style', [None])[0]
66 if fromreq is not None:
67 fromreq = pycompat.sysbytes(fromreq)
68 styles = (
69 fromreq,
70 configfn('web', 'style'),
71 'paper',
72 )
73 return styles, templater.stylemap(styles, templatepath)
74
63 75 def makebreadcrumb(url, prefix=''):
64 76 '''Return a 'URL breadcrumb' list
65 77
@@ -170,12 +182,8 b' class requestcontext(object):'
170 182 # figure out which style to use
171 183
172 184 vars = {}
173 styles = (
174 req.form.get('style', [None])[0],
175 self.config('web', 'style'),
176 'paper',
177 )
178 style, mapfile = templater.stylemap(styles, self.templatepath)
185 styles, (style, mapfile) = getstyle(req, self.config,
186 self.templatepath)
179 187 if style == styles[0]:
180 188 vars['style'] = style
181 189
@@ -503,12 +503,8 b' class hgwebdir(object):'
503 503 url += '/'
504 504
505 505 vars = {}
506 styles = (
507 req.form.get('style', [None])[0],
508 config('web', 'style'),
509 'paper'
510 )
511 style, mapfile = templater.stylemap(styles, self.templatepath)
506 styles, (style, mapfile) = hgweb_mod.getstyle(req, config,
507 self.templatepath)
512 508 if style == styles[0]:
513 509 vars['style'] = style
514 510
General Comments 0
You need to be logged in to leave comments. Login now