/loggerhead/trunk

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/loggerhead/trunk

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

Fix bug #333797 ("Loggerhead should offer a link to see the full file diffs for
a file path")

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
16
17
import os
17
18
from loggerhead.zptsupport import zpt
18
19
 
37
38
 
38
39
 
39
40
@templatefunc
40
 
def file_change_summary(url, entry, modified_file_link):
 
41
def file_change_summary(url, entry, link_style='normal', currently_showing=None):
 
42
    if link_style == 'fragment':
 
43
        def file_link(filename):
 
44
            if currently_showing:
 
45
                print filename, currently_showing, filename == currently_showing
 
46
                if filename == currently_showing:
 
47
                    return '<b><a href="#%s">%s</a></b>' % (
 
48
                        cgi.escape(filename), cgi.escape(filename))
 
49
                else:
 
50
                    return revision_link(url, entry.revno, filename)
 
51
            else:
 
52
                return '<a href="#%s">%s</a>' % (
 
53
                    cgi.escape(filename), cgi.escape(filename))
 
54
    else:
 
55
        file_link = lambda filename: revision_link(url, entry.revno, filename)
41
56
    return _pt('revisionfilechanges').expand(
42
 
        url=url, entry=entry, modified_file_link=modified_file_link,
43
 
        **templatefunctions)
 
57
        url=url, entry=entry, file_link=file_link,
 
58
        currently_showing=currently_showing, **templatefunctions)
44
59
 
45
60
 
46
61
@templatefunc
47
 
def revisioninfo(url, branch, entry, modified_file_link=None):
 
62
def revisioninfo(url, branch, entry, include_file_list=False, currently_showing=None):
48
63
    from loggerhead import util
49
64
    return _pt('revisioninfo').expand(
50
65
        url=url, change=entry, branch=branch, util=util,
51
 
        modified_file_link=modified_file_link,
 
66
        include_file_list=include_file_list, currently_showing=currently_showing,
52
67
        **templatefunctions)
53
68
 
54
69
 
84
99
 
85
100
 
86
101
@templatefunc
87
 
def modified_file_link_rev(url, entry, item):
88
 
    return _pt('modified-file-link-rev').expand(
89
 
        url=url, entry=entry, item=item,
90
 
        **templatefunctions)
91
 
 
92
 
 
93
 
@templatefunc
94
 
def modified_file_link_log(url, entry, item):
95
 
    return _pt('modified-file-link-log').expand(
96
 
        url=url, entry=entry, item=item,
97
 
        **templatefunctions)
98
 
 
99
 
 
100
 
@templatefunc
101
102
def search_box(branch, navigation):
102
103
    return _pt('search-box').expand(branch=branch, navigation=navigation,
103
104
        **templatefunctions)
112
113
def menu(branch, url, fileview_active=False):
113
114
    return _pt('menu').expand(branch=branch, url=url,
114
115
        fileview_active=fileview_active, **templatefunctions)
 
116
 
 
117
 
 
118
@templatefunc
 
119
def annotate_link(url, revno, path):
 
120
    return '<a href="%s" title="Annotate %s">%s</a>'%(
 
121
        url(['/annotate', revno, path]), cgi.escape(path), cgi.escape(path))
 
122
 
 
123
@templatefunc
 
124
def revision_link(url, revno, path):
 
125
    return '<a href="%s" title="View changes to %s in revision %s">%s</a>'%(
 
126
        url(['/revision', revno, path]), cgi.escape(path), cgi.escape(revno),
 
127
        cgi.escape(path))