~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

  • Committer: Michael Hudson
  • Date: 2007-12-11 15:32:55 UTC
  • mto: This revision was merged to the branch mainline in revision 143.
  • Revision ID: michael.hudson@canonical.com-20071211153255-2fixc573u9vnpv2g
stab turbogears in the tortuously found correct place

Show diffs side-by-side

added added

removed removed

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