annotate pylons_app/lib/helpers.py @ 165:ea893ffb7f00

implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 21 May 2010 02:07:49 +0200
parents 4cea52709743
children be4621c6de58
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
1 """Helper functions
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
2
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
3 Consists of functions to typically be used within templates, but also
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
4 available to Controllers. This module is available to both as 'h'.
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
5 """
165
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
6 from pylons import url, app_globals as g
97
be0096a02772 added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents: 94
diff changeset
7 from pylons.i18n.translation import _, ungettext
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
8 from webhelpers.html import (literal, HTML, escape)
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
9 from webhelpers.html.builder import make_tag
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
10 from webhelpers.html.tools import (auto_link, button_to, highlight, js_obfuscate
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
11 , mail_to, strip_links, strip_tags, tag_re)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
12 from webhelpers.html.tags import (auto_discovery_link, checkbox, css_classes,
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
13 end_form, file, form, hidden, image,
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
14 javascript_link, link_to, link_to_if,
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
15 link_to_unless, ol, required_legend,
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
16 select, stylesheet_link,
94
0bb9391bc287 webhelpers update
Marcin Kuzminski <marcin@python-works.com>
parents: 45
diff changeset
17 submit, text, password, textarea, title,
0bb9391bc287 webhelpers update
Marcin Kuzminski <marcin@python-works.com>
parents: 45
diff changeset
18 ul, xml_declaration)
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
19 from webhelpers.text import (chop_at, collapse, convert_accented_entities,
94
0bb9391bc287 webhelpers update
Marcin Kuzminski <marcin@python-works.com>
parents: 45
diff changeset
20 convert_misc_entities, lchop, plural, rchop,
0bb9391bc287 webhelpers update
Marcin Kuzminski <marcin@python-works.com>
parents: 45
diff changeset
21 remove_formatting, replace_whitespace, urlify)
165
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
22 from webhelpers.number import (format_byte_size, format_bit_size)
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
23 from webhelpers.pylonslib import Flash as _Flash
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
24 from webhelpers.pylonslib.secure_form import secure_form
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
25
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
26 from pygments import highlight
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
27 from pygments.formatters import HtmlFormatter
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
28 from pygments.lexers import guess_lexer
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
29 from pygments.lexers import get_lexer_by_name
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
30
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
31 #Custom helper here :)
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
32 class _Link(object):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
33 '''
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
34 Make a url based on label and url with help of url_for
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
35 @param label:name of link if not defined url is used
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
36 @param url: the url for link
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
37 '''
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
38
43
2e1247e62c5b changed for pylons 0.1 / 1.0
marcink
parents: 0
diff changeset
39 def __call__(self, label='', *url_, **urlargs):
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
40 if label is None or '':
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
41 label = url
43
2e1247e62c5b changed for pylons 0.1 / 1.0
marcink
parents: 0
diff changeset
42 link_fn = link_to(label, url(*url_, **urlargs))
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
43 return link_fn
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
44
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
45
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
46 class _GetError(object):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
47
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
48 def __call__(self, field_name, form_errors):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
49 tmpl = """<span class="error_msg">%s</span>"""
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
50 if form_errors and form_errors.has_key(field_name):
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
51 return literal(tmpl % form_errors.get(field_name))
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
52
102
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
53 class _FilesBreadCrumbs(object):
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
54
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
55 def __call__(self, repo_name, rev, paths):
104
4cea52709743 fixed file browser breadcrumbs with revision
Marcin Kuzminski <marcin@python-works.com>
parents: 102
diff changeset
56 url_l = [link_to(repo_name, url('files_home', repo_name=repo_name, revision=rev, f_path=''))]
102
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
57 paths_l = paths.split('/')
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
58
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
59 for cnt, p in enumerate(paths_l, 1):
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
60 if p != '':
104
4cea52709743 fixed file browser breadcrumbs with revision
Marcin Kuzminski <marcin@python-works.com>
parents: 102
diff changeset
61 url_l.append(link_to(p, url('files_home', repo_name=repo_name, revision=rev, f_path='/'.join(paths_l[:cnt]))))
97
be0096a02772 added helper for filesize
Marcin Kuzminski <marcin@python-works.com>
parents: 94
diff changeset
62
102
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
63 return literal(' / '.join(url_l))
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
64
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
65 def pygmentize(code, **kwargs):
165
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
66 """
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
67 Filter for chunks of html to replace code tags with pygmented code
165
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
68 """
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
69 code = code.splitlines()
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
70 _html, _html2 = [], []
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
71 _html.append("""<table class="code-highlighttable">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
72 _html.append("""<tr>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
73 _html.append("""<td class="linenos">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
74 _html.append("""<div class="linenodiv">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
75 _html.append("""<pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
76 for cnt, code in enumerate(code, 1):
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
77 #generete lines nos
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
78 _html.append("""<a id="A%s" href="#A%s">%s</a>\n""" \
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
79 % (cnt, cnt, cnt))
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
80 #propagate second list with code
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
81 _html2.append("""%s""" % (highlight(code, get_lexer_by_name('python'),
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
82 HtmlFormatter(nowrap=True))))
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
83 _html.append("""</pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
84 _html.append("""</div>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
85 _html.append("""</td>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
86 _html.append("""<td class="code">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
87 _html.append("""<div class="code-highlight">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
88 _html.append("""<pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
89 _html.extend(_html2)
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
90 _html.append("""</pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
91 _html.append("""</div>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
92 _html.append("""</td>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
93 _html.append("""</tr>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
94 _html.append("""</table>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
95 return literal(''.join(_html))
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
96 #return literal(highlight(code, get_lexer_by_name('python'), HtmlFormatter(**kwargs)))
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
97
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
98 def pygmentize_annotation(annotate_list, repo_name):
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
99 """
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
100 Generate a dict of
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
101 @param annotate_lists:
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
102 """
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
103 import random
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
104 color_dict = g.changeset_annotation_colors
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
105 def gen_color():
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
106 return [str(random.randrange(0, 255)) for _ in xrange(3)]
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
107 def get_color_string(cs):
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
108 if color_dict.has_key(cs):
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
109 col = color_dict[cs]
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
110 else:
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
111 color_dict[cs] = gen_color()
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
112 col = color_dict[cs]
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
113 return "color: rgb(%s) ! important;" % (','.join(col))
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
114 _html, _html2, _html3 = [], [], []
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
115 _html.append("""<table class="code-highlighttable">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
116 _html.append("""<tr>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
117 _html.append("""<td class="linenos">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
118 _html.append("""<div class="linenodiv">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
119 _html.append("""<pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
120 for line in annotate_list:
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
121 #lines
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
122 _html.append("""<a id="A%s" href="#S%s">%s</a>\n""" \
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
123 % (line[0], line[0], line[0]))
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
124 #annotation tags
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
125 _html2.append("""%s\n""" % link_to(line[1].raw_id,
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
126 url('changeset_home', repo_name=repo_name, revision=line[1].raw_id),
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
127 title=_('author') + ':%s rev:%s %s' % (line[1].author, line[1].revision,
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
128 line[1].message,),
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
129 style=get_color_string(line[1].raw_id)))
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
130 #code formated with pygments
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
131 _html3.append("""%s""" % (highlight(line[2], get_lexer_by_name('python')
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
132 , HtmlFormatter(nowrap=True))))
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
133 _html.append("""</pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
134 _html.append("""</div>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
135 _html.append("""</td>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
136 _html.append("""<td class="linenos">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
137 _html.append("""<div class="linenodiv">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
138 _html.append("""<pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
139 _html.extend(_html2)
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
140 _html.append("""</pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
141 _html.append("""</div>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
142 _html.append("""</td>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
143 _html.append("""<td class="code">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
144 _html.append("""<div class="code-highlight">""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
145 _html.append("""<pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
146 _html.extend(_html3)
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
147 _html.append("""</pre>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
148 _html.append("""</div>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
149 _html.append("""</td>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
150 _html.append("""</tr>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
151 _html.append("""</table>""")
ea893ffb7f00 implemented pygmentize codes into webhelpers. Together with color_dict caching into pylons globals
Marcin Kuzminski <marcin@python-works.com>
parents: 104
diff changeset
152 return literal(''.join(_html))
98
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
153
01d0f363f36d added pygments webhelper
Marcin Kuzminski <marcin@python-works.com>
parents: 97
diff changeset
154
102
2dc0c8e4f384 Updated tempaltes, added file browser breadcrumbs, and feed icons
Marcin Kuzminski <marcin@python-works.com>
parents: 98
diff changeset
155 files_breadcrumbs = _FilesBreadCrumbs()
0
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
156 link = _Link()
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
157 flash = _Flash()
564e40829f80 initial commit.
Marcin Kuzminski
parents:
diff changeset
158 get_error = _GetError()