Example #1
0
File: app.py Project: 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'}
Example #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')
Example #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')
Example #4
0
#!/usr/bin/env python3

import datetime
from pathlib import Path
import re

from feedgenerator import DefaultFeed
import mistune

working_dir = Path('.')
feed = DefaultFeed(title="SR(A)WN",
                   link="https://studentrobotics.org/srawn/",
                   description="Student Robotics (Almost) Weekly Newsletter",
                   author_name="Student Robotics")
md = mistune.create_markdown()

for md_path in sorted(working_dir.glob("SR20*/*.md")):
    filename_match = re.match("^(20\d{2}-\d{2}-\d{2})-srawn-(\d{2})$",
                              md_path.stem)
    if not filename_match:
        exit(f"{md_path.stem} does not match format. Run the linter.")
    date, issue = filename_match.groups()

    folder_match = re.match("^(SR20\d{2})$", md_path.parent.name)
    if not folder_match:
        exit(f"{md_path.parent.name} does not match format. Run the linter.")
    sryear, = folder_match.groups()

    link = f"https://studentrobotics.org/srawn/{md_path.parent.stem}/{md_path.stem}.html"
    content = md(md_path.read_text())