Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/hgweb_mod.py @ 30735:9823e2f50a93
hgweb: generate archive links in order
It would be nice for archive links to always be in a certain commonly used
order, such as 'zip', 'bz', 'gzip2'. Repo index page (hgwebdir_mod) already
shows archive links in this order, let's do the same in hgweb_mod.
Sadly, archivespecs is a regular unordered dict, and collections.OrderedDict is
new in 2.7. But requestcontext.archives is a tuple of archive types, so it can
be used as an index to archivespecs.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Sun, 08 Jan 2017 00:52:54 +0800 |
parents | f1c9fafcbf46 |
children | 319914d57b9e |
comparison
equal
deleted
inserted
replaced
30734:b9e49f7b0220 | 30735:9823e2f50a93 |
---|---|
132 'zip': ('application/zip', 'zip', '.zip', None), | 132 'zip': ('application/zip', 'zip', '.zip', None), |
133 } | 133 } |
134 | 134 |
135 def archivelist(self, nodeid): | 135 def archivelist(self, nodeid): |
136 allowed = self.configlist('web', 'allow_archive') | 136 allowed = self.configlist('web', 'allow_archive') |
137 for typ, spec in self.archivespecs.iteritems(): | 137 for typ in self.archives: |
138 spec = self.archivespecs[typ] | |
138 if typ in allowed or self.configbool('web', 'allow%s' % typ): | 139 if typ in allowed or self.configbool('web', 'allow%s' % typ): |
139 yield {'type': typ, 'extension': spec[2], 'node': nodeid} | 140 yield {'type': typ, 'extension': spec[2], 'node': nodeid} |
140 | 141 |
141 def templater(self, req): | 142 def templater(self, req): |
142 # determine scheme, port and server name | 143 # determine scheme, port and server name |