Esempio n. 1
0
    def generate(self):
        md = markdown.Markdown()

        items = []
        for row in (Comment.select().where(
                Comment.published).order_by(-Comment.published).limit(10)):
            item_link = "%s://%s%s" % (self._rss_proto, self._site_url,
                                       row.url)
            items.append(
                PyRSS2Gen.RSSItem(
                    title="%s - %s://%s%s" % (self._rss_proto, row.author_name,
                                              self._site_url, row.url),
                    link=item_link,
                    description=md.convert(row.content),
                    guid=PyRSS2Gen.Guid("%s/%d" % (item_link, row.id)),
                    pubDate=row.published,
                ))

        rss_title = 'Commentaires du site "%s"' % self._site_name
        rss = PyRSS2Gen.RSS2(
            title=rss_title,
            link="%s://%s" % (self._rss_proto, self._site_url),
            description=rss_title,
            lastBuildDate=datetime.now(),
            items=items,
        )
        rss.write_xml(open(self._rss_file, "w"), encoding="utf-8")
Esempio n. 2
0
def count_published_comments(url):
    return (Comment.select(Comment).where(
        (Comment.url == url) & (Comment.published.is_null(False))).count()
            if url else Comment.select(Comment).where(
                Comment.published.is_null(False)).count())
Esempio n. 3
0
def find_published_comments_by_url(url):
    return (Comment.select(Comment).where((Comment.url == url) & (
        Comment.published.is_null(False))).order_by(+Comment.published))
Esempio n. 4
0
def find_not_published_comments():
    return Comment.select().where(Comment.published.is_null())
Esempio n. 5
0
def find_not_notified_comments():
    return Comment.select().where(Comment.notified.is_null())