Exemplo n.º 1
0
Arquivo: app.py Projeto: insom/blag
 def rss():
     c = current_app.config
     f = DefaultFeed(title=c['BLAG_TITLE'], link=url_for('index', _external=True),
         author_name=c['BLAG_AUTHOR'], feed_url=url_for('rss', _external=True),
         description=c['BLAG_DESCRIPTION'], language='en')
     latest = sorted(articles, reverse=True,
                     key=lambda p: p.meta['published'])
     for late in latest[:3]:
         d = datetime.strptime(late.meta['published'], '%Y-%m-%d %H:%M:%S %Z')
         f.add_item(late.meta['title'], url_for('page', path=late.path, _external=True), late.html, unique_id=url_for('page', path=late.path, _external=True), pubdate=d)
     return f.writeString('UTF-8'), 200, {'Content-Type': 'application/rss+xml'}
Exemplo n.º 2
0
def removed_feed():
    """
    Legacy feed for Drupal comment feed

    Adds a single entry indicating the feed is no longer in use.
    """
    title = '%s: Deprecated Feed' % config.SITE_NAME
    description = 'This feed has been deprecated and no longer exists.'
    feed_url = config.SITE_BASE + 'crss'
    feed = Feed(title, config.SITE_BASE, description, feed_url=feed_url,
        feed_guid=feed_url, feed_copyright=u'(c) Copyright 2012, Caleb Brown')
    feed.add_item('This RSS feed no longer exists', config.SITE_BASE,
        'This feed no longer exists. But calebbrown.id.au is still '
        'alive and kicking. Please visit the hompage to see what\'s new.')
    response.content_type = 'application/rss+xml; charset=utf-8'
    return feed.writeString('utf-8')
Exemplo n.º 3
0
def blog_feed(name='list_all'):
    """
    Feed generation for the blog
    """
    index_name = 'blog' if name == 'list_all' else 'blog_%s' % name
    docs = manager.list(index_name)[:20]

    channel_name = 'All' if name == 'list_all' else name.title()
    title = "%s: %s Blog Posts" % (config.SITE_NAME, channel_name)
    description = title
    feed_url = config.SITE_BASE + 'feed' + ('' if name == 'list_all' else '/channel/' + name)

    feed = Feed(title, config.SITE_BASE, description, feed_url=feed_url,
        feed_guid=feed_url, feed_copyright=u'(c) Copyright 2012, Caleb Brown')

    for doc in docs:
        feed.add_item(doc.title, config.SITE_BASE + 'blog/' + doc.path,
            doc.render_body(), pubdate=doc.publish_on,
            unique_id='blog/' + doc.path)

    response.content_type = 'application/rss+xml; charset=utf-8'
    return feed.writeString('utf-8')