Esempio n. 1
0
 def load_comments(post_id):
     post_q = meta.Session.query(model.Post)
     c.post = post_id and post_q.filter(and_(model.Post.id==int(post_id), 
                                             model.Post.draft==False)).first() or None
     if c.post is None:
         abort(404)
     comments_q = meta.Session.query(model.Comment).filter(and_(model.Comment.post_id==int(c.post.id), 
                                                                model.Comment.approved==True))
     comments_q = comments_q.order_by(model.comments_table.c.created_on.desc()).limit(10)
     
     feed = Atom1Feed(
         title=h.wurdig_title() + u' - ' + c.post.title,
         subtitle=_(u'Most Recent Comments'),
         link=u'http://%s%s' % (request.environ['HTTP_HOST'], h.url_for(
                 controller='post', 
                 action='view', 
                 year=c.post.posted_on.strftime('%Y'), 
                 month=c.post.posted_on.strftime('%m'), 
                 slug=c.post.slug
             )),
         description=_(u'Most recent comments for %s') % c.post.title,
         language=u'en',
     )
     
     comment_meta = u"""
     <p style="margin: 0px; padding: 5px 15px 5px 15px; border: 1px solid #000">
     %s %s</p>
     """ % (_('Posted in'), '<a href="%s">%s</a>')
     
     for comment in comments_q:
         post_link=u'http://%s%s' % (request.environ['HTTP_HOST'], h.url_for(
             controller='post', 
             action='view', 
             year=c.post.posted_on.strftime('%Y'), 
             month=c.post.posted_on.strftime('%m'), 
             slug=c.post.slug
         ))
         comment_link=post_link + u'#comment-' + str(comment.id)
         
         feed.add_item(
             title=_(u'Comment from %s') % comment.name,
             link=comment_link,
             unique_id=comment_link,
             author_name=comment.name,
             author_link=comment.url,
             pubdate=comment.created_on,
             description=comment.content + comment_meta % (post_link, c.post.title)
         )
     return feed.writeString('utf-8')
Esempio n. 2
0
 def feeds(self):
     
     posts_q = meta.Session.query(model.Post).filter(
         model.Post.draft == False
     ).order_by([model.Post.posted_on.desc()]).limit(10)
     
     feed = Atom1Feed(
         title=config['blog.title'],
         subtitle=config['blog.subtitle'],
         link=u"http://%s" % request.server_name,
         description=u"Most recent posts for %s" % config['blog.title'],
         language=u"en",
     )
     
     for post in posts_q:
         tags = [tag.name for tag in post.tags]
         feed.add_item(
             title=post.title,
             link=u'http://%s%s' % (request.server_name, h.url_for(
                 controller='post', 
                 action='view', 
                 year=post.posted_on.strftime('%Y'), 
                 month=post.posted_on.strftime('%m'), 
                 slug=post.slug
             )),
             description=post.content,
             categories=tuple(tags)
         )
             
     response.content_type = 'application/atom+xml'
     return feed.writeString('utf-8')
Esempio n. 3
0
 def load_posts_sitemap():
     feed = Atom1Feed(
         title=_(u"%s - All Posts") % h.wurdig_title(),
         subtitle=h.wurdig_subtitle(),
         link=u'http://%s' % request.environ['HTTP_HOST'],
         description=_(u"All posts for %s") % h.wurdig_title(),
         language=u'en',
     )
     
     posts_q = meta.Session.query(model.Post).filter(
         model.Post.draft == False
     ).order_by([model.Post.posted_on.desc()])
 
     for post in posts_q:
         tags = [tag.name for tag in post.tags]
         feed.add_item(
             title=post.title,
             link=u'http://%s%s' % (request.environ['HTTP_HOST'], h.url_for(
                 controller='post', 
                 action='view', 
                 year=post.posted_on.strftime('%Y'), 
                 month=post.posted_on.strftime('%m'), 
                 slug=post.slug
             )),
             description=post.content,
             pubdate=post.posted_on,
             categories=tuple(tags)
         )
     return feed.writeString('utf-8')
Esempio n. 4
0
 def feeds(self):   
     comments_q = meta.Session.query(model.Comment).filter(model.Comment.approved==True)
     comments_q = comments_q.order_by(model.comments_table.c.created_on.desc()).limit(20)
     
     feed = Atom1Feed(
         title=u"Comments for " + h.wurdig_title(),
         subtitle=h.wurdig_subtitle(),
         link=u'http://%s' % request.server_name,
         description=h.wurdig_subtitle(),
         language=u"en",
     )
     
     for comment in comments_q:
         post_q = meta.Session.query(model.Post)
         c.post = comment.post_id and post_q.filter_by(id=int(comment.post_id)).first() or None
         if c.post is not None:
             feed.add_item(
                 title=u"Comment on %s" % c.post.title,
                 link=u'http://%s%s' % (request.server_name, h.url_for(
                     controller='post', 
                     action='view', 
                     year=c.post.posted_on.strftime('%Y'), 
                     month=c.post.posted_on.strftime('%m'), 
                     slug=c.post.slug,
                     anchor=u"comment-" + str(comment.id)
                 )),
                 description=comment.content
             )
             
     response.content_type = 'application/atom+xml'
     return feed.writeString('utf-8')
