Esempio n. 1
0
def add_comments(generator, content):
    try:
        # the article unique id is its relative source path,
        # so the comments are not dependant on the URL.
        source_path = content.get_relative_source_path()
        article_uuid = source_path.encode('utf8')
        thread = ArticleThread(storage_dir, article_uuid)
        thread = thread.asjson()

        for comment in thread['comments']:
            html = rst2html(comment['text'], theme='acr', body_only=True)
            comment['html'] = html

        content.metadata["comments"] = thread
    except:
        # XXX for some reason Pelican does not print plugins exceptions
        traceback.print_exc()
        raise
Esempio n. 2
0
 def test_empty_commemts(self):
     tempdir = self.get_tempdir()
     ath = ArticleThread(tempdir)
     self.assertEquals(ath.asjson()["comments"], [])
     self.assertEquals(len(ath.render().split("\n")), 1)