Ejemplo n.º 1
0
def renderAll(srcDir, htmlDir):
    """Take all the blog posts in srcDir, render blog to htmlDir."""
    posts = Post.getAll(srcDir)

    # Render pages for each post
    for post in posts:
        filename = os.path.join(htmlDir, post.filename.replace('.md', '.html'))
        with open(filename, 'w') as f:
            print 'Generating', filename
            f.write(renderPost(post).encode('utf8'))

    # Render the various indexes
    print 'Generating index.html'
    with open(os.path.join(htmlDir, 'index.html'), 'w') as f:
        f.write(renderIndex(posts).encode('utf8'))
    print 'Generating RSS feed'
    with open(os.path.join(htmlDir, 'feed.xml'), 'w') as f:
        f.write(renderRSS(posts).encode('utf8'))

    # Copy over the whole static resource hierarchy (if any).
    if os.path.exists(os.path.join(srcDir, 'static')):
        print 'Copying static resources'
        shutil.copytree(os.path.join(srcDir, 'static'), os.path.join(htmlDir, 'static'))