comparison mercurial/hgweb/hgwebdir_mod.py @ 6221:2eb18c780287

Support web.baseurl in hgwebdir, overriding SCRIPT_NAME
author Brendan Cully <brendan@kublai.com>
date Sat, 08 Mar 2008 17:19:18 -0800
parents fe8dbbe9520d
children c93b6c0e6e84
comparison
equal deleted inserted replaced
6220:1939e29151ca 6221:2eb18c780287
26 interactive = False) 26 interactive = False)
27 self.motd = None 27 self.motd = None
28 self.style = None 28 self.style = None
29 self.stripecount = None 29 self.stripecount = None
30 self.repos_sorted = ('name', False) 30 self.repos_sorted = ('name', False)
31 self._baseurl = None
31 if isinstance(config, (list, tuple)): 32 if isinstance(config, (list, tuple)):
32 self.repos = cleannames(config) 33 self.repos = cleannames(config)
33 self.repos_sorted = ('', False) 34 self.repos_sorted = ('', False)
34 elif isinstance(config, dict): 35 elif isinstance(config, dict):
35 self.repos = cleannames(config.items()) 36 self.repos = cleannames(config.items())
46 self.motd = cp.get('web', 'motd') 47 self.motd = cp.get('web', 'motd')
47 if cp.has_option('web', 'style'): 48 if cp.has_option('web', 'style'):
48 self.style = cp.get('web', 'style') 49 self.style = cp.get('web', 'style')
49 if cp.has_option('web', 'stripes'): 50 if cp.has_option('web', 'stripes'):
50 self.stripecount = int(cp.get('web', 'stripes')) 51 self.stripecount = int(cp.get('web', 'stripes'))
52 if cp.has_option('web', 'baseurl'):
53 self._baseurl = cp.get('web', 'baseurl')
51 if cp.has_section('paths'): 54 if cp.has_section('paths'):
52 self.repos.extend(cleannames(cp.items('paths'))) 55 self.repos.extend(cleannames(cp.items('paths')))
53 if cp.has_section('collections'): 56 if cp.has_section('collections'):
54 for prefix, root in cp.items('collections'): 57 for prefix, root in cp.items('collections'):
55 for path in util.walkrepos(root): 58 for path in util.walkrepos(root):
231 sort = [("sort_%s" % column, 234 sort = [("sort_%s" % column,
232 "%s%s" % ((not descending and column == sortcolumn) 235 "%s%s" % ((not descending and column == sortcolumn)
233 and "-" or "", column)) 236 and "-" or "", column))
234 for column in sortable] 237 for column in sortable]
235 238
239 if self._baseurl is not None:
240 req.env['SCRIPT_NAME'] = self._baseurl
241
236 return tmpl("index", entries=entries, subdir=subdir, 242 return tmpl("index", entries=entries, subdir=subdir,
237 sortcolumn=sortcolumn, descending=descending, 243 sortcolumn=sortcolumn, descending=descending,
238 **dict(sort)) 244 **dict(sort))
239 245
240 def templater(self, req): 246 def templater(self, req):
251 else: 257 else:
252 yield config('web', 'motd', '') 258 yield config('web', 'motd', '')
253 259
254 def config(section, name, default=None, untrusted=True): 260 def config(section, name, default=None, untrusted=True):
255 return self.parentui.config(section, name, default, untrusted) 261 return self.parentui.config(section, name, default, untrusted)
262
263 if self._baseurl is not None:
264 req.env['SCRIPT_NAME'] = self._baseurl
256 265
257 url = req.env.get('SCRIPT_NAME', '') 266 url = req.env.get('SCRIPT_NAME', '')
258 if not url.endswith('/'): 267 if not url.endswith('/'):
259 url += '/' 268 url += '/'
260 269