Mercurial > hg
comparison mercurial/hgweb/webutil.py @ 37513:40a7c1dd2df9
hgweb: move archivelist() of hgwebdir to webutil
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 01 Apr 2018 22:37:03 +0900 |
parents | 356e61e82c2a |
children | 034a422aeaff |
comparison
equal
deleted
inserted
replaced
37512:aac97d043e6d | 37513:40a7c1dd2df9 |
---|---|
46 archivespecs = util.sortdict(( | 46 archivespecs = util.sortdict(( |
47 ('zip', ('application/zip', 'zip', '.zip', None)), | 47 ('zip', ('application/zip', 'zip', '.zip', None)), |
48 ('gz', ('application/x-gzip', 'tgz', '.tar.gz', None)), | 48 ('gz', ('application/x-gzip', 'tgz', '.tar.gz', None)), |
49 ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), | 49 ('bz2', ('application/x-bzip2', 'tbz2', '.tar.bz2', None)), |
50 )) | 50 )) |
51 | |
52 def archivelist(ui, nodeid, url): | |
53 allowed = ui.configlist('web', 'allow_archive', untrusted=True) | |
54 archives = [] | |
55 | |
56 for typ, spec in archivespecs.iteritems(): | |
57 if typ in allowed or ui.configbool('web', 'allow' + typ, | |
58 untrusted=True): | |
59 archives.append({ | |
60 'type': typ, | |
61 'extension': spec[2], | |
62 'node': nodeid, | |
63 'url': url, | |
64 }) | |
65 | |
66 return archives | |
51 | 67 |
52 def up(p): | 68 def up(p): |
53 if p[0:1] != "/": | 69 if p[0:1] != "/": |
54 p = "/" + p | 70 p = "/" + p |
55 if p[-1:] == "/": | 71 if p[-1:] == "/": |