コード例 #1
0
ファイル: views.py プロジェクト: limeburst/yak
def settings():
    if request.method == 'POST':
        for key in request.form:
            if not request.form[key]:
                flash(MSG_SETTINGS_FILL)
                g.blog = request.form
                return render_template('settings.html')
        write_config(blog_dir, request.form)
        g.blog = read_config(blog_dir)
        flash(MSG_SETTINGS_SAVED)
    return render_template('settings.html')
コード例 #2
0
ファイル: __init__.py プロジェクト: limeburst/yak
def init(blog_dir, config=DEFAULT_CONFIG):
    if not os.path.exists(blog_dir):
        os.makedirs(blog_dir)
    dirs = [
            ('drafts', []),
            ('static', ['style.css', 'favicon.ico']),
            ('publish', ['2012-07-20-yak.md']),
            ('templates', ['base.html', 'index.html', 'post.html',
                'archive.html', 'atom.xml']),
            ]
    try:
        write_config(blog_dir, config)
        for dir in dirs:
            os.mkdir(os.path.join(blog_dir, dir[0]))
            for file in dir[1]:
                with open(os.path.join(blog_dir, dir[0], file), 'w') as f:
                    f.write(get_data('yak', os.path.join('data', file)))
    except OSError:
        print "Directory {} is not empty. Abort.".format(blog_dir)
    else:
        print ("Basic Yak blog structure has been created in '{}'\n"
               "Be sure to edit the config.py file.".format(blog_dir))