-
-
Save dmitric/3828280 to your computer and use it in GitHub Desktop.
Template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Traceback (most recent call last): | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/web.py", line 1021, in _stack_context_handle_exception | |
raise_exc_info((type, value, traceback)) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/stack_context.py", line 258, in _nested | |
yield vars | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/stack_context.py", line 228, in wrapped | |
callback(*args, **kwargs) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/gen.py", line 382, in inner | |
self.set_result(key, result) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/gen.py", line 315, in set_result | |
self.run() | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/gen.py", line 345, in run | |
yielded = self.gen.send(next) | |
File "/Users/DLC/Code/gkapps/b/handlers/route.py", line 135, in get | |
is_app=self.is_app) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/web.py", line 500, in render | |
html = self.render_string(template_name, **kwargs) | |
File "/Users/DLC/Code/gkapps/handlers/base.py", line 13, in render_string | |
return tornado.web.RequestHandler.render_string(self, template, **kwargs) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/web.py", line 607, in render_string | |
return t.generate(**namespace) | |
File "/Users/DLC/.virtualenvs/b/lib/python2.7/site-packages/tornado/template.py", line 261, in generate | |
return execute() | |
File "web/route_html.generated.py", line 429, in _execute | |
return _utf8('').join(_buffer) # web/base.html:0 | |
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 27: ordinal not in range(128) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#catch link and hashtags or @ mentions | |
_LINK_RE = re.compile(ur"([@#])([\w]+)") | |
def link_elements(text): | |
def make_link(m): | |
link_type = m.group(1) | |
if link_type == u'@': | |
link_type = u'/%s' % m.group(2) | |
else: | |
link_type = u'/tag/%s' % m.group(2) | |
return u'<a href="%s">%s</a>' % (link_type, m.group(0)) | |
return _LINK_RE.sub(make_link, text) | |
return self.render("t.html", link_elements=link_elements) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% block body %} | |
... | |
{% if len(comments) > 0 and (not is_app or show_comments) %} | |
<div class="comments"> | |
{% for comment in comments %} | |
<a class="username" href="/{{ comment["user"]["username"] }}">{{ comment["user"]["username"] }}</a> | |
<p class="comment">{% apply link_elements %}{{ comment['textContent'] }} {% end %}</p> | |
{% end %} | |
</div> | |
{% end %} | |
... | |
{% end %} | |
{% end %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment