summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-05-03 15:43:00 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-05-03 15:43:00 +0200
commit4c88fe5a2efc7cc6a5412966aa44fb80f19415aa (patch)
treedf20e60e65d3dcf3f4cda6d9e9feea3d6f1fcb02
parent5b0e4328baa9d6563158cf894290bcaa9353ba66 (diff)
downloadweb-4c88fe5a2efc7cc6a5412966aa44fb80f19415aa.tar.gz
web-4c88fe5a2efc7cc6a5412966aa44fb80f19415aa.tar.bz2
web-4c88fe5a2efc7cc6a5412966aa44fb80f19415aa.zip
Change code to be run in a multiple-app env
-rw-r--r--highlighting.py12
-rwxr-xr-xindex.py4
-rw-r--r--renderer.py3
-rw-r--r--templates/root.mako2
4 files changed, 9 insertions, 12 deletions
diff --git a/highlighting.py b/highlighting.py
index f859920..439ae78 100644
--- a/highlighting.py
+++ b/highlighting.py
@@ -7,13 +7,11 @@ formatter = HtmlFormatter(encoding = "utf-8", classprefix="pygm", nowrap=True)
BashLexer.tokens["basic"].append((r'\b(emerge|layman|git(?!:))\s*\b(?!\.)', Name.Builtin))
-def highlight(context, code, lang):
+def highlight(code, lang):
l = get_lexer_by_name(lang, encoding = "utf-8")
- context.write(pygHighlight(code, l, formatter))
- return ''
+ return pygHighlight(code, l, formatter)
-def get_css(context):
- context.write("""<style type="text/css">
+def get_css():
+ return """<style type="text/css">
%s
-</style>""" % formatter.get_style_defs())
- return ''
+</style>""" % formatter.get_style_defs()
diff --git a/index.py b/index.py
index 5db7b25..b91418d 100755
--- a/index.py
+++ b/index.py
@@ -7,8 +7,8 @@ import controller
# URL Mappings
#
urls = (
- "/r/(.*)", "controller.Redirect",
- "/(.*)", "controller.Page"
+ "/r/(.*)", controller.Redirect,
+ "/(.*)", controller.Page
)
#
diff --git a/renderer.py b/renderer.py
index 5e19a92..ba08e36 100644
--- a/renderer.py
+++ b/renderer.py
@@ -4,6 +4,7 @@ import mako
from mako.lookup import TemplateLookup
import helper
+import highlighting
class Renderer:
"""
@@ -23,7 +24,7 @@ class Renderer:
except mako.exceptions.TopLevelLookupException, e:
raise web.ctx.app_stack[-1].notfound(tpl)
- return t.render(h = helper, url = helper.url, w = web, **kwargs)
+ return t.render(h = helper, url = helper.url, w = web, _hl = highlighting, **kwargs)
__call__ = render
diff --git a/templates/root.mako b/templates/root.mako
index 72dac01..39ee098 100644
--- a/templates/root.mako
+++ b/templates/root.mako
@@ -38,8 +38,6 @@
## functions
-<%namespace name="_hl" module="highlighting"/>
-
<%def name="hl(lang)">
<pre class="box">${_hl.highlight(capture(caller.body), lang)}</pre>
</%def>