~loggerhead-team/loggerhead/trunk-rich

« back to all changes in this revision

Viewing changes to loggerhead/templatefunctions.py

  • Committer: geoffreyfishing at gmail
  • Date: 2011-06-08 21:43:23 UTC
  • mto: (431.2.18 loggerhead) (459.2.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 461.
  • Revision ID: geoffreyfishing@gmail.com-20110608214323-gfrkg7kuc84dl68v
Finished up.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
15
15
#
16
16
 
 
17
import cgi
17
18
import os
18
 
import urllib
19
19
 
20
20
import pkg_resources
21
21
 
23
23
 
24
24
import loggerhead
25
25
from loggerhead.zptsupport import zpt
26
 
from loggerhead.util import html_format
27
26
 
28
27
 
29
28
templatefunctions = {}
50
49
    if style == 'fragment':
51
50
        def file_link(filename):
52
51
            if currently_showing and filename == currently_showing:
53
 
                return html_format(
54
 
                    '<b><a href="#%s">%s</a></b>',
55
 
                    urllib.quote(filename.encode('utf-8')), filename)
 
52
                return '<b><a href="#%s">%s</a></b>' % (
 
53
                    cgi.escape(filename), cgi.escape(filename))
56
54
            else:
57
55
                return revision_link(
58
 
                    url, entry.revno, filename,
59
 
                    '#' + urllib.quote(filename.encode('utf-8')))
 
56
                    url, entry.revno, filename, '#' + filename)
60
57
    else:
61
58
        def file_link(filename):
62
 
            return html_format(
63
 
                '<a href="%s%s" title="View changes to %s in revision %s">'
64
 
                '%s</a>',
65
 
                url(['/revision', entry.revno]),
66
 
                '#' + urllib.quote(filename.encode('utf-8')),
67
 
                filename, entry.revno, 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))
68
62
    return _pt('revisionfilechanges').expand(
69
63
        entry=entry, file_changes=file_changes, file_link=file_link, **templatefunctions)
70
64
 
128
122
 
129
123
@templatefunc
130
124
def view_link(url, revno, path):
131
 
    return html_format(
132
 
        '<a href="%s" title="Annotate %s">%s</a>',
133
 
        url(['/view', revno, path]), path, path)
134
 
 
 
125
    return '<a href="%s" title="Annotate %s">%s</a>' % (
 
126
        url(['/view', revno, path]), cgi.escape(path), cgi.escape(path))
135
127
 
136
128
@templatefunc
137
129
def revision_link(url, revno, path, frag=''):
138
 
    return html_format(
139
 
        '<a href="%s%s" title="View changes to %s in revision %s">%s</a>',
140
 
        url(['/revision', revno, path]), frag, path, revno, path)
 
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))
141
133
 
142
134
 
143
135
@templatefunc