Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.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 | 8a5ee6aa8870 |
comparison
equal
deleted
inserted
replaced
37512:aac97d043e6d | 37513:40a7c1dd2df9 |
---|---|
102 # by default, allow reading if no allow_read option has been set | 102 # by default, allow reading if no allow_read option has been set |
103 if not allow_read or ismember(ui, user, allow_read): | 103 if not allow_read or ismember(ui, user, allow_read): |
104 return True | 104 return True |
105 | 105 |
106 return False | 106 return False |
107 | |
108 def archivelist(ui, nodeid, url): | |
109 allowed = ui.configlist('web', 'allow_archive', untrusted=True) | |
110 archives = [] | |
111 | |
112 for typ, spec in webutil.archivespecs.iteritems(): | |
113 if typ in allowed or ui.configbool('web', 'allow' + typ, | |
114 untrusted=True): | |
115 archives.append({ | |
116 'type': typ, | |
117 'extension': spec[2], | |
118 'node': nodeid, | |
119 'url': url, | |
120 }) | |
121 | |
122 return archives | |
123 | 107 |
124 def rawindexentries(ui, repos, req, subdir=''): | 108 def rawindexentries(ui, repos, req, subdir=''): |
125 descend = ui.configbool('web', 'descend') | 109 descend = ui.configbool('web', 'descend') |
126 collapse = ui.configbool('web', 'collapse') | 110 collapse = ui.configbool('web', 'collapse') |
127 seenrepos = set() | 111 seenrepos = set() |
239 'url': url, | 223 'url': url, |
240 'description': description or "unknown", | 224 'description': description or "unknown", |
241 'description_sort': description.upper() or "unknown", | 225 'description_sort': description.upper() or "unknown", |
242 'lastchange': d, | 226 'lastchange': d, |
243 'lastchange_sort': d[1] - d[0], | 227 'lastchange_sort': d[1] - d[0], |
244 'archives': archivelist(u, "tip", url), | 228 'archives': webutil.archivelist(u, "tip", url), |
245 'isdirectory': None, | 229 'isdirectory': None, |
246 'labels': templateutil.hybridlist(labels, name='label'), | 230 'labels': templateutil.hybridlist(labels, name='label'), |
247 } | 231 } |
248 | 232 |
249 yield row | 233 yield row |