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
25
17
from loggerhead.zptsupport import zpt
28
19
templatefunctions = {}
31
20
def templatefunc(func):
32
21
templatefunctions[func.__name__] = func
36
25
_base = os.path.dirname(__file__)
40
27
return zpt(os.path.join(_base, 'templates', name + '.pt'))
43
30
templatefunctions['macros'] = _pt('macros').macros
44
templatefunctions['breadcrumbs'] = _pt('breadcrumbs').macros
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))
33
def file_change_summary(url, entry, modified_file_link):
62
34
return _pt('revisionfilechanges').expand(
63
entry=entry, file_changes=file_changes, file_link=file_link, **templatefunctions)
35
url=url, entry=entry, modified_file_link=modified_file_link,
67
def revisioninfo(url, branch, entry, file_changes=None, currently_showing=None, merged_in=None):
39
def revisioninfo(url, branch, entry, modified_file_link=None):
68
40
from loggerhead import util
69
41
return _pt('revisioninfo').expand(
70
42
url=url, change=entry, branch=branch, util=util,
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)
43
modified_file_link=modified_file_link,
84
47
def collapse_button(group, name, branch, normal='block'):
86
49
group=group, name=name, normal=normal, branch=branch,
87
50
**templatefunctions)
91
53
def collapse_all_button(group, branch, normal='block'):
92
54
return _pt('collapse-all-button').expand(
93
55
group=group, normal=normal, branch=branch,
94
56
**templatefunctions)
98
59
def revno_with_nick(entry):
99
60
if entry.branch_nick:
100
61
extra = ' ' + entry.branch_nick
103
return '(%s%s)' % (entry.revno, extra)
64
return '(%s%s)'%(entry.revno, extra)
67
def modified_file_link_rev(url, entry, item):
68
return _pt('modified-file-link-rev').expand(
69
url=url, entry=entry, item=item,
73
def modified_file_link_log(url, entry, item):
74
return _pt('modified-file-link-log').expand(
75
url=url, entry=entry, item=item,
107
79
def search_box(branch, navigation):
108
80
return _pt('search-box').expand(branch=branch, navigation=navigation,
109
81
**templatefunctions)
113
84
def feed_link(branch, url):
114
85
return _pt('feed-link').expand(branch=branch, url=url, **templatefunctions)
118
88
def menu(branch, url, fileview_active=False):
119
89
return _pt('menu').expand(branch=branch, url=url,
120
90
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