Ejemplo n.º 1
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')
Ejemplo n.º 2
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')
Ejemplo n.º 3
0
 def load_comments():
     feed = Atom1Feed(
         title=_(u'Comments for %s') % h.wurdig_title(),
         subtitle=h.wurdig_subtitle(),
         link=u'http://%s' % request.environ['HTTP_HOST'],
         description=h.wurdig_subtitle(),
         language=u'en',
     )
     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)
 
     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_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:
             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')
Ejemplo n.º 4
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')