~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

  • Committer: Robey Pointer
  • Date: 2007-03-26 06:08:50 UTC
  • Revision ID: robey@lag.net-20070326060850-69b3yu2i6udttzjq
include more stuff in the manifest

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
# This program is free software; you can redistribute it and/or modify
3
 
# it under the terms of the GNU General Public License as published by
4
 
# the Free Software Foundation; either version 2 of the License, or
5
 
# (at your option) any later version.
6
 
#
7
 
# This program is distributed in the hope that it will be useful,
8
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
# GNU General Public License for more details.
11
 
#
12
 
# You should have received a copy of the GNU General Public License
13
 
# along with this program; if not, write to the Free Software
14
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
 
#
16
 
import os
17
 
from loggerhead.zptsupport import zpt
18
 
 
19
 
templatefunctions = {}
20
 
def templatefunc(func):
21
 
    templatefunctions[func.__name__] = func
22
 
    return func
23
 
 
24
 
 
25
 
_base = os.path.dirname(__file__)
26
 
def _pt(name):
27
 
    return zpt(os.path.join(_base, 'templates', name + '.pt'))
28
 
 
29
 
 
30
 
templatefunctions['macros'] = _pt('macros').macros
31
 
templatefunctions['breadcrumbs'] = _pt('breadcrumbs').macros
32
 
 
33
 
@templatefunc
34
 
def file_change_summary(url, entry, modified_file_link):
35
 
    return _pt('revisionfilechanges').expand(
36
 
        url=url, entry=entry, modified_file_link=modified_file_link,
37
 
        **templatefunctions)
38
 
 
39
 
@templatefunc
40
 
def revisioninfo(url, branch, entry, modified_file_link=None):
41
 
    from loggerhead import util
42
 
    return _pt('revisioninfo').expand(
43
 
        url=url, change=entry, branch=branch, util=util,
44
 
        modified_file_link=modified_file_link,
45
 
        **templatefunctions)
46
 
 
47
 
@templatefunc
48
 
def collapse_button(group, name, branch, normal='block'):
49
 
    return _pt('collapse-button').expand(
50
 
        group=group, name=name, normal=normal, branch=branch,
51
 
        **templatefunctions)
52
 
 
53
 
@templatefunc
54
 
def collapse_all_button(group, branch, normal='block'):
55
 
    return _pt('collapse-all-button').expand(
56
 
        group=group, normal=normal, branch=branch,
57
 
        **templatefunctions)
58
 
 
59
 
@templatefunc
60
 
def revno_with_nick(entry):
61
 
    if entry.branch_nick:
62
 
        extra = ' ' + entry.branch_nick
63
 
    else:
64
 
        extra = ''
65
 
    return '(%s%s)'%(entry.revno, extra)
66
 
 
67
 
@templatefunc
68
 
def modified_file_link_rev(url, entry, item):
69
 
    return _pt('modified-file-link-rev').expand(
70
 
        url=url, entry=entry, item=item,
71
 
        **templatefunctions)
72
 
 
73
 
@templatefunc
74
 
def modified_file_link_log(url, entry, item):
75
 
    return _pt('modified-file-link-log').expand(
76
 
        url=url, entry=entry, item=item,
77
 
        **templatefunctions)
78
 
 
79
 
@templatefunc
80
 
def search_box(branch, navigation):
81
 
    return _pt('search-box').expand(branch=branch, navigation=navigation,
82
 
        **templatefunctions)
83
 
 
84
 
@templatefunc
85
 
def feed_link(branch, url):
86
 
    return _pt('feed-link').expand(branch=branch, url=url, **templatefunctions)
87
 
 
88
 
@templatefunc
89
 
def menu(branch, url, fileview_active=False):
90
 
    return _pt('menu').expand(branch=branch, url=url,
91
 
        fileview_active=fileview_active, **templatefunctions)