OLD | NEW |
---|---|
1 # This file is part of Buildbot. Buildbot is free software: you can | 1 # This file is part of Buildbot. Buildbot is free software: you can |
2 # redistribute it and/or modify it under the terms of the GNU General Public | 2 # redistribute it and/or modify it under the terms of the GNU General Public |
3 # License as published by the Free Software Foundation, version 2. | 3 # License as published by the Free Software Foundation, version 2. |
4 # | 4 # |
5 # This program is distributed in the hope that it will be useful, but WITHOUT | 5 # This program is distributed in the hope that it will be useful, but WITHOUT |
6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | 6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | 7 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
8 # details. | 8 # details. |
9 # | 9 # |
10 # You should have received a copy of the GNU General Public License along with | 10 # You should have received a copy of the GNU General Public License along with |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 extensions=['jinja2.ext.i18n'], | 491 extensions=['jinja2.ext.i18n'], |
492 trim_blocks=True, | 492 trim_blocks=True, |
493 undefined=AlmostStrictUndefined) | 493 undefined=AlmostStrictUndefined) |
494 | 494 |
495 env.install_null_translations() # needed until we have a proper i18n backend | 495 env.install_null_translations() # needed until we have a proper i18n backend |
496 | 496 |
497 env.filters.update(dict( | 497 env.filters.update(dict( |
498 urlencode = urllib.quote, | 498 urlencode = urllib.quote, |
499 email = emailfilter, | 499 email = emailfilter, |
500 user = userfilter, | 500 user = userfilter, |
501 cq = cqfilter, | |
M-A Ruel
2012/01/26 18:53:47
An option is to monkey patch it in scripts/master/
sadrul
2012/01/26 20:24:41
Interesting idea! I have made that change.
| |
501 shortrev = shortrevfilter(revlink, env), | 502 shortrev = shortrevfilter(revlink, env), |
502 revlink = revlinkfilter(revlink, env), | 503 revlink = revlinkfilter(revlink, env), |
503 changecomment = changelinkfilter(changecommentlink), | 504 changecomment = changelinkfilter(changecommentlink), |
504 repolink = dictlinkfilter(repositories), | 505 repolink = dictlinkfilter(repositories), |
505 projectlink = dictlinkfilter(projects) | 506 projectlink = dictlinkfilter(projects) |
506 )) | 507 )) |
507 | 508 |
508 return env | 509 return env |
509 | 510 |
510 def emailfilter(value): | 511 def emailfilter(value): |
(...skipping 15 matching lines...) Expand all Loading... | |
526 it on mouse-over or similar etc | 527 it on mouse-over or similar etc |
527 ''' | 528 ''' |
528 r = re.compile('(.*) +<(.*)>') | 529 r = re.compile('(.*) +<(.*)>') |
529 m = r.search(value) | 530 m = r.search(value) |
530 if m: | 531 if m: |
531 user = jinja2.escape(m.group(1)) | 532 user = jinja2.escape(m.group(1)) |
532 email = emailfilter(m.group(2)) | 533 email = emailfilter(m.group(2)) |
533 return jinja2.Markup('<div class="user">%s<div class="email">%s</div></d iv>' % (user, email)) | 534 return jinja2.Markup('<div class="user">%s<div class="email">%s</div></d iv>' % (user, email)) |
534 else: | 535 else: |
535 return emailfilter(value) # filter for emails here for safety | 536 return emailfilter(value) # filter for emails here for safety |
536 | 537 |
538 def cqfilter(value): | |
539 ''' Adds a helpful '(CQ)' to make it visibly obvious which commits were made | |
540 through the commit queue. | |
541 ''' | |
542 if value: | |
sadrul
2012/01/26 17:57:49
I am assuming |value| here will continue to be a b
M-A Ruel
2012/01/26 18:53:47
:/ No idea.
| |
543 return " (CQ)" | |
544 return "" | |
545 | |
537 def _revlinkcfg(replace, templates): | 546 def _revlinkcfg(replace, templates): |
538 '''Helper function that returns suitable macros and functions | 547 '''Helper function that returns suitable macros and functions |
539 for building revision links depending on replacement mechanism | 548 for building revision links depending on replacement mechanism |
540 ''' | 549 ''' |
541 | 550 |
542 assert not replace or callable(replace) or isinstance(replace, dict) or \ | 551 assert not replace or callable(replace) or isinstance(replace, dict) or \ |
543 isinstance(replace, str) or isinstance(replace, unicode) | 552 isinstance(replace, str) or isinstance(replace, unicode) |
544 | 553 |
545 if not replace: | 554 if not replace: |
546 return lambda rev, repo: None | 555 return lambda rev, repo: None |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
761 return filter | 770 return filter |
762 | 771 |
763 class AlmostStrictUndefined(jinja2.StrictUndefined): | 772 class AlmostStrictUndefined(jinja2.StrictUndefined): |
764 ''' An undefined that allows boolean testing but | 773 ''' An undefined that allows boolean testing but |
765 fails properly on every other use. | 774 fails properly on every other use. |
766 | 775 |
767 Much better than the default Undefined, but not | 776 Much better than the default Undefined, but not |
768 fully as strict as StrictUndefined ''' | 777 fully as strict as StrictUndefined ''' |
769 def __nonzero__(self): | 778 def __nonzero__(self): |
770 return False | 779 return False |
OLD | NEW |