~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

  • Committer: Martin Albisetti
  • Date: 2008-11-17 18:08:38 UTC
  • mto: This revision was merged to the branch mainline in revision 242.
  • Revision ID: argentina@gmail.com-20081117180838-lwumzgappr8t93vm
* Use head in the download URL when viewing HEAD of BRANCH
* Some cleanups

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
15
15
#
16
 
import cgi
17
16
import os
18
17
from loggerhead.zptsupport import zpt
19
18
 
38
37
 
39
38
 
40
39
@templatefunc
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))
47
 
            else:
48
 
                return revision_link(
49
 
                    url, entry.revno, filename, '#' + filename)
50
 
    else:
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))
 
40
def file_change_summary(url, entry, modified_file_link):
55
41
    return _pt('revisionfilechanges').expand(
56
 
        entry=entry, file_changes=file_changes, file_link=file_link, **templatefunctions)
 
42
        url=url, entry=entry, modified_file_link=modified_file_link,
 
43
        **templatefunctions)
57
44
 
58
45
 
59
46
@templatefunc
60
 
def revisioninfo(url, branch, entry, file_changes=None, currently_showing=None):
 
47
def revisioninfo(url, branch, entry, modified_file_link=None):
61
48
    from loggerhead import util
62
49
    return _pt('revisioninfo').expand(
63
50
        url=url, change=entry, branch=branch, util=util,
64
 
        file_changes=file_changes, currently_showing=currently_showing,
 
51
        modified_file_link=modified_file_link,
65
52
        **templatefunctions)
66
53
 
67
54
 
68
55
@templatefunc
69
 
def branchinfo(branch):
70
 
    if branch.served_url is not None:
71
 
        return _pt('branchinfo').expand(branch=branch, **templatefunctions)
72
 
    else:
73
 
        return ''
74
 
 
75
 
 
76
 
@templatefunc
77
56
def collapse_button(group, name, branch, normal='block'):
78
57
    return _pt('collapse-button').expand(
79
58
        group=group, name=name, normal=normal, branch=branch,
97
76
 
98
77
 
99
78
@templatefunc
 
79
def modified_file_link_rev(url, entry, item):
 
80
    return _pt('modified-file-link-rev').expand(
 
81
        url=url, entry=entry, item=item,
 
82
        **templatefunctions)
 
83
 
 
84
 
 
85
@templatefunc
 
86
def modified_file_link_log(url, entry, item):
 
87
    return _pt('modified-file-link-log').expand(
 
88
        url=url, entry=entry, item=item,
 
89
        **templatefunctions)
 
90
 
 
91
 
 
92
@templatefunc
100
93
def search_box(branch, navigation):
101
94
    return _pt('search-box').expand(branch=branch, navigation=navigation,
102
95
        **templatefunctions)
111
104
def menu(branch, url, fileview_active=False):
112
105
    return _pt('menu').expand(branch=branch, url=url,
113
106
        fileview_active=fileview_active, **templatefunctions)
114
 
 
115
 
 
116
 
@templatefunc
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))
120
 
 
121
 
@templatefunc
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))