コード例 #1
0
ファイル: comments.py プロジェクト: AcrDijon/henet
    def add_summary(comment):
        if len(comment.text) > 20:
            comment.summary = comment.text[:20] + '...'
        else:
            comment.summary = comment.text

        comment.html = rst2html(comment.text, theme='acr', body_only=True)
        return comment
コード例 #2
0
ファイル: henet_comments.py プロジェクト: AcrDijon/henet
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