Exemple #1
0
def init():
    if request.method == 'GET':
        if g.blog:
            return redirect(url_for('dashboard'))
        else:
            g.blog = DEFAULT_CONFIG
            return render_template('init.html')
    elif request.method == 'POST':
        for key in request.form:
            if not request.form[key]:
                flash(MSG_SETTINGS_FILL)
                g.blog = request.form
                return render_template('init.html')

        from yak import init
        init(blog_dir, request.form)
        g.blog = read_config(blog_dir)

        hg_init(blog_dir)
        for post in publish():
            source = os.path.join(blog_dir, 'publish',  post)
            hg_add(source)
            hg_commit(source, 'new blog')

        bake_blog()
        flash(MSG_INIT_SUCCESS)
        return redirect(url_for('dashboard'))
Exemple #2
0
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')
Exemple #3
0
def bake(blog_dir):
    started = datetime.now()
    print "Reading started at {}".format(started)
    oven = get_posts(os.path.join(blog_dir, 'publish'))
    finished = datetime.now()
    delta = finished - started
    print "Reading finished at {}. Took {} seconds. Read {} post(s).".format(
            finished, delta.seconds, len(oven))

    print
    config = read_config(blog_dir)
    config['PATH'] = blog_dir
    blog = Blog(config, oven)

    started  = datetime.now()
    print "Baking started at {}".format(started)
    bake_blog(blog)
    finished = datetime.now()
    delta = finished - started
    print "Baking finished at {}. Took {} seconds.".format(
            finished, delta.seconds)
Exemple #4
0
def before_request():
    if os.path.exists(blog_dir):
        g.blog = read_config(blog_dir)
    else:
        g.blog = False