How to use the feedgenerator.Rss201rev2Feed function in feedgenerator

To help you get started, we’ve selected a few feedgenerator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github saimn / sigal / sigal / plugins / feeds.py View on Github external
def generate_feed(gallery, medias, feed_type=None, feed_url='', nb_items=0):
    root_album = gallery.albums['.']
    cls = Rss201rev2Feed if feed_type == 'rss' else Atom1Feed
    feed = cls(
        title=Markup.escape(root_album.title),
        link='/',
        feed_url=feed_url,
        description=Markup.escape(root_album.description).striptags()
    )

    theme = gallery.settings['theme']
    nb_medias = len(medias)
    nb_items = min(nb_items, nb_medias) if nb_items > 0 else nb_medias
    base_url = feed_url.rsplit('/', maxsplit=1)[0]

    for item in medias[:nb_items]:
        if theme == 'galleria':
            link = '%s/%s/#%s' % (base_url, item.path, item.url)
        else:
github magnunleno / pelican-podcast-feed / pelican_podcast_feed.py View on Github external
'itunes:summary',
    'itunes:image',
    'enclosure',
    'description',
    'link',
    'guid',
    'pubDate',
    'itunes:duration',
    )

DEFAULT_ITEM_ELEMENTS = {}
for key in ITEM_ELEMENTS:
    DEFAULT_ITEM_ELEMENTS[key] = None


class PodcastFeed(Rss201rev2Feed):
    """Helper class which generates the XML based in the global settings"""
    def __init__(self, *args, **kwargs):
        """Nice method docstring goes here"""
        super(PodcastFeed, self).__init__(*args, **kwargs)

    def set_settings(self, settings):
        """Helper function which just receives the podcast settings.
        :param settings: A dictionary with all the site settings.
        """
        self.settings = settings

    def rss_attributes(self):
        """Returns the podcast feed's attributes.

        :return: A dictionary containing the feed's attributes.
        """
github SamR1 / python-twootfeed / twootfeed / utils / feed_generation.py View on Github external
def generate_feed(title, link, param, description=None):

    return feedgenerator.Rss201rev2Feed(
        title=title,
        link=link,
        description=(description if description
                     else param['twitter']['description']),
        language=param['feed']['language'],
        author_name=param['feed']['author_name'],
        feed_url=param['feed']['feed_url'])
github cristoper / feedmixer / feedmixer.py View on Github external
def rss_feed(self) -> str:
        """
        Returns:
            An RSS 2 feed consisting of the `num_keep` most recent entries from
            each of the `feeds`.
        """
        return self.__generate_feed(Rss201rev2Feed).writeString('utf-8')
github hackncast / hackncast / .plugins / pelican-podcast-feed / pelican_podcast_feed.py View on Github external
'itunes:summary',
    'itunes:image',
    'enclosure',
    'description',
    'link',
    'guid',
    'pubDate',
    'itunes:duration',
    )

DEFAULT_ITEM_ELEMENTS = {}
for key in ITEM_ELEMENTS:
    DEFAULT_ITEM_ELEMENTS[key] = None


class PodcastFeed(Rss201rev2Feed):
    """Helper class which generates the XML based in the global settings"""
    def __init__(self, *args, **kwargs):
        """Nice method docstring goes here"""
        super(PodcastFeed, self).__init__(*args, **kwargs)

    def set_settings(self, settings):
        """Helper function which just receives the podcast settings.
        :param settings: A dictionary with all the site settings.
        """
        self.settings = settings

    def rss_attributes(self):
        """Returns the podcast feed's attributes.

        :return: A dictionary containing the feed's attributes.
        """