Esempio n. 5
0
    def tag_feed(self, slug=None):
        if slug is None:
            abort(404)
        tag_q = meta.Session.query(model.Tag)
        c.tag = tag_q.filter(model.Tag.slug==slug).first()
        
        if(c.tag is None):
            c.tagname = slug
        else:
            c.tagname = c.tag.name
            
        posts_q = meta.Session.query(model.Post).filter(
            and_(
                 model.Post.tags.any(slug=slug), 
                 model.Post.draft == False 
            )
        ).order_by([model.Post.posted_on.desc()]).limit(10)

        feed = Atom1Feed(
            title=config['blog.title'],
            subtitle=u'Blog posts tagged "%s"' % slug,
            link=u"http://%s%s" % (request.server_name, h.url_for(
                controller='tag',
                action='archive',
                slug=slug
            )),
            description=u"Blog posts tagged %s" % slug,
            language=u"en",
        )
        
        for post in posts_q:
            tags = [tag.name for tag in post.tags]
            feed.add_item(
                title=post.title,
                link=u'http://%s%s' % (request.server_name, h.url_for(
                    controller='post', 
                    action='view', 
                    year=post.posted_on.strftime('%Y'), 
                    month=post.posted_on.strftime('%m'), 
                    slug=post.slug
                )),
                description=post.content,
                categories=tuple(tags)
            )
                
        response.content_type = 'application/atom+xml'
        return feed.writeString('utf-8')
Esempio n. 6
0
 def post_comment_feed(self, post_id=None):
     if post_id is None:
         abort(404)
     
     post_q = meta.Session.query(model.Post)
     c.post = post_id and post_q.filter(and_(model.Post.id==int(post_id), 
                                             model.Post.draft==False)).first() or None
     if c.post is None:
         abort(404)
     comments_q = meta.Session.query(model.Comment).filter(and_(model.Comment.post_id==c.post.id, 
                                                                model.Comment.approved==True))
     comments_q = comments_q.order_by(model.comments_table.c.created_on.desc()).limit(10)
     
     feed = Atom1Feed(
         title=h.wurdig_title() + u' - ' + c.post.title,
         subtitle=u'Most Recent Comments',
         link=u'http://%s%s' % (request.server_name, h.url_for(
                 controller='post', 
                 action='view', 
                 year=c.post.posted_on.strftime('%Y'), 
                 month=c.post.posted_on.strftime('%m'), 
                 slug=c.post.slug
             )),
         description=u"Most recent comments for %s" % c.post.title,
         language=u"en",
     )
     
     for comment in comments_q:
         feed.add_item(
             title=c.post.title + u" comment #%s" % comment.id,
             link=u'http://%s%s' % (request.server_name, h.url_for(
                 controller='post', 
                 action='view', 
                 year=c.post.posted_on.strftime('%Y'), 
                 month=c.post.posted_on.strftime('%m'), 
                 slug=c.post.slug,
                 anchor=u'comment-' + str(comment.id)
             )),
             description=comment.content
         )
             
     response.content_type = 'application/atom+xml'
     return feed.writeString('utf-8')
Esempio n. 7
0
     def load_tag_posts(slug):                
         posts_q = meta.Session.query(model.Post).filter(
             and_(
                  model.Post.tags.any(slug=slug), 
                  model.Post.draft == False 
             )
         ).order_by([model.Post.posted_on.desc()]).limit(10)
 
         feed = Atom1Feed(
             title=h.wurdig_title(),
             subtitle=_(u'Blog posts tagged "%s"') % slug,
             link=u"http://%s%s" % (request.environ['HTTP_HOST'], h.url_for(
                 controller='tag',
                 action='archive',
                 slug=slug
             )),
             description=_(u'Blog posts tagged %s') % slug,
             language=u'en',
         )
         
         for post in posts_q:
             tags = [tag.name for tag in post.tags]
             feed.add_item(
                 title=post.title,
                 link=u'http://%s%s' % (request.server_name, h.url_for(
                     controller='post', 
                     action='view', 
                     year=post.posted_on.strftime('%Y'), 
                     month=post.posted_on.strftime('%m'), 
                     slug=post.slug
                 )),
                 pubdate=post.posted_on,
                 description=post.content,
                 categories=tuple(tags)
             )
         return feed.writeString('utf-8')
Esempio n. 8
0
 def load_pages_sitemap():
     feed = Atom1Feed(
         title=_(u"%s - All Pages") % h.wurdig_title(),
         subtitle=h.wurdig_subtitle(),
         link=u'http://%s' % request.environ['HTTP_HOST'],
         description=_(u"All pages for %s") % h.wurdig_title(),
         language=u'en',
     )
     
     pages_q = meta.Session.query(model.Page).order_by([model.Page.created_on.desc()])
 
     for page in pages_q:
         feed.add_item(
             title=page.title,
             link=u'http://%s%s' % (request.environ['HTTP_HOST'], h.url_for(
                 controller='page', 
                 action='view', 
                 slug=page.slug
             )),
             description=page.content,
             pubdate=page.created_on
         )
     return feed.writeString('utf-8')
Esempio n. 9
0
 def signinagain(self):
     request.environ['paste.auth_tkt.logout_user']()
     return render('/derived/account/signin.html').replace('%s', h.url_for('signin'))
Esempio n. 10
0
 def signinagain(self):
     request.environ['paste.auth_tkt.logout_user']()
     return render('/derived/account/signin.html').replace('%s', h.url_for(controller='account', action='dashboard'))