Exemple #1
0
def feed(**kw):
    '''
    Generate rss feed.
    '''
    host = kw['request'].host_url
    options = store.get_settings(blog.GROUP_OPTIONS)
    blog.update_default_settings(options)
    title = options[blog.FEED_TITLE]
    description = 'Subscribe RSS feed'
    hub = 'http://pubsubhubbub.appspot.com'
    link = options[blog.FEED_PROXY] or ('%s/blog/feed' % host)
    max = int(options[blog.FEED_ITEMS])
    posts, cursor = model.get_posts(limit=max)
    response = kw['response']
    response.content_type = 'application/rss+xml'
    response.charset = 'utf8'
    out = response.out
    out.write(r'''<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
  <channel>
    <atom:link rel="hub" href="%s"/>
    <title>%s</title>
    <link>%s</link>
    <description>%s</description>
    <generator>expressme.org</generator>
    <language>en</language>''' % (hub, title, link, description))
    for post in posts:
        out.write(r'''
    <item>
      <title>%s</title>
      <link>%s/blog/post/%s</link>
      <dc:creator>%s</dc:creator>
      <pubDate>%s</pubDate>
      <description><![CDATA[%s]]></description>
    </item>''' % (
            post.title,
            host,
            post.id,
            post.author,
            post.creation_date.strftime('%a, %d %b %Y %H:%M:%S'),
            post.content
    ))
    out.write(r'''
  </channel>
</rss>
''')
Exemple #2
0
def feed(**kw):
    '''
    Generate rss feed.
    '''
    host = kw['request'].host_url
    options = store.get_settings(blog.GROUP_OPTIONS)
    blog.update_default_settings(options)
    title = options[blog.FEED_TITLE]
    description = 'Subscribe RSS feed'
    hub = 'http://pubsubhubbub.appspot.com'
    link = options[blog.FEED_PROXY] or ('%s/blog/feed' % host)
    max = int(options[blog.FEED_ITEMS])
    posts, cursor = model.get_posts(limit=max)
    response = kw['response']
    response.content_type = 'application/rss+xml'
    response.charset = 'utf8'
    out = response.out
    out.write(r'''<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/">
  <channel>
    <atom:link rel="hub" href="%s"/>
    <title>%s</title>
    <link>%s</link>
    <description>%s</description>
    <generator>expressme.org</generator>
    <language>en</language>''' % (hub, title, link, description))
    for post in posts:
        out.write(r'''
    <item>
      <title>%s</title>
      <link>%s/blog/post/%s</link>
      <dc:creator>%s</dc:creator>
      <pubDate>%s</pubDate>
      <description><![CDATA[%s]]></description>
    </item>''' % (post.title, host, post.id, post.author,
                  post.creation_date.strftime('%a, %d %b %Y %H:%M:%S'),
                  post.content))
    out.write(r'''
  </channel>
</rss>
''')
Exemple #3
0
def _options(user, app, context):
    info = ''
    if context.method=='post':
        feed_title = context.get_argument(blog.FEED_TITLE)
        feed_proxy = context.get_argument(blog.FEED_PROXY)
        feed_items = context.get_argument(blog.FEED_ITEMS)
        show_abstract = context.get_argument(blog.SHOW_ABSTRACT)
        # save:
        store.set_setting(blog.FEED_TITLE, feed_title, blog.GROUP_OPTIONS)
        store.set_setting(blog.FEED_PROXY, feed_proxy, blog.GROUP_OPTIONS)
        store.set_setting(blog.FEED_ITEMS, feed_items, blog.GROUP_OPTIONS)
        store.set_setting(blog.SHOW_ABSTRACT, show_abstract, blog.GROUP_OPTIONS)
        info = 'Your options are saved.'
    # load options:
    options = store.get_settings(blog.GROUP_OPTIONS)
    blog.update_default_settings(options)
    return {
            '__view__' : 'manage_option',
            'options' : options,
            'info' : info,
    }
Exemple #4
0
def _options(user, app, context):
    info = ''
    if context.method == 'post':
        feed_title = context.get_argument(blog.FEED_TITLE)
        feed_proxy = context.get_argument(blog.FEED_PROXY)
        feed_items = context.get_argument(blog.FEED_ITEMS)
        show_abstract = context.get_argument(blog.SHOW_ABSTRACT)
        # save:
        store.set_setting(blog.FEED_TITLE, feed_title, blog.GROUP_OPTIONS)
        store.set_setting(blog.FEED_PROXY, feed_proxy, blog.GROUP_OPTIONS)
        store.set_setting(blog.FEED_ITEMS, feed_items, blog.GROUP_OPTIONS)
        store.set_setting(blog.SHOW_ABSTRACT, show_abstract,
                          blog.GROUP_OPTIONS)
        info = 'Your options are saved.'
    # load options:
    options = store.get_settings(blog.GROUP_OPTIONS)
    blog.update_default_settings(options)
    return {
        '__view__': 'manage_option',
        'options': options,
        'info': info,
    }