github neurodebian / neurodebian / sphinx / sphinxext / feed / __init__.py View on Github external
'description': app.config.feed_description,
      'categories': app.config.feed_categories,
      'author_name': app.config.feed_author_name,
      'author_email': app.config.feed_author_email
    }
    if app.config.language:
        feed_dict['language'] = app.config.language
    if app.config.copyright:
        feed_dict['feed_copyright'] = app.config.copyright
    # sort items
    ordered_keys = feed_entries.keys()
    ordered_keys.sort(reverse=True)
    # loop over all feed variants
    for feedvar in app.config.feed_variants:
        feedvar_settings = app.config.feed_variants[feedvar]
        feed = feedgenerator.Rss201rev2Feed(**feed_dict)
        app.builder.env.feed_feed = feed
        for key in ordered_keys:
            item = feed_entries[key]
            # only take the ones that should be in this feed
            if feedvar_settings['tag'] is None \
                    or feedvar_settings['tag'] in item['categories']:
                feed.add_item(**feed_entries[key])
        outfilename = os.path.join(app.builder.outdir,
          feedvar_settings['filename'])
        # make sure the directory exists
        feed_dir = os.path.dirname(outfilename)
        if feed_dir and not os.path.exists(feed_dir):
            os.makedirs(os.path.dirname(outfilename))
        fp = open(outfilename, 'w')
        feed.write(fp, 'utf-8')
        fp.close()
github tylerbutler / engineer / engineer / commands / bundled.py View on Github external
# Generate tag pages
        if num_posts > 0:
            tags_output_path = settings.OUTPUT_CACHE_DIR / 'tag'
            for tag in all_posts.all_tags:
                rendered_tag_page = all_posts.render_tag_html(tag, all_posts)
                tag_path = ensure_exists(
                    tags_output_path / slugify(tag) / 'index.html')
                with open(tag_path, mode='wb', encoding='UTF-8') as the_file:
                    the_file.write(rendered_tag_page)
                    build_stats['counts']['tag_pages'] += 1
                    logger.debug("Output %s." % relpath(the_file.name))

        # Generate feeds
        rss_feed_output_path = ensure_exists(settings.OUTPUT_CACHE_DIR / 'feeds/rss.xml')
        atom_feed_output_path = ensure_exists(settings.OUTPUT_CACHE_DIR / 'feeds/atom.xml')
        rss_feed = Rss201rev2Feed(
            title=settings.FEED_TITLE,
            link=settings.SITE_URL,
            description=settings.FEED_DESCRIPTION,
            feed_url=settings.FEED_URL
        )

        atom_feed = Atom1Feed(
            title=settings.FEED_TITLE,
            link=settings.SITE_URL,
            description=settings.FEED_DESCRIPTION,
            feed_url=settings.FEED_URL
        )

        for feed in (rss_feed, atom_feed):
            for post in all_posts[:settings.FEED_ITEM_LIMIT]:
                title = settings.JINJA_ENV.get_template('core/feeds/title.jinja2').render(post=post)
github tylerbutler / engineer / engineer / engine.py View on Github external
# Generate tag pages
    if num_posts > 0:
        tags_output_path = settings.OUTPUT_CACHE_DIR / 'tag'
        for tag in all_posts.all_tags:
            rendered_tag_page = all_posts.render_tag_html(tag, all_posts)
            tag_path = ensure_exists(
                tags_output_path / slugify(tag) / 'index.html')
            with open(tag_path, mode='wb', encoding='UTF-8') as the_file:
                the_file.write(rendered_tag_page)
                build_stats['counts']['tag_pages'] += 1
                logger.debug("Output %s." % relpath(the_file.name))

    # Generate feeds
    rss_feed_output_path = ensure_exists(settings.OUTPUT_CACHE_DIR / 'feeds/rss.xml')
    atom_feed_output_path = ensure_exists(settings.OUTPUT_CACHE_DIR / 'feeds/atom.xml')
    rss_feed = Rss201rev2Feed(
        title=settings.FEED_TITLE,
        link=settings.SITE_URL,
        description=settings.FEED_DESCRIPTION,
        feed_url=settings.FEED_URL
    )

    atom_feed = Atom1Feed(
        title=settings.FEED_TITLE,
        link=settings.SITE_URL,
        description=settings.FEED_DESCRIPTION,
        feed_url=settings.FEED_URL
    )

    for feed in (rss_feed, atom_feed):
        for post in all_posts[:settings.FEED_ITEM_LIMIT]:
            title = settings.JINJA_ENV.get_template('core/feeds/title.jinja2').render(post=post)