Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 36868:8ddb5c354906
hgweb: expose repo name on parsedrequest
I'm not a fan of doing this because I want to find a better solution to
the REPO_NAME hack. But this change gets us a few steps closer to
eliminating use of wsgirequest. We can worry about fixing REPO_NAME
once wsgirequest is gone.
Differential Revision: https://phab.mercurial-scm.org/D2784
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 10 Mar 2018 14:06:58 -0800 |
parents | cf69df7ea385 |
children | 7ad6a275316f |
comparison
equal
deleted
inserted
replaced
36867:a755fd3b7146 | 36868:8ddb5c354906 |
---|---|
139 allowed = self.configlist('web', 'allow_archive') | 139 allowed = self.configlist('web', 'allow_archive') |
140 for typ, spec in self.archivespecs.iteritems(): | 140 for typ, spec in self.archivespecs.iteritems(): |
141 if typ in allowed or self.configbool('web', 'allow%s' % typ): | 141 if typ in allowed or self.configbool('web', 'allow%s' % typ): |
142 yield {'type': typ, 'extension': spec[2], 'node': nodeid} | 142 yield {'type': typ, 'extension': spec[2], 'node': nodeid} |
143 | 143 |
144 def templater(self, wsgireq, req): | 144 def templater(self, req): |
145 # determine scheme, port and server name | 145 # determine scheme, port and server name |
146 # this is needed to create absolute urls | 146 # this is needed to create absolute urls |
147 logourl = self.config('web', 'logourl') | 147 logourl = self.config('web', 'logourl') |
148 logoimg = self.config('web', 'logoimg') | 148 logoimg = self.config('web', 'logoimg') |
149 staticurl = (self.config('web', 'staticurl') | 149 staticurl = (self.config('web', 'staticurl') |
157 yield self.config('web', 'motd') | 157 yield self.config('web', 'motd') |
158 | 158 |
159 # figure out which style to use | 159 # figure out which style to use |
160 | 160 |
161 vars = {} | 161 vars = {} |
162 styles, (style, mapfile) = getstyle(wsgireq.req, self.config, | 162 styles, (style, mapfile) = getstyle(req, self.config, |
163 self.templatepath) | 163 self.templatepath) |
164 if style == styles[0]: | 164 if style == styles[0]: |
165 vars['style'] = style | 165 vars['style'] = style |
166 | 166 |
167 sessionvars = webutil.sessionvars(vars, '?') | 167 sessionvars = webutil.sessionvars(vars, '?') |
168 | 168 |
169 if not self.reponame: | 169 if not self.reponame: |
170 self.reponame = (self.config('web', 'name', '') | 170 self.reponame = (self.config('web', 'name', '') |
171 or wsgireq.env.get('REPO_NAME') | 171 or req.reponame |
172 or req.apppath or self.repo.root) | 172 or req.apppath |
173 or self.repo.root) | |
173 | 174 |
174 def websubfilter(text): | 175 def websubfilter(text): |
175 return templatefilters.websub(text, self.websubtable) | 176 return templatefilters.websub(text, self.websubtable) |
176 | 177 |
177 # create the templater | 178 # create the templater |
370 cmd = req.qsparams.get('cmd', '') | 371 cmd = req.qsparams.get('cmd', '') |
371 | 372 |
372 # process the web interface request | 373 # process the web interface request |
373 | 374 |
374 try: | 375 try: |
375 tmpl = rctx.templater(wsgireq, req) | 376 tmpl = rctx.templater(req) |
376 ctype = tmpl('mimetype', encoding=encoding.encoding) | 377 ctype = tmpl('mimetype', encoding=encoding.encoding) |
377 ctype = templater.stringify(ctype) | 378 ctype = templater.stringify(ctype) |
378 | 379 |
379 # check read permissions non-static content | 380 # check read permissions non-static content |
380 if cmd != 'static': | 381 if cmd != 'static': |