Added a "tags" view.
This commit is contained in:
parent
91338e7691
commit
a8a9510c62
@ -4,3 +4,4 @@ ScribeEngine.e4p
|
||||
scribeengine.sqlite
|
||||
posts.sql
|
||||
*.egg-info
|
||||
ScrivbeEngine.e4p
|
||||
|
@ -48,6 +48,8 @@ def make_map():
|
||||
map.connect('/archive/{year}/{month}/{day}', controller='blog', action='archive')
|
||||
map.connect('/archive/{year}/{month}/{day}/{url}', controller='blog', action='view')
|
||||
|
||||
map.connect('/tag/{id}', controller='blog', action='tag')
|
||||
|
||||
map.connect('/{controller}/{action}')
|
||||
map.connect('/{controller}/{action}/{id}')
|
||||
|
||||
|
@ -25,7 +25,7 @@ from datetime import datetime
|
||||
|
||||
from scribeengine.lib.base import *
|
||||
from scribeengine.lib import utils
|
||||
from scribeengine.model import Post, Comment
|
||||
from scribeengine.model import Post, Comment, Tag
|
||||
from scribeengine.model.meta import Session
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -71,6 +71,15 @@ class BlogController(BaseController):
|
||||
c.page_title = c.post.title
|
||||
return render(u'/blog/view.mako')
|
||||
|
||||
def tag(self, id=None):
|
||||
if not id:
|
||||
h.redirect_to('/')
|
||||
c.tag = Session.query(Tag).filter_by(url=id).first()
|
||||
if not c.tag:
|
||||
h.redirect_to('/')
|
||||
c.page_title = u'Blog posts with tag: %s' % c.tag.name
|
||||
return render('/blog/tag.mako')
|
||||
|
||||
@authenticate()
|
||||
def comment_POST(self, id):
|
||||
if not id:
|
||||
|
@ -125,7 +125,7 @@ ScribeEngine.Namespace.create("ScribeEngine.Widgets", {
|
||||
},
|
||||
tagEditor: function (selector)
|
||||
{
|
||||
$(selector).tagEditor({confirmRemoval: true, completeOnBlur: true, initialParse: true});
|
||||
$(selector).tagEditor({completeOnBlur: true, initialParse: true});
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -16,9 +16,6 @@ body {
|
||||
color: #999999;
|
||||
}
|
||||
|
||||
h1, h2, h3 {
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 3em;
|
||||
}
|
||||
@ -29,7 +26,7 @@ h2 {
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1em;
|
||||
font-size: 1.5em;
|
||||
}
|
||||
|
||||
p, ul, ol, pre {
|
||||
@ -141,6 +138,11 @@ hr {
|
||||
width: 605px;
|
||||
}
|
||||
|
||||
.title {
|
||||
border-bottom: 1px solid #454545;
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
.post {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
@ -198,7 +200,7 @@ hr {
|
||||
|
||||
#comments,
|
||||
#respond {
|
||||
font-size: 1.5em;
|
||||
/*font-size: 1.5em;*/
|
||||
margin-top: 1.8em;
|
||||
}
|
||||
|
||||
@ -224,6 +226,36 @@ hr {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
/* Tags */
|
||||
|
||||
.tags {
|
||||
margin-top: 1.8em;
|
||||
}
|
||||
|
||||
.tags p {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tags ul {
|
||||
margin: 4px 0 4px 10px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.tags ul li {
|
||||
background-color: #454545;
|
||||
cursor: pointer;
|
||||
display: inline;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 2px 6px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
}
|
||||
|
||||
.tags ul li a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Sidebar */
|
||||
|
||||
#sidebar {
|
||||
@ -430,6 +462,7 @@ fieldset {
|
||||
.tagEditor li:hover
|
||||
{
|
||||
background-color: #eee;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
/* Miscellaneous Styles */
|
||||
|
@ -1,5 +1,5 @@
|
||||
<%inherit file="/base.mako"/>
|
||||
<%include file="/flash.mako"/>
|
||||
<%include file="/flash.mako"/>
|
||||
% for post in c.posts:
|
||||
<div class="post">
|
||||
<h2 class="title"><a href="${h.url_for_post(post)}">${post.title}</a></h2>
|
||||
|
22
scribeengine/templates/blog/tag.mako
Normal file
22
scribeengine/templates/blog/tag.mako
Normal file
@ -0,0 +1,22 @@
|
||||
<%inherit file="/base.mako"/>
|
||||
<%include file="/flash.mako"/>
|
||||
<h2 class="title">Blog posts with tag: ${c.tag.name}</h2>
|
||||
% for post in c.tag.posts:
|
||||
<div class="post">
|
||||
<h3 class="title"><a href="${h.url_for_post(post)}">${post.title}</a></h3>
|
||||
<div class="entry">
|
||||
${h.literal(h.teaser(post.body, h.url_for_post(post)))}
|
||||
</div>
|
||||
<p class="meta">
|
||||
<span class="byline">Posted by ${post.user.nick} on ${post.created.strftime('%B %d, %Y')}</span>
|
||||
<a href="${h.url_for_post(post)}" class="read-more">Read more</a>
|
||||
% if len(post.comments) == 0:
|
||||
<a href="${h.url_for_post(post)}#comments" class="comments">No comments</a>
|
||||
% elif len(post.comments) == 1:
|
||||
<a href="${h.url_for_post(post)}#comments" class="comments">1 comment</a>
|
||||
% else:
|
||||
<a href="${h.url_for_post(post)}#comments" class="comments">${len(post.comments)} comments</a>
|
||||
% endif
|
||||
</p>
|
||||
</div>
|
||||
% endfor
|
@ -6,11 +6,16 @@
|
||||
<div class="entry">
|
||||
${h.literal(c.post.body)}
|
||||
</div>
|
||||
% if c.post.tags:
|
||||
<div class="tags">
|
||||
<p>Filed under:</p>
|
||||
<ul>
|
||||
% for tag in c.post.tags:
|
||||
<a href="/tag/${tag.url}">${tag.name}</a>
|
||||
<li><a href="/tag/${tag.url}">${tag.name}</a></li>
|
||||
% endfor
|
||||
</ul>
|
||||
</div>
|
||||
% endif
|
||||
% if len(c.post.comments) == 0:
|
||||
<h3 id="comments">No Responses</h3>
|
||||
% elif len(c.post.comments) == 1:
|
||||
|
Reference in New Issue
Block a user