~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

  • Committer: Michael Hudson
  • Date: 2008-08-16 06:34:03 UTC
  • Revision ID: michael.hudson@canonical.com-20080816063403-2lvu1e79mpv3ymg5
make the tab capitalization consistent, see bug #252867

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
# along with this program; if not, write to the Free Software
14
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
15
#
16
 
import cgi
17
16
import os
18
17
from loggerhead.zptsupport import zpt
19
18
 
20
 
 
21
19
templatefunctions = {}
22
 
 
23
 
 
24
20
def templatefunc(func):
25
21
    templatefunctions[func.__name__] = func
26
22
    return func
27
23
 
28
24
 
29
25
_base = os.path.dirname(__file__)
30
 
 
31
 
 
32
26
def _pt(name):
33
27
    return zpt(os.path.join(_base, 'templates', name + '.pt'))
34
28
 
35
29
 
36
30
templatefunctions['macros'] = _pt('macros').macros
37
 
templatefunctions['breadcrumbs'] = _pt('breadcrumbs').macros
38
 
 
39
31
 
40
32
@templatefunc
41
 
def file_change_summary(url, entry, file_changes, style='normal', currently_showing=None):
42
 
    if style == 'fragment':
43
 
        def file_link(filename):
44
 
            if currently_showing and filename == currently_showing:
45
 
                return '<b><a href="#%s">%s</a></b>' % (
46
 
                    cgi.escape(filename), cgi.escape(filename))
47
 
            else:
48
 
                return revision_link(
49
 
                    url, entry.revno, filename, '#' + filename)
50
 
    else:
51
 
        def file_link(filename):
52
 
            return '<a href="%s%s" title="View changes to %s in revision %s">%s</a>'%(
53
 
                url(['/revision', entry.revno]), '#' + filename, cgi.escape(filename),
54
 
                cgi.escape(entry.revno), cgi.escape(filename))
 
33
def file_change_summary(url, entry, modified_file_link):
55
34
    return _pt('revisionfilechanges').expand(
56
 
        entry=entry, file_changes=file_changes, file_link=file_link, **templatefunctions)
57
 
 
 
35
        url=url, entry=entry, modified_file_link=modified_file_link,
 
36
        **templatefunctions)
58
37
 
59
38
@templatefunc
60
 
def revisioninfo(url, branch, entry, file_changes=None, currently_showing=None, merged_in=None):
 
39
def revisioninfo(url, branch, entry, modified_file_link=None):
61
40
    from loggerhead import util
62
41
    return _pt('revisioninfo').expand(
63
42
        url=url, change=entry, branch=branch, util=util,
64
 
        file_changes=file_changes, currently_showing=currently_showing,
65
 
        merged_in=merged_in, **templatefunctions)
66
 
 
67
 
 
68
 
@templatefunc
69
 
def branchinfo(branch):
70
 
    if branch.served_url is not None:
71
 
        return _pt('branchinfo').expand(branch=branch, **templatefunctions)
72
 
    else:
73
 
        return ''
74
 
 
 
43
        modified_file_link=modified_file_link,
 
44
        **templatefunctions)
75
45
 
76
46
@templatefunc
77
47
def collapse_button(group, name, branch, normal='block'):
79
49
        group=group, name=name, normal=normal, branch=branch,
80
50
        **templatefunctions)
81
51
 
82
 
 
83
52
@templatefunc
84
53
def collapse_all_button(group, branch, normal='block'):
85
54
    return _pt('collapse-all-button').expand(
86
55
        group=group, normal=normal, branch=branch,
87
56
        **templatefunctions)
88
57
 
89
 
 
90
58
@templatefunc
91
59
def revno_with_nick(entry):
92
60
    if entry.branch_nick:
95
63
        extra = ''
96
64
    return '(%s%s)'%(entry.revno, extra)
97
65
 
 
66
@templatefunc
 
67
def modified_file_link_rev(url, entry, item):
 
68
    return _pt('modified-file-link-rev').expand(
 
69
        url=url, entry=entry, item=item,
 
70
        **templatefunctions)
 
71
 
 
72
@templatefunc
 
73
def modified_file_link_log(url, entry, item):
 
74
    return _pt('modified-file-link-log').expand(
 
75
        url=url, entry=entry, item=item,
 
76
        **templatefunctions)
98
77
 
99
78
@templatefunc
100
79
def search_box(branch, navigation):
101
80
    return _pt('search-box').expand(branch=branch, navigation=navigation,
102
81
        **templatefunctions)
103
82
 
104
 
 
105
83
@templatefunc
106
84
def feed_link(branch, url):
107
85
    return _pt('feed-link').expand(branch=branch, url=url, **templatefunctions)
108
86
 
109
 
 
110
87
@templatefunc
111
88
def menu(branch, url, fileview_active=False):
112
89
    return _pt('menu').expand(branch=branch, url=url,
113
90
        fileview_active=fileview_active, **templatefunctions)
114
 
 
115
 
 
116
 
@templatefunc
117
 
def annotate_link(url, revno, path):
118
 
    return '<a href="%s" title="Annotate %s">%s</a>'%(
119
 
        url(['/annotate', revno, path]), cgi.escape(path), cgi.escape(path))
120
 
 
121
 
@templatefunc
122
 
def revision_link(url, revno, path, frag=''):
123
 
    return '<a href="%s%s" title="View changes to %s in revision %s">%s</a>'%(
124
 
        url(['/revision', revno, path]), frag, cgi.escape(path),
125
 
        cgi.escape(revno), cgi.escape(path))