Show More
@@ -64,25 +64,6 b' def write(*things):' | |||
|
64 | 64 | else: |
|
65 | 65 | sys.stdout.write(str(thing)) |
|
66 | 66 | |
|
67 | def template(tmpl, filters = {}, **map): | |
|
68 | while tmpl: | |
|
69 | m = re.search(r"#([a-zA-Z0-9]+)((\|[a-zA-Z0-9]+)*)#", tmpl) | |
|
70 | if m: | |
|
71 | yield tmpl[:m.start(0)] | |
|
72 | v = map.get(m.group(1), "") | |
|
73 | v = callable(v) and v(**map) or v | |
|
74 | ||
|
75 | fl = m.group(2) | |
|
76 | if fl: | |
|
77 | for f in fl.split("|")[1:]: | |
|
78 | v = filters[f](v) | |
|
79 | ||
|
80 | yield v | |
|
81 | tmpl = tmpl[m.end(0):] | |
|
82 | else: | |
|
83 | yield tmpl | |
|
84 | return | |
|
85 | ||
|
86 | 67 | class templater: |
|
87 | 68 | def __init__(self, mapfile, filters = {}, defaults = {}): |
|
88 | 69 | self.cache = {} |
@@ -109,7 +90,37 b' class templater:' | |||
|
109 | 90 | tmpl = self.cache[t] |
|
110 | 91 | except KeyError: |
|
111 | 92 | tmpl = self.cache[t] = file(self.map[t]).read() |
|
112 | return template(tmpl, self.filters, **m) | |
|
93 | return self.template(tmpl, self.filters, **m) | |
|
94 | ||
|
95 | def template(self, tmpl, filters = {}, **map): | |
|
96 | while tmpl: | |
|
97 | m = re.search(r"#([a-zA-Z0-9]+)((%[a-zA-Z0-9]+)*)((\|[a-zA-Z0-9]+)*)#", tmpl) | |
|
98 | if m: | |
|
99 | yield tmpl[:m.start(0)] | |
|
100 | v = map.get(m.group(1), "") | |
|
101 | v = callable(v) and v(**map) or v | |
|
102 | ||
|
103 | format = m.group(2) | |
|
104 | fl = m.group(4) | |
|
105 | ||
|
106 | if format: | |
|
107 | q = v.__iter__ | |
|
108 | for i in q(): | |
|
109 | lm = map.copy() | |
|
110 | lm.update(i) | |
|
111 | yield self(format[1:], **lm) | |
|
112 | ||
|
113 | v = "" | |
|
114 | ||
|
115 | elif fl: | |
|
116 | for f in fl.split("|")[1:]: | |
|
117 | v = filters[f](v) | |
|
118 | ||
|
119 | yield v | |
|
120 | tmpl = tmpl[m.end(0):] | |
|
121 | else: | |
|
122 | yield tmpl | |
|
123 | return | |
|
113 | 124 | |
|
114 | 125 | def rfc822date(x): |
|
115 | 126 | return time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(x)) |
@@ -242,12 +253,12 b' class hgweb:' | |||
|
242 | 253 | if pos + f < count: l.append(("+" + r, pos + f)) |
|
243 | 254 | if pos - f >= 0: l.insert(0, ("-" + r, pos - f)) |
|
244 | 255 | |
|
245 |
yield |
|
|
256 | yield {"rev": 0, "label": "(0)"} | |
|
246 | 257 | |
|
247 | 258 | for label, rev in l: |
|
248 |
yield |
|
|
259 | yield {"label": label, "rev": rev} | |
|
249 | 260 | |
|
250 |
yield |
|
|
261 | yield {"label": "tip", "rev": ""} | |
|
251 | 262 | |
|
252 | 263 | def changelist(**map): |
|
253 | 264 | parity = (start - end) & 1 |
@@ -259,22 +270,21 b' class hgweb:' | |||
|
259 | 270 | hn = hex(n) |
|
260 | 271 | t = float(changes[2].split(' ')[0]) |
|
261 | 272 | |
|
262 |
l.insert(0, |
|
|
263 |
|
|
|
264 |
|
|
|
265 | author = changes[1], | |
|
266 | parent = self.parents("changelogparent", | |
|
273 | l.insert(0, { | |
|
274 | "parity": parity, | |
|
275 | "author": changes[1], | |
|
276 | "parent": self.parents("changelogparent", | |
|
267 | 277 | cl.parents(n), cl.rev), |
|
268 |
changelogtag |
|
|
269 |
manifest |
|
|
270 |
desc |
|
|
271 |
date |
|
|
272 |
files |
|
|
273 |
rev |
|
|
274 |
node |
|
|
278 | "changelogtag": self.showtag("changelogtag",n), | |
|
279 | "manifest": hex(changes[0]), | |
|
280 | "desc": changes[4], | |
|
281 | "date": t, | |
|
282 | "files": self.listfilediffs(changes[3], n), | |
|
283 | "rev": i, | |
|
284 | "node": hn}) | |
|
275 | 285 | parity = 1 - parity |
|
276 | 286 | |
|
277 |
yield |
|
|
287 | for e in l: yield e | |
|
278 | 288 | |
|
279 | 289 | cl = self.repo.changelog |
|
280 | 290 | mf = cl.read(cl.tip())[0] |
@@ -389,20 +399,19 b' class hgweb:' | |||
|
389 | 399 | cs = cl.read(cl.node(lr)) |
|
390 | 400 | t = float(cs[2].split(' ')[0]) |
|
391 | 401 | |
|
392 |
l.insert(0, |
|
|
393 |
|
|
|
394 |
|
|
|
395 |
|
|
|
396 |
|
|
|
397 |
|
|
|
398 |
|
|
|
399 |
|
|
|
400 | parent = self.parents("filelogparent", | |
|
402 | l.insert(0, {"parity": parity, | |
|
403 | "filenode": hex(n), | |
|
404 | "filerev": i, | |
|
405 | "file": f, | |
|
406 | "node": hex(cn), | |
|
407 | "author": cs[1], | |
|
408 | "date": t, | |
|
409 | "parent": self.parents("filelogparent", | |
|
401 | 410 | fl.parents(n), fl.rev, file=f), |
|
402 |
|
|
|
411 | "desc": cs[4]}) | |
|
403 | 412 | parity = 1 - parity |
|
404 | 413 | |
|
405 |
yield |
|
|
414 | for e in l: yield e | |
|
406 | 415 | |
|
407 | 416 | yield self.t("filelog", |
|
408 | 417 | file = f, |
@@ -422,9 +431,9 b' class hgweb:' | |||
|
422 | 431 | |
|
423 | 432 | def lines(): |
|
424 | 433 | for l, t in enumerate(text.splitlines(1)): |
|
425 |
yield |
|
|
426 |
|
|
|
427 |
|
|
|
434 | yield {"line": t, | |
|
435 | "linenumber": "% 6d" % (l + 1), | |
|
436 | "parity": l & 1} | |
|
428 | 437 | |
|
429 | 438 | yield self.t("filerevision", file = f, |
|
430 | 439 | filenode = node, |
@@ -478,13 +487,12 b' class hgweb:' | |||
|
478 | 487 | parity = 1 - parity |
|
479 | 488 | last = cnode |
|
480 | 489 | |
|
481 |
yield |
|
|
482 | parity = parity, | |
|
483 |
|
|
|
484 |
|
|
|
485 |
|
|
|
486 |
|
|
|
487 | line = l) | |
|
490 | yield {"parity": parity, | |
|
491 | "node": hex(cnode), | |
|
492 | "rev": r, | |
|
493 | "author": name, | |
|
494 | "file": f, | |
|
495 | "line": l} | |
|
488 | 496 | |
|
489 | 497 | yield self.t("fileannotate", |
|
490 | 498 | file = f, |
@@ -528,28 +536,40 b' class hgweb:' | |||
|
528 | 536 | fl.sort() |
|
529 | 537 | for f in fl: |
|
530 | 538 | full, fnode = files[f] |
|
531 | if fnode: | |
|
532 | yield self.t("manifestfileentry", | |
|
533 | file = full, | |
|
534 | manifest = mnode, | |
|
535 |
|
|
|
536 | parity = parity, | |
|
537 |
|
|
|
538 | permissions = mff[full]) | |
|
539 | else: | |
|
540 | yield self.t("manifestdirentry", | |
|
541 | parity = parity, | |
|
542 | path = os.path.join(path, f), | |
|
543 | manifest = mnode, basename = f[:-1]) | |
|
539 | if not fnode: | |
|
540 | continue | |
|
541 | ||
|
542 | yield {"file": full, | |
|
543 | "manifest": mnode, | |
|
544 | "filenode": hex(fnode), | |
|
545 | "parity": parity, | |
|
546 | "basename": f, | |
|
547 | "permissions": mff[full]} | |
|
544 | 548 | parity = 1 - parity |
|
545 | 549 | |
|
550 | def dirlist(**map): | |
|
551 | parity = 0 | |
|
552 | fl = files.keys() | |
|
553 | fl.sort() | |
|
554 | for f in fl: | |
|
555 | full, fnode = files[f] | |
|
556 | if fnode: | |
|
557 | continue | |
|
558 | ||
|
559 | yield {"parity": parity, | |
|
560 | "path": os.path.join(path, f), | |
|
561 | "manifest": mnode, | |
|
562 | "basename": f[:-1]} | |
|
563 | parity = 1 - parity | |
|
564 | ||
|
546 | 565 | yield self.t("manifest", |
|
547 | 566 | manifest = mnode, |
|
548 | 567 | rev = rev, |
|
549 | 568 | node = hex(node), |
|
550 | 569 | path = path, |
|
551 | 570 | up = up(path), |
|
552 |
entries = filelist |
|
|
571 | fentries = filelist, | |
|
572 | dentries = dirlist) | |
|
553 | 573 | |
|
554 | 574 | def tags(self): |
|
555 | 575 | cl = self.repo.changelog |
@@ -561,10 +581,9 b' class hgweb:' | |||
|
561 | 581 | def entries(**map): |
|
562 | 582 | parity = 0 |
|
563 | 583 | for k,n in i: |
|
564 |
yield |
|
|
565 |
|
|
|
566 |
|
|
|
567 | node = hex(n)) | |
|
584 | yield {"parity": parity, | |
|
585 | "tag": k, | |
|
586 | "node": hex(n)} | |
|
568 | 587 | parity = 1 - parity |
|
569 | 588 | |
|
570 | 589 | yield self.t("tags", |
@@ -18,18 +18,18 b'' | |||
|
18 | 18 | <label for="search1">search:</label> |
|
19 | 19 | <input type="hidden" name="cmd" value="changelog"> |
|
20 | 20 | <input name="rev" id="search1" type="text" size="30"> |
|
21 | navigate: <small>#changenav#</small> | |
|
21 | navigate: <small>#changenav%naventry#</small> | |
|
22 | 22 | </p> |
|
23 | 23 | </form> |
|
24 | 24 | |
|
25 | #entries# | |
|
25 | #entries%changelogentry# | |
|
26 | 26 | |
|
27 | 27 | <form action="#"> |
|
28 | 28 | <p> |
|
29 | 29 | <label for="search2">search:</label> |
|
30 | 30 | <input type="hidden" name="cmd" value="changelog"> |
|
31 | 31 | <input name="rev" id="search2" type="text" size="30"> |
|
32 | navigate: <small>#changenav#</small> | |
|
32 | navigate: <small>#changenav%naventry#</small> | |
|
33 | 33 | </p> |
|
34 | 34 | </form> |
|
35 | 35 |
@@ -36,7 +36,7 b'' | |||
|
36 | 36 | <br/> |
|
37 | 37 | |
|
38 | 38 | <table cellspacing="0" cellpadding="0"> |
|
39 | #annotate# | |
|
39 | #annotate%annotateline# | |
|
40 | 40 | </table> |
|
41 | 41 | |
|
42 | 42 | #footer# |
@@ -16,6 +16,6 b'' | |||
|
16 | 16 | |
|
17 | 17 | <h2>#file# revision history</h2> |
|
18 | 18 | |
|
19 | #entries# | |
|
19 | #entries%filelogentry# | |
|
20 | 20 | |
|
21 | 21 | #footer# |
@@ -35,7 +35,7 b'' | |||
|
35 | 35 | </table> |
|
36 | 36 | |
|
37 | 37 | <pre> |
|
38 | #text# | |
|
38 | #text%fileline# | |
|
39 | 39 | </pre> |
|
40 | 40 | |
|
41 | 41 | #footer# |
General Comments 0
You need to be logged in to leave comments.
Login now