Esempio n. 1
0
def wikihome():
    page = current_wiki.get('home')
    app.config['index_dict'] = current_wiki.index_dict()
    if page:
        return wikidisplay('home')
    return render_template('pages/wiki/home.html',
                           index_dict=app.config.get('index_dict', {}))
Esempio n. 2
0
def wikidisplay(url):
    page = current_wiki.get(url)
    if not page:
        return redirect(url_for('wikicreate', url=url))
    return render_template(
        'pages/wiki/page.html',
        page=page, index_dict=app.config.get('index_dict', {}))
Esempio n. 3
0
def wikidelete(url):
    page = current_wiki.get(url)
    if not page:
        return redirect(url_for('wikicreate', url=url))
    current_wiki.delete(url)
    flash(f'Wiki page "{page.title}" was deleted.', 'error')
    return redirect(url_for('wikihome'))
Esempio n. 4
0
def wikimove(url):
    page = current_wiki.get(url)
    if not page:
        return redirect(url_for('wikicreate', url=url))
    form = URLForm(obj=page)
    if form.validate_on_submit():
        newurl = form.url.data
        current_wiki.move(url, newurl)
        return redirect(url_for('wikidisplay', url=newurl))
    return render_template(
        'pages/wiki/move.html', form=form,
        page=page, index_dict=app.config.get('index_dict', {}))
Esempio n. 5
0
def wikiedit(url):
    page = current_wiki.get(url)
    form = EditorForm(obj=page)
    if form.validate_on_submit():
        submit = request.form.get('submit', None)
        if submit == 'Cancel':
            flash(f'Wiki page "{page.title}" was not changed', 'warning')
            return redirect(url_for('wikidisplay', url=url))
        if not page:
            page = current_wiki.get_bare(url)
        form.populate_obj(page)
        page.save()
        flash(f'Wiki page "{page.title}" was saved', 'success')
        return redirect(url_for('wikidisplay', url=url))
    return render_template(
        'pages/wiki/editor.html', form=form,
        page=page, index_dict=app.config.get('index_dict', {}))