Exemplo n.º 1
0
def create_feed_item(app, docname, templatename, ctx, doctree):
    """
    Here we have access to nice HTML fragments to use in, say, an RSS feed.
    We serialize them to disk so that we get them preserved across builds.
    
    We also inject useful metadata into the context here.
    """
    global feed_entries
    from absolutify_urls import absolutify
    env = app.builder.env
    metadata = env.metadata.get(docname, {})
    pub_date = get_date_for_article(env, docname)
    if not pub_date:
        return
    # RSS item attributes, w/defaults:
    #     title, link, description, author_email=None,
    #     author_name=None, author_link=None, pubdate=None, comments=None,
    #     unique_id=None, enclosure=None, categories=(), item_copyright=None,
    #     ttl=None,
    link = app.config.feed_base_url + '/' + ctx['current_page_name'] + ctx['file_suffix']
    item = {
      'title': ctx.get('title'),
      'link': link,
      'unique_id': link,
      'description': absolutify(ctx.get('body'), link),
      'pubdate': pub_date
    }
    if 'author' in metadata:
        item['author'] = metadata['author']
        
    feed_entries[dated_name(docname, pub_date)] = item
    
    #Now, useful variables to keep in context
    ctx['rss_link'] = app.builder.env.feed_url 
    ctx['pub_date'] = pub_date
Exemplo n.º 2
0
def create_feed_item(app, docname, templatename, ctx, doctree):
    """
    Here we have access to nice HTML fragments to use in, say, an RSS feed.
    We serialize them to disk so that we get them preserved across builds.
    
    We also inject useful metadata into the context here.
    """
    global feed_entries
    from absolutify_urls import absolutify
    env = app.builder.env
    metadata = env.metadata.get(docname, {})
    pub_date = get_date_for_article(env, docname)
    if not pub_date:
        return
    # RSS item attributes, w/defaults:
    #     title, link, description, author_email=None,
    #     author_name=None, author_link=None, pubdate=None, comments=None,
    #     unique_id=None, enclosure=None, categories=(), item_copyright=None,
    #     ttl=None,
    link = app.config.feed_base_url + '/' + ctx['current_page_name'] + ctx['file_suffix']
    item = {
      'title': ctx.get('title'),
      'link': link,
      'unique_id': link,
      'description': absolutify(ctx.get('body'), link),
      'pubdate': pub_date
    }
    if 'author' in metadata:
        item['author'] = metadata['author']
        
    feed_entries[dated_name(docname, pub_date)] = item
    
    #Now, useful variables to keep in context
    ctx['rss_link'] = app.builder.env.feed_url 
    ctx['pub_date'] = pub_date
Exemplo n.º 3
0
    except ValueError, exc:
        #probably a nonsensical date
        app.builder.warn('date parse error: ' + str(exc) + ' in ' + pagename)
        return

    # title, link, description, author_email=None,
    #     author_name=None, author_link=None, pubdate=None, comments=None,
    #     unique_id=None, enclosure=None, categories=(), item_copyright=None,
    #     ttl=None,
    link = app.config.feed_base_url + '/' + ctx['current_page_name'] + ctx[
        'file_suffix']
    item = {
        'title': ctx.get('title'),
        'link': link,
        'unique_id': link,
        'description': absolutify(ctx.get('body'), link),
        'pubdate': pub_date
    }
    if 'author' in metadata:
        item['author'] = metadata['author']
    feed_entries[nice_name(pagename, pub_date)] = item


def remove_dead_feed_item(app, env, docname):
    """
    TODO:
    purge unwanted crap
    """
    global feed_entries
    munged_name = ''.join([MAGIC_SEPARATOR, quote_plus(docname)])
    for name in feed_entries:
Exemplo n.º 4
0
    # RSS item attributes, w/defaults:
    #     title, link, description, author_email=None,
    #     author_name=None, author_link=None, pubdate=None, comments=None,
    #     unique_id=None, enclosure=None, categories=(), item_copyright=None,
    #     ttl=None,
    link = app.config.feed_base_url + '/' + ctx['current_page_name'] + ctx['file_suffix']
    # bring main body of the feed item into shape
    body = ctx.get('body')
    # remove all header links (they make ugly characters in feed readers)
    body = re.sub('\<a class\="headerlink".*\>.</a\>', '', body)

    item = {
      'title': ctx.get('title'),
      'link': link,
      'unique_id': link,
      'description': absolutify(body, link),
      'pubdate': pub_date,
      'categories': ()
    }
    if 'tags' in metadata:
        item['categories'] = metadata['tags'].split(",")
    if 'author' in metadata:
        item['author_name'] = metadata['author']
    else:
        item['author_name'] = app.config.feed_author_name
    if 'author_email' in metadata:
        item['author_email'] = metadata['author_email']
    else:
        item['author_email'] = app.config.feed_author_email
    feed_entries[nice_name(pagename, pub_date)] = item    
    
Exemplo n.º 5
0
        pub_date = date_parser.parse(metadata['date'])
    except ValueError, exc:
        #probably a nonsensical date
        app.builder.warn('date parse error: ' + str(exc) + ' in ' + pagename)
        return

    # title, link, description, author_email=None,
    #     author_name=None, author_link=None, pubdate=None, comments=None,
    #     unique_id=None, enclosure=None, categories=(), item_copyright=None,
    #     ttl=None,
    link = app.config.feed_base_url + '/' + ctx['current_page_name'] + ctx['file_suffix']
    item = {
      'title': ctx.get('title'),
      'link': link,
      'unique_id': link,
      'description': absolutify(ctx.get('body'), link),
      'pubdate': pub_date
    }
    if 'author' in metadata:
        item['author'] = metadata['author']
    feed_entries[nice_name(pagename, pub_date)] = item

def remove_dead_feed_item(app, env, docname):
    """
    TODO:
    purge unwanted crap
    """
    global feed_entries
    munged_name = ''.join([MAGIC_SEPARATOR,quote_plus(docname)])
    for name in feed_entries:
        if name.endswith(munged_name):
Exemplo n.º 6
0
    #     title, link, description, author_email=None,
    #     author_name=None, author_link=None, pubdate=None, comments=None,
    #     unique_id=None, enclosure=None, categories=(), item_copyright=None,
    #     ttl=None,
    link = app.config.feed_base_url + '/' + ctx['current_page_name'] + ctx[
        'file_suffix']
    # bring main body of the feed item into shape
    body = ctx.get('body')
    # remove all header links (they make ugly characters in feed readers)
    body = re.sub('\<a class\="headerlink".*\>.</a\>', '', body)

    item = {
        'title': ctx.get('title'),
        'link': link,
        'unique_id': link,
        'description': absolutify(body, link),
        'pubdate': pub_date,
        'categories': ()
    }
    if 'tags' in metadata:
        item['categories'] = metadata['tags'].split(",")
    if 'author' in metadata:
        item['author_name'] = metadata['author']
    else:
        item['author_name'] = app.config.feed_author_name
    if 'author_email' in metadata:
        item['author_email'] = metadata['author_email']
    else:
        item['author_email'] = app.config.feed_author_email
    feed_entries[nice_name(pagename, pub_date)] = item