First commit
This commit is contained in:
commit
8a5e979650
@ -39,13 +39,13 @@ paths.images = %(here)s/images
|
||||
paths.themes = %(here)s/themes
|
||||
|
||||
# Security settings
|
||||
security.salt = xgH,{@1pgtU9,nLd
|
||||
security.salt = secretsalt
|
||||
|
||||
mail.on = true
|
||||
mail.on = false
|
||||
mail.manager = immediate
|
||||
mail.smtp.server = mail.saturnlaboratories.co.za
|
||||
mail.smtp.username = raoul.snyman+saturnlaboratories.co.za
|
||||
mail.smtp.password = 0miG0sh89
|
||||
mail.smtp.server = mail.mydomain.com
|
||||
mail.smtp.username = mymailusername
|
||||
mail.smtp.password = mymailpassword
|
||||
|
||||
# WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT*
|
||||
# Debug mode will enable the interactive debugging tool, allowing ANYONE to
|
||||
|
@ -20,12 +20,12 @@ def load_environment(global_conf, app_conf):
|
||||
engine = engine_from_config(app_conf, 'sqlalchemy.')
|
||||
init_model(engine)
|
||||
|
||||
# Pull out theme variable
|
||||
theme = Session.query(Variable).get(u'theme')
|
||||
if theme:
|
||||
theme_name = theme.value
|
||||
else:
|
||||
theme_name = None
|
||||
theme_name = None
|
||||
if not app_conf.get('setup-app'):
|
||||
# Pull out theme variable
|
||||
theme = Session.query(Variable).get(u'theme')
|
||||
if theme:
|
||||
theme_name = theme.value
|
||||
|
||||
# Set up Pylons paths
|
||||
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
@ -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))
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
}
|
||||
)
|
||||
|
@ -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 {
|
||||
|
@ -19,6 +19,11 @@
|
||||
% for page in c.pages:
|
||||
<li><a href="${page.url}">${page.name}</a></li>
|
||||
% endfor
|
||||
% if c.current_user:
|
||||
<li><a href="${h.url_for('/admin/logout')}">Logout</a></li>
|
||||
% else:
|
||||
<li><a href="${h.url_for('/admin/login')}">Login</a></li>
|
||||
% endif
|
||||
</ul>
|
||||
</div>
|
||||
<hr />
|
||||
|
@ -1,21 +1,20 @@
|
||||
<%inherit file="/base.mako"/>
|
||||
<%include file="/flash.mako"/>
|
||||
% for post in c.posts:
|
||||
<% post.full_url = u'/archive/%s/%s/%s/%s' % (post.created.strftime('%Y'), post.created.strftime('%m'), post.created.strftime('%d'), post.url) %>
|
||||
<div class="post">
|
||||
<h2 class="title"><a href="${post.full_url}">${post.title}</a></h2>
|
||||
<h2 class="title"><a href="${h.full_url(post)}">${post.title}</a></h2>
|
||||
<div class="entry">
|
||||
${h.literal(h.teaser(post.body, post.full_url))}
|
||||
${h.literal(h.teaser(post.body, h.full_url(post)))}
|
||||
</div>
|
||||
<p class="meta">
|
||||
<span class="byline">Posted by ${post.user.nick} on ${post.created.strftime('%B %d, %Y')}</span>
|
||||
<a href="${post.full_url}" class="read-more">Read more</a>
|
||||
<a href="${h.full_url(post)}" class="read-more">Read more</a>
|
||||
% if len(post.comments) == 0:
|
||||
<a href="${post.full_url}#comments" class="comments">No comments</a>
|
||||
<a href="${h.full_url(post)}#comments" class="comments">No comments</a>
|
||||
% elif len(post.comments) == 1:
|
||||
<a href="${post.full_url}#comments" class="comments">1 comment</a>
|
||||
<a href="${h.full_url(post)}#comments" class="comments">1 comment</a>
|
||||
% else:
|
||||
<a href="${post.full_url}#comments" class="comments">${len(post.comments)} comments</a>
|
||||
<a href="${h.full_url(post)}#comments" class="comments">${len(post.comments)} comments</a>
|
||||
% endif
|
||||
</p>
|
||||
</div>
|
||||
|
@ -1,15 +1,13 @@
|
||||
<%inherit file="/base.mako"/>
|
||||
<div class="post">
|
||||
<%include file="/flash.mako"/>
|
||||
<h2 class="title"><a href="${h.url_for(year=c.post.created.strftime('%Y'), month=c.post.created.strftime('%m'), day=c.post.created.strftime('%d'), url=c.post.url)}">${c.post.title}</a></h2>
|
||||
<h2 class="title">${c.post.title}</h2>
|
||||
<div class="info">Posted by ${c.post.user.nick} on ${c.post.created.strftime('%B %d, %Y')}</div>
|
||||
<%include file="/flash.mako"/>
|
||||
<div class="entry">
|
||||
${h.literal(c.post.body)}
|
||||
</div>
|
||||
<div> </div>
|
||||
% if len(c.post.comments) == 0:
|
||||
<h3 id="comments">No Responses</h3>
|
||||
<p> </p>
|
||||
% elif len(c.post.comments) == 1:
|
||||
<h3 id="comments">One Response</h3>
|
||||
% else:
|
||||
@ -19,9 +17,16 @@
|
||||
<ol class="commentlist">
|
||||
% for num, comment in enumerate(c.post.comments):
|
||||
<li id="comment-${comment.id}">
|
||||
<cite>${comment.user.nick}</cite> Says:<br />
|
||||
<small class="commentmetadata"><a href="#comment-<?php comment_ID() ?>" title="">${comment.created.strftime('%B %d, %Y')} at ${comment.created.strftime('%H:%M')}</a> <a href="edit">edit</a></small>
|
||||
${comment.body}
|
||||
<div class="comment-title">
|
||||
<a href="#comment-${comment.id}" title="${comment.title}">${comment.title}</a>
|
||||
</div>
|
||||
<div class="comment-meta">
|
||||
by <cite>${comment.user.nick}</cite>
|
||||
on ${comment.created.strftime('%B %d, %Y')} at ${comment.created.strftime('%H:%M')}
|
||||
</div>
|
||||
<div>
|
||||
${comment.body}
|
||||
</div>
|
||||
</li>
|
||||
% endfor
|
||||
</ol>
|
||||
@ -33,15 +38,14 @@
|
||||
% if c.post.comment_status == u'open':
|
||||
<h3 id="respond">Leave a Reply</h3>
|
||||
% if not c.current_user:
|
||||
<p>You must be <a href="/login">logged in</a> to post a comment.</p>
|
||||
<p>You must be <a href="${h.url_for('/admin/login')}">logged in</a> to post a comment.</p>
|
||||
% else:
|
||||
<div> </div>
|
||||
<form action="${h.url_for('/comment/edit')}" method="post" id="commentform">
|
||||
<p>Logged in as <em>${c.current_user.nick}</em>. <a href="/logout" title="Log out of this account">Logout »</a></p>
|
||||
<p><textarea name="comment" id="comment" cols="80" rows="10" tabindex="4" style="width: 605px;"></textarea></p>
|
||||
<form action="${h.url_for('/blog/comment/%s' % c.post.id)}" method="post" id="commentform">
|
||||
<p class="user-details">Logged in as <em>${c.current_user.nick}</em>. <a href="/logout" title="Log out of this account">Logout »</a></p>
|
||||
<p><input type="text" name="title" class="form-text" value="RE: ${c.post.title}" /></p>
|
||||
<p><textarea name="body" class="form-textarea" cols="80" rows="10" tabindex="4"></textarea></p>
|
||||
<p>
|
||||
<input name="submit" type="submit" id="submit" tabindex="5" value="Submit Comment" />
|
||||
<input type="hidden" name="post_id" value="${c.post.id}" />
|
||||
<input name="submit" type="submit" id="submit" tabindex="5" class="form-button" value="Submit Comment" />
|
||||
</p>
|
||||
</form>
|
||||
% endif
|
||||
|
@ -32,6 +32,7 @@ log = logging.getLogger(__name__)
|
||||
|
||||
def setup_app(command, conf, vars):
|
||||
"""Place any commands to setup scribeengine here"""
|
||||
conf.local_conf['setup-app'] = True
|
||||
load_environment(conf.global_conf, conf.local_conf)
|
||||
|
||||
import hashlib
|
||||
@ -56,10 +57,10 @@ def setup_app(command, conf, vars):
|
||||
role_admin = Role(name=u'Administrator')
|
||||
role_admin.permissions.extend([perm_addposts, perm_editmyposts, perm_delmyposts])
|
||||
|
||||
password = unicode(hmac.new(conf[u'security.salt'], u'omigosh',
|
||||
password = unicode(hmac.new(conf[u'security.salt'], u'password',
|
||||
hashlib.sha256).hexdigest(), u'utf-8')
|
||||
user = User(email=u'raoul.snyman@saturnlaboratories.co.za',
|
||||
password=password, nick=u'raoul')
|
||||
user = User(email=u'admin@scribeengine.org',
|
||||
password=password, nick=u'admin')
|
||||
user.roles.append(role_admin)
|
||||
|
||||
Session.add_all([blog_title, blog_slogan, user])
|
||||
|
Reference in New Issue
Block a user