diff --git a/scribeengine/lib/helpers.py b/scribeengine/lib/helpers.py index 1e02a6d..e5334b4 100644 --- a/scribeengine/lib/helpers.py +++ b/scribeengine/lib/helpers.py @@ -26,12 +26,15 @@ Helper functions Consists of functions to typically be used within templates, but also available to Controllers. This module is available to both as 'h'. """ +import logging from webhelpers.html import escape, HTML, literal, url_escape from webhelpers.date import distance_of_time_in_words from pylons import session, url as url_for from pylons.controllers.util import redirect_to +log = logging.getLogger(__name__) + class Flash(object): def set_message(self, message_text, message_type, message_head=None): session[u'flash.text'] = message_text @@ -77,6 +80,13 @@ def teaser(text): text = text[:position] return text +def comment(text): + text = text.replace(u'\r\n', u'\n') + paralist = escape(text).split(u'\n\n') + paragraphs = u'

'.join([para.strip(u'\n') for para in paralist]) + text = paragraphs.replace(u'\n', u'
') + return literal(text) + def url_for_post(post): #TODO: this is hard coded. return url_for( diff --git a/scribeengine/public/styles/style.css b/scribeengine/public/styles/style.css index 1d3b53a..14da007 100644 --- a/scribeengine/public/styles/style.css +++ b/scribeengine/public/styles/style.css @@ -221,6 +221,11 @@ hr { font-size: 0.9em; } +.comment-body p { + margin-top: 0; + margin-bottom: 0.5em; +} + .user-details { margin-top: 0; } diff --git a/scribeengine/templates/blog/view.mako b/scribeengine/templates/blog/view.mako index 80f2091..4c8dead 100644 --- a/scribeengine/templates/blog/view.mako +++ b/scribeengine/templates/blog/view.mako @@ -39,8 +39,8 @@ by ${comment.user.nick} on ${comment.created.strftime('%B %d, %Y')} at ${comment.created.strftime('%H:%M')} -

- ${comment.body} +
+

${h.comment(comment.body)}

% endfor