Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgweb_mod.py @ 30749:e38e7ea21987
hgweb: use archivespecs for links on repo index page too
Moving archivespecs to the module level allows using it from other modules
(such as hgwebdir_mod), and keeping a reference to it in requestcontext allows
current code to just work.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Tue, 10 Jan 2017 23:41:58 +0800 |
parents | 319914d57b9e |
children | d7bf7d2bd5ab |
comparison
equal
deleted
inserted
replaced
30748:319914d57b9e | 30749:e38e7ea21987 |
---|---|
51 'listkeys': 'pull', | 51 'listkeys': 'pull', |
52 'unbundle': 'push', | 52 'unbundle': 'push', |
53 'pushkey': 'push', | 53 'pushkey': 'push', |
54 } | 54 } |
55 | 55 |
56 archivespecs = util.sortdict(( | |
57 ('zip', ('application/zip', 'zip', '.zip', None)), | |
58 ('gz', ('application/x-gzip', 'tgz', '.tar.gz', None)), | |
59 ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), | |
60 )) | |
61 | |
56 def makebreadcrumb(url, prefix=''): | 62 def makebreadcrumb(url, prefix=''): |
57 '''Return a 'URL breadcrumb' list | 63 '''Return a 'URL breadcrumb' list |
58 | 64 |
59 A 'URL breadcrumb' is a list of URL-name pairs, | 65 A 'URL breadcrumb' is a list of URL-name pairs, |
60 corresponding to each of the path items on a URL. | 66 corresponding to each of the path items on a URL. |
87 """ | 93 """ |
88 def __init__(self, app, repo): | 94 def __init__(self, app, repo): |
89 self.repo = repo | 95 self.repo = repo |
90 self.reponame = app.reponame | 96 self.reponame = app.reponame |
91 | 97 |
98 self.archivespecs = archivespecs | |
99 | |
92 self.maxchanges = self.configint('web', 'maxchanges', 10) | 100 self.maxchanges = self.configint('web', 'maxchanges', 10) |
93 self.stripecount = self.configint('web', 'stripes', 1) | 101 self.stripecount = self.configint('web', 'stripes', 1) |
94 self.maxshortchanges = self.configint('web', 'maxshortchanges', 60) | 102 self.maxshortchanges = self.configint('web', 'maxshortchanges', 60) |
95 self.maxfiles = self.configint('web', 'maxfiles', 10) | 103 self.maxfiles = self.configint('web', 'maxfiles', 10) |
96 self.allowpull = self.configbool('web', 'allowpull', True) | 104 self.allowpull = self.configbool('web', 'allowpull', True) |
121 untrusted=untrusted) | 129 untrusted=untrusted) |
122 | 130 |
123 def configlist(self, section, name, default=None, untrusted=True): | 131 def configlist(self, section, name, default=None, untrusted=True): |
124 return self.repo.ui.configlist(section, name, default, | 132 return self.repo.ui.configlist(section, name, default, |
125 untrusted=untrusted) | 133 untrusted=untrusted) |
126 | |
127 archivespecs = util.sortdict(( | |
128 ('zip', ('application/zip', 'zip', '.zip', None)), | |
129 ('gz', ('application/x-gzip', 'tgz', '.tar.gz', None)), | |
130 ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), | |
131 )) | |
132 | 134 |
133 def archivelist(self, nodeid): | 135 def archivelist(self, nodeid): |
134 allowed = self.configlist('web', 'allow_archive') | 136 allowed = self.configlist('web', 'allow_archive') |
135 for typ, spec in self.archivespecs.iteritems(): | 137 for typ, spec in self.archivespecs.iteritems(): |
136 if typ in allowed or self.configbool('web', 'allow%s' % typ): | 138 if typ in allowed or self.configbool('web', 'allow%s' % typ): |