140 allowed = self.configlist('web', 'allow_archive') |
140 allowed = self.configlist('web', 'allow_archive') |
141 for typ, spec in self.archivespecs.iteritems(): |
141 for typ, spec in self.archivespecs.iteritems(): |
142 if typ in allowed or self.configbool('web', 'allow%s' % typ): |
142 if typ in allowed or self.configbool('web', 'allow%s' % typ): |
143 yield {'type': typ, 'extension': spec[2], 'node': nodeid} |
143 yield {'type': typ, 'extension': spec[2], 'node': nodeid} |
144 |
144 |
145 def templater(self, wsgireq): |
145 def templater(self, wsgireq, req): |
146 # determine scheme, port and server name |
146 # determine scheme, port and server name |
147 # this is needed to create absolute urls |
147 # this is needed to create absolute urls |
148 |
|
149 proto = wsgireq.env.get('wsgi.url_scheme') |
|
150 if proto == 'https': |
|
151 proto = 'https' |
|
152 default_port = '443' |
|
153 else: |
|
154 proto = 'http' |
|
155 default_port = '80' |
|
156 |
|
157 port = wsgireq.env[r'SERVER_PORT'] |
|
158 port = port != default_port and (r':' + port) or r'' |
|
159 urlbase = r'%s://%s%s' % (proto, wsgireq.env[r'SERVER_NAME'], port) |
|
160 logourl = self.config('web', 'logourl') |
148 logourl = self.config('web', 'logourl') |
161 logoimg = self.config('web', 'logoimg') |
149 logoimg = self.config('web', 'logoimg') |
162 staticurl = (self.config('web', 'staticurl') |
150 staticurl = (self.config('web', 'staticurl') |
163 or pycompat.sysbytes(wsgireq.url) + 'static/') |
151 or pycompat.sysbytes(wsgireq.url) + 'static/') |
164 if not staticurl.endswith('/'): |
152 if not staticurl.endswith('/'): |
192 defaults = { |
180 defaults = { |
193 'url': pycompat.sysbytes(wsgireq.url), |
181 'url': pycompat.sysbytes(wsgireq.url), |
194 'logourl': logourl, |
182 'logourl': logourl, |
195 'logoimg': logoimg, |
183 'logoimg': logoimg, |
196 'staticurl': staticurl, |
184 'staticurl': staticurl, |
197 'urlbase': urlbase, |
185 'urlbase': req.advertisedbaseurl, |
198 'repo': self.reponame, |
186 'repo': self.reponame, |
199 'encoding': encoding.encoding, |
187 'encoding': encoding.encoding, |
200 'motd': motd, |
188 'motd': motd, |
201 'sessionvars': sessionvars, |
189 'sessionvars': sessionvars, |
202 'pathdef': makebreadcrumb(pycompat.sysbytes(wsgireq.url)), |
190 'pathdef': makebreadcrumb(pycompat.sysbytes(wsgireq.url)), |
394 cmd = wsgireq.form.get('cmd', [''])[0] |
382 cmd = wsgireq.form.get('cmd', [''])[0] |
395 |
383 |
396 # process the web interface request |
384 # process the web interface request |
397 |
385 |
398 try: |
386 try: |
399 tmpl = rctx.templater(wsgireq) |
387 tmpl = rctx.templater(wsgireq, req) |
400 ctype = tmpl('mimetype', encoding=encoding.encoding) |
388 ctype = tmpl('mimetype', encoding=encoding.encoding) |
401 ctype = templater.stringify(ctype) |
389 ctype = templater.stringify(ctype) |
402 |
390 |
403 # check read permissions non-static content |
391 # check read permissions non-static content |
404 if cmd != 'static': |
392 if cmd != 'static': |