~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2008-03-04 06:16:12 UTC
  • mfrom: (147.1.2 release-final-prep)
  • Revision ID: launchpad@pqm.canonical.com-20080304061612-1q6l3vo604dkk8vg
[r=jamesh] final adjustments to the README and NEWS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
2
 
from turbosimpletal.zptsupport import zpt
3
 
 
4
 
templatefunctions = {}
5
 
def templatefunc(func):
6
 
    templatefunctions[func.__name__] = func
7
 
    return func
8
 
 
9
 
 
10
 
_base = os.path.dirname(__file__)
11
 
def _pt(name):
12
 
    return zpt(os.path.join(_base, 'templates', name + '.pt'))
13
 
 
14
 
 
15
 
templatefunctions['macros'] = _pt('macros').macros
16
 
 
17
 
@templatefunc
18
 
def file_change_summary(url, entry, modified_file_link):
19
 
    return _pt('revisionfilechanges').expand(
20
 
        url=url, entry=entry, modified_file_link=modified_file_link,
21
 
        **templatefunctions)
22
 
 
23
 
@templatefunc
24
 
def revisioninfo(url, branch, entry, modified_file_link=None):
25
 
    from loggerhead import util
26
 
    return _pt('revisioninfo').expand(
27
 
        url=url, change=entry, branch=branch, util=util,
28
 
        modified_file_link=modified_file_link,
29
 
        **templatefunctions)
30
 
 
31
 
@templatefunc
32
 
def collapse_button(group, name, branch, normal='block'):
33
 
    return _pt('collapse-button').expand(
34
 
        group=group, name=name, normal=normal, branch=branch,
35
 
        **templatefunctions)
36
 
 
37
 
@templatefunc
38
 
def collapse_all_button(group, branch, normal='block'):
39
 
    return _pt('collapse-all-button').expand(
40
 
        group=group, normal=normal, branch=branch,
41
 
        **templatefunctions)
42
 
 
43
 
@templatefunc
44
 
def revno_with_nick(entry):
45
 
    if entry.branch_nick:
46
 
        extra = ' ' + entry.branch_nick
47
 
    else:
48
 
        extra = ''
49
 
    return '(%s%s)'%(entry.revno, extra)
50
 
 
51
 
@templatefunc
52
 
def modified_file_link_rev(url, entry, item):
53
 
    return _pt('modified-file-link-rev').expand(
54
 
        url=url, entry=entry, item=item,
55
 
        **templatefunctions)
56
 
 
57
 
@templatefunc
58
 
def modified_file_link_log(url, entry, item):
59
 
    return _pt('modified-file-link-log').expand(
60
 
        url=url, entry=entry, item=item,
61
 
        **templatefunctions)
62
 
 
63
 
class tg:
64
 
    @staticmethod
65
 
    def url(what):
66
 
        return what
67
 
 
68
 
templatefunctions['tg'] =  tg