~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

  • Committer: Michael Hudson
  • Date: 2009-02-10 02:40:09 UTC
  • mto: This revision was merged to the branch mainline in revision 267.
  • Revision ID: michael.hudson@canonical.com-20090210024009-lzcec5t6f8vbze1r
fix test!

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
import os
17
17
from loggerhead.zptsupport import zpt
18
18
 
 
19
 
19
20
templatefunctions = {}
 
21
 
 
22
 
20
23
def templatefunc(func):
21
24
    templatefunctions[func.__name__] = func
22
25
    return func
23
26
 
24
27
 
25
28
_base = os.path.dirname(__file__)
 
29
 
 
30
 
26
31
def _pt(name):
27
32
    return zpt(os.path.join(_base, 'templates', name + '.pt'))
28
33
 
29
34
 
30
35
templatefunctions['macros'] = _pt('macros').macros
 
36
templatefunctions['breadcrumbs'] = _pt('breadcrumbs').macros
 
37
 
31
38
 
32
39
@templatefunc
33
40
def file_change_summary(url, entry, modified_file_link):
35
42
        url=url, entry=entry, modified_file_link=modified_file_link,
36
43
        **templatefunctions)
37
44
 
 
45
 
38
46
@templatefunc
39
47
def revisioninfo(url, branch, entry, modified_file_link=None):
40
48
    from loggerhead import util
43
51
        modified_file_link=modified_file_link,
44
52
        **templatefunctions)
45
53
 
 
54
 
 
55
@templatefunc
 
56
def branchinfo(branch):
 
57
    return _pt('branchinfo').expand(branch=branch, **templatefunctions)
 
58
 
 
59
 
46
60
@templatefunc
47
61
def collapse_button(group, name, branch, normal='block'):
48
62
    return _pt('collapse-button').expand(
49
63
        group=group, name=name, normal=normal, branch=branch,
50
64
        **templatefunctions)
51
65
 
 
66
 
52
67
@templatefunc
53
68
def collapse_all_button(group, branch, normal='block'):
54
69
    return _pt('collapse-all-button').expand(
55
70
        group=group, normal=normal, branch=branch,
56
71
        **templatefunctions)
57
72
 
 
73
 
58
74
@templatefunc
59
75
def revno_with_nick(entry):
60
76
    if entry.branch_nick:
63
79
        extra = ''
64
80
    return '(%s%s)'%(entry.revno, extra)
65
81
 
 
82
 
66
83
@templatefunc
67
84
def modified_file_link_rev(url, entry, item):
68
85
    return _pt('modified-file-link-rev').expand(
69
86
        url=url, entry=entry, item=item,
70
87
        **templatefunctions)
71
88
 
 
89
 
72
90
@templatefunc
73
91
def modified_file_link_log(url, entry, item):
74
92
    return _pt('modified-file-link-log').expand(
75
93
        url=url, entry=entry, item=item,
76
94
        **templatefunctions)
77
95
 
 
96
 
78
97
@templatefunc
79
98
def search_box(branch, navigation):
80
99
    return _pt('search-box').expand(branch=branch, navigation=navigation,
81
100
        **templatefunctions)
82
101
 
 
102
 
83
103
@templatefunc
84
104
def feed_link(branch, url):
85
105
    return _pt('feed-link').expand(branch=branch, url=url, **templatefunctions)
86
106
 
 
107
 
87
108
@templatefunc
88
109
def menu(branch, url, fileview_active=False):
89
110
    return _pt('menu').expand(branch=branch, url=url,