/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk
183.2.1 by John Arbash Meinel
Add Copyright information to most files.
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
#
128.6.36 by Michael Hudson
move the templatefunctions to a better location
16
import os
159.2.30 by Michael Hudson
trim down turbosimpletal and move it inside loggerhead package.
17
from loggerhead.zptsupport import zpt
128.6.36 by Michael Hudson
move the templatefunctions to a better location
18
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
19
128.6.36 by Michael Hudson
move the templatefunctions to a better location
20
templatefunctions = {}
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
21
22
128.6.36 by Michael Hudson
move the templatefunctions to a better location
23
def templatefunc(func):
24
    templatefunctions[func.__name__] = func
25
    return func
26
128.6.37 by Michael Hudson
convert annotate.pt to using metal in preparation for getting rid of the bizarro "here" hack
27
28
_base = os.path.dirname(__file__)
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
29
30
128.6.37 by Michael Hudson
convert annotate.pt to using metal in preparation for getting rid of the bizarro "here" hack
31
def _pt(name):
32
    return zpt(os.path.join(_base, 'templates', name + '.pt'))
33
34
128.6.38 by Michael Hudson
browse.pt -> metal and some fixes
35
templatefunctions['macros'] = _pt('macros').macros
201.2.9 by Russ Brown
Moved breadcrumb code and markup out into shared locations
36
templatefunctions['breadcrumbs'] = _pt('breadcrumbs').macros
128.6.37 by Michael Hudson
convert annotate.pt to using metal in preparation for getting rid of the bizarro "here" hack
37
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
38
128.6.36 by Michael Hudson
move the templatefunctions to a better location
39
@templatefunc
40
def file_change_summary(url, entry, modified_file_link):
128.6.59 by Michael Hudson
mostly more unicode fixes
41
    return _pt('revisionfilechanges').expand(
128.6.36 by Michael Hudson
move the templatefunctions to a better location
42
        url=url, entry=entry, modified_file_link=modified_file_link,
43
        **templatefunctions)
44
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
45
128.6.36 by Michael Hudson
move the templatefunctions to a better location
46
@templatefunc
128.8.7 by Martin Albisetti
* Removed passing revid to revision info and using change instead
47
def revisioninfo(url, branch, entry, modified_file_link=None):
128.6.36 by Michael Hudson
move the templatefunctions to a better location
48
    from loggerhead import util
128.6.59 by Michael Hudson
mostly more unicode fixes
49
    return _pt('revisioninfo').expand(
128.6.36 by Michael Hudson
move the templatefunctions to a better location
50
        url=url, change=entry, branch=branch, util=util,
128.8.7 by Martin Albisetti
* Removed passing revid to revision info and using change instead
51
        modified_file_link=modified_file_link,
128.6.36 by Michael Hudson
move the templatefunctions to a better location
52
        **templatefunctions)
53
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
54
128.6.36 by Michael Hudson
move the templatefunctions to a better location
55
@templatefunc
159.2.11 by Michael Hudson
hacking towards server from urls based on file paths.
56
def collapse_button(group, name, branch, normal='block'):
128.6.59 by Michael Hudson
mostly more unicode fixes
57
    return _pt('collapse-button').expand(
159.2.11 by Michael Hudson
hacking towards server from urls based on file paths.
58
        group=group, name=name, normal=normal, branch=branch,
128.6.36 by Michael Hudson
move the templatefunctions to a better location
59
        **templatefunctions)
60
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
61
128.6.36 by Michael Hudson
move the templatefunctions to a better location
62
@templatefunc
159.2.11 by Michael Hudson
hacking towards server from urls based on file paths.
63
def collapse_all_button(group, branch, normal='block'):
128.6.59 by Michael Hudson
mostly more unicode fixes
64
    return _pt('collapse-all-button').expand(
159.2.11 by Michael Hudson
hacking towards server from urls based on file paths.
65
        group=group, normal=normal, branch=branch,
128.6.36 by Michael Hudson
move the templatefunctions to a better location
66
        **templatefunctions)
67
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
68
128.6.36 by Michael Hudson
move the templatefunctions to a better location
69
@templatefunc
70
def revno_with_nick(entry):
71
    if entry.branch_nick:
72
        extra = ' ' + entry.branch_nick
73
    else:
74
        extra = ''
75
    return '(%s%s)'%(entry.revno, extra)
76
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
77
128.6.36 by Michael Hudson
move the templatefunctions to a better location
78
@templatefunc
79
def modified_file_link_rev(url, entry, item):
128.6.59 by Michael Hudson
mostly more unicode fixes
80
    return _pt('modified-file-link-rev').expand(
128.6.36 by Michael Hudson
move the templatefunctions to a better location
81
        url=url, entry=entry, item=item,
82
        **templatefunctions)
83
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
84
128.6.36 by Michael Hudson
move the templatefunctions to a better location
85
@templatefunc
86
def modified_file_link_log(url, entry, item):
128.6.59 by Michael Hudson
mostly more unicode fixes
87
    return _pt('modified-file-link-log').expand(
128.6.36 by Michael Hudson
move the templatefunctions to a better location
88
        url=url, entry=entry, item=item,
89
        **templatefunctions)
207.1.1 by Paul Hummer
Added search_box
90
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
91
207.1.1 by Paul Hummer
Added search_box
92
@templatefunc
207.1.8 by Paul Hummer
Moved the form tags for the search box into the search template
93
def search_box(branch, navigation):
94
    return _pt('search-box').expand(branch=branch, navigation=navigation,
95
        **templatefunctions)
207.1.1 by Paul Hummer
Added search_box
96
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
97
207.1.3 by Paul Hummer
Added feed_link template function
98
@templatefunc
207.1.10 by Paul Hummer
Fixed an issue with the feed link
99
def feed_link(branch, url):
100
    return _pt('feed-link').expand(branch=branch, url=url, **templatefunctions)
207.1.4 by Paul Hummer
Pulled menu into its own template
101
230.1.1 by Steve 'Ashcrow' Milner
Updated to follow pep8.
102
207.1.4 by Paul Hummer
Pulled menu into its own template
103
@templatefunc
207.1.6 by Paul Hummer
Finish up abstracting the menu
104
def menu(branch, url, fileview_active=False):
105
    return _pt('menu').expand(branch=branch, url=url,
106
        fileview_active=fileview_active, **templatefunctions)