##// END OF EJS Templates
hgweb: expose list of per-repo labels to templates...
Gregory Szorc -
r29471:c4fc33c4 default
parent child Browse files
Show More
@@ -2026,6 +2026,14 b' The full set of options is:'
2026 ``ipv6``
2026 ``ipv6``
2027 Whether to use IPv6. (default: False)
2027 Whether to use IPv6. (default: False)
2028
2028
2029 ``labels``
2030 List of string *labels* associated with the repository.
2031
2032 Labels are exposed as a template keyword and can be used to customize
2033 output. e.g. the ``index`` template can group or filter repositories
2034 by labels and the ``summary`` template can display additional content
2035 if a specific label is present.
2036
2029 ``logoimg``
2037 ``logoimg``
2030 File name of the logo image that some templates display on each page.
2038 File name of the logo image that some templates display on each page.
2031 The file name is relative to ``staticurl``. That is, the full path to
2039 The file name is relative to ``staticurl``. That is, the full path to
@@ -366,7 +366,9 b' class hgwebdir(object):'
366 'lastchange': d,
366 'lastchange': d,
367 'lastchange_sort': d[1]-d[0],
367 'lastchange_sort': d[1]-d[0],
368 'archives': [],
368 'archives': [],
369 'isdirectory': True}
369 'isdirectory': True,
370 'labels': [],
371 }
370
372
371 seendirs.add(name)
373 seendirs.add(name)
372 yield row
374 yield row
@@ -416,6 +418,7 b' class hgwebdir(object):'
416 'lastchange_sort': d[1]-d[0],
418 'lastchange_sort': d[1]-d[0],
417 'archives': archivelist(u, "tip", url),
419 'archives': archivelist(u, "tip", url),
418 'isdirectory': None,
420 'isdirectory': None,
421 'labels': u.configlist('web', 'labels', untrusted=True),
419 }
422 }
420
423
421 yield row
424 yield row
@@ -725,7 +725,8 b' def summary(web, req, tmpl):'
725 shortlog=changelist,
725 shortlog=changelist,
726 node=tip.hex(),
726 node=tip.hex(),
727 symrev='tip',
727 symrev='tip',
728 archives=web.archivelist("tip"))
728 archives=web.archivelist("tip"),
729 labels=web.configlist('web', 'labels'))
729
730
730 @webcommand('filediff')
731 @webcommand('filediff')
731 def filediff(web, req, tmpl):
732 def filediff(web, req, tmpl):
@@ -109,7 +109,8 b" summary = '\\{"
109 "branches": [{join(branches%branchentry, ", ")}],
109 "branches": [{join(branches%branchentry, ", ")}],
110 "shortlog": [{join(shortlog%shortlogentry, ", ")}],
110 "shortlog": [{join(shortlog%shortlogentry, ", ")}],
111 "tags": [{join(tags%tagentry, ", ")}],
111 "tags": [{join(tags%tagentry, ", ")}],
112 "archives": [{join(archives%archiveentry, ", ")}]
112 "archives": [{join(archives%archiveentry, ", ")}],
113 "labels": {labels|json}
113 }'
114 }'
114 archiveentry = '\{
115 archiveentry = '\{
115 "node": {node|json},
116 "node": {node|json},
@@ -220,5 +221,6 b" indexentry = '\\{"
220 "name": {name|utf8|json},
221 "name": {name|utf8|json},
221 "description": {description|utf8|json},
222 "description": {description|utf8|json},
222 "contact": {contact|utf8|json},
223 "contact": {contact|utf8|json},
223 "lastchange": {lastchange|json}
224 "lastchange": {lastchange|json},
225 "labels": {labels|json}
224 }'
226 }'
@@ -848,6 +848,7 b' summary/ shows a summary of repository s'
848 "status": "inactive"
848 "status": "inactive"
849 }
849 }
850 ],
850 ],
851 "labels": [],
851 "lastchange": [
852 "lastchange": [
852 0.0,
853 0.0,
853 0
854 0
@@ -62,6 +62,7 b' create a subdirectory containing reposit'
62 $ cat >> f/.hg/hgrc << EOF
62 $ cat >> f/.hg/hgrc << EOF
63 > [web]
63 > [web]
64 > name = fancy name for repo f
64 > name = fancy name for repo f
65 > labels = foo, bar
65 > EOF
66 > EOF
66 $ cd ..
67 $ cd ..
67
68
@@ -108,12 +109,14 b' should succeed'
108 "name": "a",
109 "name": "a",
109 "description": "unknown",
110 "description": "unknown",
110 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
111 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
111 "lastchange": [*, *] (glob)
112 "lastchange": [*, *], (glob)
113 "labels": []
112 }, {
114 }, {
113 "name": "b",
115 "name": "b",
114 "description": "unknown",
116 "description": "unknown",
115 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
117 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
116 "lastchange": [*, *] (glob)
118 "lastchange": [*, *], (glob)
119 "labels": []
117 }]
120 }]
118 } (no-eol)
121 } (no-eol)
119
122
@@ -201,6 +204,218 b' should succeed, slashy names'
201 /astar/
204 /astar/
202 /astar/.hg/patches/
205 /astar/.hg/patches/
203
206
207
208 $ get-with-headers.py localhost:$HGPORT1 '?style=json'
209 200 Script output follows
210
211 {
212 "entries": [{
213 "name": "t/a",
214 "description": "unknown",
215 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
216 "lastchange": [*, *], (glob)
217 "labels": []
218 }, {
219 "name": "b",
220 "description": "unknown",
221 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
222 "lastchange": [*, *], (glob)
223 "labels": []
224 }, {
225 "name": "coll/a",
226 "description": "unknown",
227 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
228 "lastchange": [*, *], (glob)
229 "labels": []
230 }, {
231 "name": "coll/a/.hg/patches",
232 "description": "unknown",
233 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
234 "lastchange": [*, *], (glob)
235 "labels": []
236 }, {
237 "name": "coll/b",
238 "description": "unknown",
239 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
240 "lastchange": [*, *], (glob)
241 "labels": []
242 }, {
243 "name": "coll/c",
244 "description": "unknown",
245 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
246 "lastchange": [*, *], (glob)
247 "labels": []
248 }, {
249 "name": "coll/notrepo/e",
250 "description": "unknown",
251 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
252 "lastchange": [*, *], (glob)
253 "labels": []
254 }, {
255 "name": "fancy name for repo f",
256 "description": "unknown",
257 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
258 "lastchange": [*, *], (glob)
259 "labels": ["foo", "bar"]
260 }, {
261 "name": "rcoll/a",
262 "description": "unknown",
263 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
264 "lastchange": [*, *], (glob)
265 "labels": []
266 }, {
267 "name": "rcoll/a/.hg/patches",
268 "description": "unknown",
269 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
270 "lastchange": [*, *], (glob)
271 "labels": []
272 }, {
273 "name": "rcoll/b",
274 "description": "unknown",
275 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
276 "lastchange": [*, *], (glob)
277 "labels": []
278 }, {
279 "name": "rcoll/b/d",
280 "description": "unknown",
281 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
282 "lastchange": [*, *], (glob)
283 "labels": []
284 }, {
285 "name": "rcoll/c",
286 "description": "unknown",
287 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
288 "lastchange": [*, *], (glob)
289 "labels": []
290 }, {
291 "name": "rcoll/notrepo/e",
292 "description": "unknown",
293 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
294 "lastchange": [*, *], (glob)
295 "labels": []
296 }, {
297 "name": "rcoll/notrepo/e/e2",
298 "description": "unknown",
299 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
300 "lastchange": [*, *], (glob)
301 "labels": []
302 }, {
303 "name": "fancy name for repo f",
304 "description": "unknown",
305 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
306 "lastchange": [*, *], (glob)
307 "labels": ["foo", "bar"]
308 }, {
309 "name": "rcoll/notrepo/f/f2",
310 "description": "unknown",
311 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
312 "lastchange": [*, *], (glob)
313 "labels": []
314 }, {
315 "name": "star/webdir/a",
316 "description": "unknown",
317 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
318 "lastchange": [*, *], (glob)
319 "labels": []
320 }, {
321 "name": "star/webdir/a/.hg/patches",
322 "description": "unknown",
323 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
324 "lastchange": [*, *], (glob)
325 "labels": []
326 }, {
327 "name": "star/webdir/b",
328 "description": "unknown",
329 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
330 "lastchange": [*, *], (glob)
331 "labels": []
332 }, {
333 "name": "star/webdir/c",
334 "description": "unknown",
335 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
336 "lastchange": [*, *], (glob)
337 "labels": []
338 }, {
339 "name": "star/webdir/notrepo/e",
340 "description": "unknown",
341 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
342 "lastchange": [*, *], (glob)
343 "labels": []
344 }, {
345 "name": "fancy name for repo f",
346 "description": "unknown",
347 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
348 "lastchange": [*, *], (glob)
349 "labels": ["foo", "bar"]
350 }, {
351 "name": "starstar/webdir/a",
352 "description": "unknown",
353 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
354 "lastchange": [*, *], (glob)
355 "labels": []
356 }, {
357 "name": "starstar/webdir/a/.hg/patches",
358 "description": "unknown",
359 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
360 "lastchange": [*, *], (glob)
361 "labels": []
362 }, {
363 "name": "starstar/webdir/b",
364 "description": "unknown",
365 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
366 "lastchange": [*, *], (glob)
367 "labels": []
368 }, {
369 "name": "starstar/webdir/b/d",
370 "description": "unknown",
371 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
372 "lastchange": [*, *], (glob)
373 "labels": []
374 }, {
375 "name": "starstar/webdir/c",
376 "description": "unknown",
377 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
378 "lastchange": [*, *], (glob)
379 "labels": []
380 }, {
381 "name": "starstar/webdir/notrepo/e",
382 "description": "unknown",
383 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
384 "lastchange": [*, *], (glob)
385 "labels": []
386 }, {
387 "name": "starstar/webdir/notrepo/e/e2",
388 "description": "unknown",
389 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
390 "lastchange": [*, *], (glob)
391 "labels": []
392 }, {
393 "name": "fancy name for repo f",
394 "description": "unknown",
395 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
396 "lastchange": [*, *], (glob)
397 "labels": ["foo", "bar"]
398 }, {
399 "name": "starstar/webdir/notrepo/f/f2",
400 "description": "unknown",
401 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
402 "lastchange": [*, *], (glob)
403 "labels": []
404 }, {
405 "name": "astar",
406 "description": "unknown",
407 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
408 "lastchange": [*, *], (glob)
409 "labels": []
410 }, {
411 "name": "astar/.hg/patches",
412 "description": "unknown",
413 "contact": "Foo Bar \u003cfoo.bar@example.com\u003e",
414 "lastchange": [*, *], (glob)
415 "labels": []
416 }]
417 } (no-eol)
418
204 $ get-with-headers.py localhost:$HGPORT1 '?style=paper'
419 $ get-with-headers.py localhost:$HGPORT1 '?style=paper'
205 200 Script output follows
420 200 Script output follows
206
421
General Comments 0
You need to be logged in to leave comments. Login now