From bbd366c0cbd88483976e06fabc51d0254a0be2ac Mon Sep 17 00:00:00 2001
From: Raoul Snyman
and
\n becomes
---
scribeengine/lib/helpers.py | 10 ++++++++++
scribeengine/public/styles/style.css | 5 +++++
scribeengine/templates/blog/view.mako | 4 ++--
3 files changed, 17 insertions(+), 2 deletions(-)
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')}
-
${h.comment(comment.body)}