diff --git a/scribeengine/controllers/blog.py b/scribeengine/controllers/blog.py index dca72f8..12b34e8 100644 --- a/scribeengine/controllers/blog.py +++ b/scribeengine/controllers/blog.py @@ -25,7 +25,7 @@ from datetime import datetime from scribeengine.lib.base import * from scribeengine.lib import utils -from scribeengine.model import Post +from scribeengine.model import Post, Comment from scribeengine.model.meta import Session log = logging.getLogger(__name__) @@ -70,3 +70,23 @@ class BlogController(BaseController): .first() c.page_title = c.post.title return render(u'/blog/view.mako') + + def comment_POST(self, id): + if not id: + h.flash.set_message(u'There was a problem submitting your comment.', u'error') + h.redirect_to('/') + post = Session.query(Post).get(id) + if not post or post.comment_status != u'open': + h.flash.set_message(u'There was a problem submitting your comment.', u'error') + h.redirect_to('/') + comment = Comment( + user = c.current_user, + title = c.form_values[u'title'], + body = c.form_values[u'body'] + ) + post.comments.append(comment) + Session.add(post) + Session.commit() + h.flash.set_message(u'Successfully submitted your comment.', u'success') + h.redirect_to(h.full_url(post)) + diff --git a/scribeengine/lib/helpers.py b/scribeengine/lib/helpers.py index 5b0a7f5..17f1403 100644 --- a/scribeengine/lib/helpers.py +++ b/scribeengine/lib/helpers.py @@ -78,4 +78,10 @@ def teaser(text, url): text = text[:position] return text +def full_url(post): + return '/archive/%s/%s/%s/%s' % (str(post.created.strftime('%Y')), \ + str(post.created.strftime('%m')), \ + str(post.created.strftime('%d')), \ + str(post.url)) + flash = Flash() diff --git a/scribeengine/model/__init__.py b/scribeengine/model/__init__.py index 46dee34..854ff67 100644 --- a/scribeengine/model/__init__.py +++ b/scribeengine/model/__init__.py @@ -46,7 +46,7 @@ mapper(Permission, permissions_table) mapper(Post, posts_table, properties={ u'categories': relation(Category, backref='posts', secondary=categories_posts_table), - u'comments': relation(Comment, backref=u'post'), + u'comments': relation(Comment, backref=u'post', order_by=Comment.created.desc()), u'tags': relation(Tag, backref=u'posts', secondary=posts_tags_table) } ) diff --git a/scribeengine/public/styles/style.css b/scribeengine/public/styles/style.css index b18b9e3..8adcc00 100644 --- a/scribeengine/public/styles/style.css +++ b/scribeengine/public/styles/style.css @@ -32,7 +32,7 @@ h3 { font-size: 1em; } -p, ul, ol { +p, ul, ol, pre { margin-top: 1.8em; line-height: 180%; } @@ -186,6 +186,44 @@ hr { margin-left: 1em; } +.post pre { + background-color: #191919; + border: 1px solid #333333; + font-family: Monaco, Lucida Typewriter, Courier New, monospace; + margin-bottom: 0.5em; + padding: 0.3em 0.5em; +} + +/* Comments */ + +#comments, +#respond { + font-size: 1.5em; + margin-top: 1.8em; +} + +.commentlist { + font-weight: bold; +} + +.commentlist li { + margin-top: 1em; + font-weight: normal; +} + +.comment-title { + font-size: 1.2em; + font-weight: bold; +} + +.comment-meta { + font-size: 0.9em; +} + +.user-details { + margin-top: 0; +} + /* Sidebar */ #sidebar { @@ -319,7 +357,7 @@ fieldset { .form-textarea { height: 12em; - width: 605px; + width: 595px; } .form-button { diff --git a/scribeengine/templates/base.mako b/scribeengine/templates/base.mako index 532a870..6538cae 100644 --- a/scribeengine/templates/base.mako +++ b/scribeengine/templates/base.mako @@ -19,6 +19,11 @@ % for page in c.pages:
% elif len(c.post.comments) == 1:
You must be logged in to post a comment.
+You must be logged in to post a comment.
% else: -
- ${comment.created.strftime('%B %d, %Y')} at ${comment.created.strftime('%H:%M')} edit - ${comment.body} +