updated wiki routes
This commit is contained in:
parent
d31930bf10
commit
a891e77d40
|
@ -213,13 +213,8 @@ for status_code in httplib.responses:
|
||||||
|
|
||||||
assets = Environment()
|
assets = Environment()
|
||||||
assets.init_app(app)
|
assets.init_app(app)
|
||||||
if config.ENV is 'PROD':
|
|
||||||
if 'js_common' not in assets._named_bundles:
|
|
||||||
assets.register('js_common', Bundle('packed-common.js'))
|
|
||||||
if 'js_editor' not in assets._named_bundles:
|
|
||||||
assets.register('js_editor', Bundle('packed-editor.js'))
|
|
||||||
else:
|
|
||||||
if 'js_common' not in assets._named_bundles:
|
|
||||||
js = Bundle(
|
js = Bundle(
|
||||||
Bundle('vendor/jquery/jquery.js',
|
Bundle('vendor/jquery/jquery.js',
|
||||||
'vendor/components-underscore/underscore.js',
|
'vendor/components-underscore/underscore.js',
|
||||||
|
@ -235,12 +230,12 @@ else:
|
||||||
output='packed-common.js')
|
output='packed-common.js')
|
||||||
assets.register('js_common', js)
|
assets.register('js_common', js)
|
||||||
|
|
||||||
if 'js_editor' not in assets._named_bundles:
|
|
||||||
js = Bundle('js/ace/ace.js',
|
js = Bundle('js/ace/ace.js',
|
||||||
'js/ace/mode-markdown.js',
|
'js/ace/mode-markdown.js',
|
||||||
'vendor/keymaster/keymaster.js',
|
'vendor/keymaster/keymaster.js',
|
||||||
'js/dillinger.js',
|
'js/dillinger.js',
|
||||||
filters='closure_js', output='packed-editor.js')
|
filters='closure_js', output='packed-editor.js')
|
||||||
|
|
||||||
assets.register('js_editor', js)
|
assets.register('js_editor', js)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,11 @@ def edit(name):
|
||||||
edit_cname = to_canonical(request.form['name'])
|
edit_cname = to_canonical(request.form['name'])
|
||||||
if edit_cname.lower() != cname.lower():
|
if edit_cname.lower() != cname.lower():
|
||||||
g.current_wiki.rename_page(cname, edit_cname)
|
g.current_wiki.rename_page(cname, edit_cname)
|
||||||
|
|
||||||
g.current_wiki.write_page(edit_cname,
|
g.current_wiki.write_page(edit_cname,
|
||||||
request.form['content'],
|
request.form['content'],
|
||||||
message=request.form['message'],
|
message=request.form['message'],
|
||||||
username=g.current_user.get('username'))
|
username=g.current_user.get('username'))
|
||||||
return redirect(url_for('wiki.page', name=edit_cname))
|
|
||||||
else:
|
else:
|
||||||
if data:
|
if data:
|
||||||
name = remove_ext(data['name'])
|
name = remove_ext(data['name'])
|
||||||
|
@ -70,12 +70,7 @@ def delete(name):
|
||||||
@blueprint.route("/wiki/_create/", defaults={'name': None}, methods=['GET', 'POST'])
|
@blueprint.route("/wiki/_create/", defaults={'name': None}, methods=['GET', 'POST'])
|
||||||
@blueprint.route("/wiki/_create/<name>", methods=['GET', 'POST'])
|
@blueprint.route("/wiki/_create/<name>", methods=['GET', 'POST'])
|
||||||
def create(name):
|
def create(name):
|
||||||
cname = ""
|
|
||||||
if name:
|
|
||||||
cname = to_canonical(name)
|
|
||||||
if g.current_wiki.get_page(cname):
|
|
||||||
# Page exists, edit instead
|
|
||||||
return redirect(url_for('wiki.edit', name=cname))
|
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
g.current_wiki.write_page(request.form['name'],
|
g.current_wiki.write_page(request.form['name'],
|
||||||
|
@ -83,8 +78,12 @@ def create(name):
|
||||||
message=request.form['message'],
|
message=request.form['message'],
|
||||||
create=True,
|
create=True,
|
||||||
username=g.current_user.get('username'))
|
username=g.current_user.get('username'))
|
||||||
return redirect(url_for('wiki.page', name=cname))
|
|
||||||
else:
|
else:
|
||||||
|
cname = to_canonical(name) if name else ""
|
||||||
|
if cname and g.current_wiki.get_page(cname):
|
||||||
|
# Page exists, edit instead
|
||||||
|
return redirect(url_for('wiki.edit', name=cname))
|
||||||
|
|
||||||
return render_template('wiki/edit.html', name=cname, content="")
|
return render_template('wiki/edit.html', name=cname, content="")
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue