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.
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.
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
18
from loggerhead.zptsupport import zpt
21
templatefunctions = {}
24
def templatefunc(func):
25
templatefunctions[func.__name__] = func
29
_base = os.path.dirname(__file__)
33
return zpt(os.path.join(_base, 'templates', name + '.pt'))
36
templatefunctions['macros'] = _pt('macros').macros
37
templatefunctions['breadcrumbs'] = _pt('breadcrumbs').macros
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))
49
url, entry.revno, filename, '#' + filename)
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))
55
return _pt('revisionfilechanges').expand(
56
entry=entry, file_changes=file_changes, file_link=file_link, **templatefunctions)
60
def revisioninfo(url, branch, entry, file_changes=None, currently_showing=None):
61
from loggerhead import util
62
return _pt('revisioninfo').expand(
63
url=url, change=entry, branch=branch, util=util,
64
file_changes=file_changes, currently_showing=currently_showing,
69
def branchinfo(branch):
70
if branch.served_url is not None:
71
return _pt('branchinfo').expand(branch=branch, **templatefunctions)
77
def collapse_button(group, name, branch, normal='block'):
78
return _pt('collapse-button').expand(
79
group=group, name=name, normal=normal, branch=branch,
84
def collapse_all_button(group, branch, normal='block'):
85
return _pt('collapse-all-button').expand(
86
group=group, normal=normal, branch=branch,
91
def revno_with_nick(entry):
93
extra = ' ' + entry.branch_nick
96
return '(%s%s)'%(entry.revno, extra)
100
def search_box(branch, navigation):
101
return _pt('search-box').expand(branch=branch, navigation=navigation,
106
def feed_link(branch, url):
107
return _pt('feed-link').expand(branch=branch, url=url, **templatefunctions)
111
def menu(branch, url, fileview_active=False):
112
return _pt('menu').expand(branch=branch, url=url,
113
fileview_active=fileview_active, **templatefunctions)
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))
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))