Exemple #1
0
def commit_page(slug):
    content = request.POST['content']
    message = "%s changed via web interface" % unquote(slug)
    name = request.auth[0]
    email = config.get('emails', name)

    post = Post(repository_path, unquote(slug))
    if post.content != content:
        post.update_content(content, name, email, message)
    redirect(url('post', slug=slug))
Exemple #2
0
def create_page():
    content = request.POST['content']
    filename = helpers.generate_slug(content)

    post = Post(repository_path, filename)
    if post.exists:
        for i in count(start=2):
            alternate_filename = '%s-%s' % (filename, i)
            post = Post(repository_path, alternate_filename)
            print i, alternate_filename
            if not post.exists:
                break
        filename = alternate_filename

    message = "%s created via web interface" % unquote(filename)
    name = request.auth[0]
    email = config.get('emails', name)
    post.update_content(content, name, email, message)
    redirect(url('/posts/:slug', slug=filename))