Пример #1
0
    def get_index_feed(self, uri, path):
        articles, _ = api.get_articles(tags=self.tag_ids,
                                       tags_exclude=self.excluded_tags)

        feed = feeds.build_feed(
            uri=uri,
            path=path,
            title=self.blog_title,
            description=self.feed_description,
            articles=articles,
        )

        return feed.rss_str()
Пример #2
0
    def get_topic_feed(self, topic_slug, uri, path):
        tag = api.get_tag_by_slug(topic_slug)

        if not tag:
            return None

        articles, _ = api.get_articles(tags=[tag["id"]],
                                       tags_exclude=self.excluded_tags)

        title = f"{tag['name']} - {self.blog_title}"
        feed = feeds.build_feed(
            uri=uri,
            path=path,
            title=title,
            description=self.feed_description,
            articles=articles,
        )

        return feed.rss_str()
    def get_author_feed(self, username, uri, path):
        author = api.get_user_by_username(username)

        if not author:
            return None

        articles, _ = api.get_articles(
            tags=self.tag_ids,
            tags_exclude=self.excluded_tags,
            author=author["id"],
        )

        title = f"{author['name']} - {self.blog_title}"
        feed = feeds.build_feed(
            uri=uri,
            title=title,
            path=path,
            description=self.feed_description,
            articles=articles,
        )

        return feed.rss_str()
    def get_group_feed(self, group_slug, uri, path):
        group = api.get_group_by_slug(group_slug)

        if not group:
            return None

        articles, _ = api.get_articles(
            tags=self.tag_ids,
            tags_exclude=self.excluded_tags,
            groups=[group.get("id", "")],
        )

        title = f"{group['name']} - {self.blog_title}"
        feed = feeds.build_feed(
            uri=uri,
            path=path,
            title=title,
            description=self.feed_description,
            articles=articles,
        )

        return feed.rss_str()