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
3
from turbosimpletal.zptsupport import zpt
25
from loggerhead.zptsupport import zpt
5
28
templatefunctions = {}
6
31
def templatefunc(func):
7
32
templatefunctions[func.__name__] = func
11
36
_base = os.path.dirname(__file__)
13
40
return zpt(os.path.join(_base, 'templates', name + '.pt'))
16
43
templatefunctions['macros'] = _pt('macros').macros
44
templatefunctions['breadcrumbs'] = _pt('breadcrumbs').macros
19
def file_change_summary(url, entry, modified_file_link):
48
def file_change_summary(url, entry, file_changes, style='normal', currently_showing=None):
49
if style == 'fragment':
50
def file_link(filename):
51
if currently_showing and filename == currently_showing:
52
return '<b><a href="#%s">%s</a></b>' % (
53
cgi.escape(filename), cgi.escape(filename))
56
url, entry.revno, filename, '#' + filename)
58
def file_link(filename):
59
return '<a href="%s%s" title="View changes to %s in revision %s">%s</a>' % (
60
url(['/revision', entry.revno]), '#' + filename, cgi.escape(filename),
61
cgi.escape(entry.revno), cgi.escape(filename))
20
62
return _pt('revisionfilechanges').expand(
21
url=url, entry=entry, modified_file_link=modified_file_link,
63
entry=entry, file_changes=file_changes, file_link=file_link, **templatefunctions)
25
def revisioninfo(url, branch, entry, modified_file_link=None):
67
def revisioninfo(url, branch, entry, file_changes=None, currently_showing=None, merged_in=None):
26
68
from loggerhead import util
27
69
return _pt('revisioninfo').expand(
28
70
url=url, change=entry, branch=branch, util=util,
29
modified_file_link=modified_file_link,
33
def collapse_button(group, name, normal='block'):
71
file_changes=file_changes, currently_showing=currently_showing,
72
merged_in=merged_in, **templatefunctions)
76
def branchinfo(branch):
77
if branch.served_url is not None:
78
return _pt('branchinfo').expand(branch=branch, **templatefunctions)
84
def collapse_button(group, name, branch, normal='block'):
34
85
return _pt('collapse-button').expand(
35
group=group, name=name, normal=normal, tg=turbogears,
86
group=group, name=name, normal=normal, branch=branch,
36
87
**templatefunctions)
39
def collapse_all_button(group, normal='block'):
91
def collapse_all_button(group, branch, normal='block'):
40
92
return _pt('collapse-all-button').expand(
41
group=group, normal=normal, tg=turbogears,
93
group=group, normal=normal, branch=branch,
42
94
**templatefunctions)
45
98
def revno_with_nick(entry):
46
99
if entry.branch_nick:
47
100
extra = ' ' + entry.branch_nick
50
return '(%s%s)'%(entry.revno, extra)
53
def modified_file_link_rev(url, entry, item):
54
return _pt('modified-file-link-rev').expand(
55
url=url, entry=entry, item=item,
59
def modified_file_link_log(url, entry, item):
60
return _pt('modified-file-link-log').expand(
61
url=url, entry=entry, item=item,
103
return '(%s%s)' % (entry.revno, extra)
107
def search_box(branch, navigation):
108
return _pt('search-box').expand(branch=branch, navigation=navigation,
113
def feed_link(branch, url):
114
return _pt('feed-link').expand(branch=branch, url=url, **templatefunctions)
118
def menu(branch, url, fileview_active=False):
119
return _pt('menu').expand(branch=branch, url=url,
120
fileview_active=fileview_active, **templatefunctions)
124
def annotate_link(url, revno, path):
125
return '<a href="%s" title="Annotate %s">%s</a>' % (
126
url(['/annotate', revno, path]), cgi.escape(path), cgi.escape(path))
129
def revision_link(url, revno, path, frag=''):
130
return '<a href="%s%s" title="View changes to %s in revision %s">%s</a>' % (
131
url(['/revision', revno, path]), frag, cgi.escape(path),
132
cgi.escape(revno), cgi.escape(path))
136
def loggerhead_version():
137
return loggerhead.__version__
139
_cached_generator_string = None
142
def generator_string():
143
global _cached_generator_string
144
if _cached_generator_string is None:
147
# TODO: Errors -- e.g. from a missing/invalid __version__ attribute, or
148
# ValueError accessing Distribution.version -- should be non-fatal.
150
versions.append(('Loggerhead', loggerhead.__version__))
153
python_version = bzrlib._format_version_tuple(sys.version_info)
154
versions.append(('Python', python_version))
156
versions.append(('Bazaar', bzrlib.__version__))
158
Paste = pkg_resources.get_distribution('Paste')
159
versions.append(('Paste', Paste.version))
162
PasteDeploy = pkg_resources.get_distribution('PasteDeploy')
163
except pkg_resources.DistributionNotFound:
166
versions.append(('PasteDeploy', PasteDeploy.version))
169
versions.append(('SimpleTAL', simpletal.__version__))
176
versions.append(('Pygments', pygments.__version__))
179
from bzrlib.plugins import search
183
bzr_search_version = bzrlib._format_version_tuple(
185
versions.append(('bzr-search', bzr_search_version))
187
# TODO: On old Python versions, elementtree may be used.
194
versions.append(('simplejson', simplejson.__version__))
197
Dozer = pkg_resources.get_distribution('Dozer')
198
except pkg_resources.DistributionNotFound:
201
versions.append(('Dozer', Dozer.version))
203
version_strings = ("%s/%s" % t for t in versions)
204
_cached_generator_string = ' '.join(version_strings)
205
return _cached_generator_string