updated wiki routes
This commit is contained in:
parent
d31930bf10
commit
a891e77d40
|
@ -213,35 +213,30 @@ for status_code in httplib.responses:
|
|||
|
||||
assets = Environment()
|
||||
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(
|
||||
Bundle('vendor/jquery/jquery.js',
|
||||
'vendor/components-underscore/underscore.js',
|
||||
'vendor/components-bootstrap/js/bootstrap.js',
|
||||
'vendor/handlebars/handlebars.js',
|
||||
'vendor/showdown/src/showdown.js',
|
||||
'vendor/showdown/src/extensions/table.js',
|
||||
'js/wmd.js',
|
||||
filters='closure_js'),
|
||||
'js/html-sanitizer-minified.js',
|
||||
'vendor/highlightjs/highlight.pack.js',
|
||||
Bundle('js/main.js', filters='closure_js'),
|
||||
output='packed-common.js')
|
||||
assets.register('js_common', js)
|
||||
|
||||
if 'js_editor' not in assets._named_bundles:
|
||||
js = Bundle('js/ace/ace.js',
|
||||
'js/ace/mode-markdown.js',
|
||||
'vendor/keymaster/keymaster.js',
|
||||
'js/dillinger.js',
|
||||
filters='closure_js', output='packed-editor.js')
|
||||
assets.register('js_editor', js)
|
||||
|
||||
js = Bundle(
|
||||
Bundle('vendor/jquery/jquery.js',
|
||||
'vendor/components-underscore/underscore.js',
|
||||
'vendor/components-bootstrap/js/bootstrap.js',
|
||||
'vendor/handlebars/handlebars.js',
|
||||
'vendor/showdown/src/showdown.js',
|
||||
'vendor/showdown/src/extensions/table.js',
|
||||
'js/wmd.js',
|
||||
filters='closure_js'),
|
||||
'js/html-sanitizer-minified.js',
|
||||
'vendor/highlightjs/highlight.pack.js',
|
||||
Bundle('js/main.js', filters='closure_js'),
|
||||
output='packed-common.js')
|
||||
assets.register('js_common', js)
|
||||
|
||||
js = Bundle('js/ace/ace.js',
|
||||
'js/ace/mode-markdown.js',
|
||||
'vendor/keymaster/keymaster.js',
|
||||
'js/dillinger.js',
|
||||
filters='closure_js', output='packed-editor.js')
|
||||
|
||||
assets.register('js_editor', js)
|
||||
|
||||
|
||||
@app.before_request
|
||||
|
|
|
@ -47,11 +47,11 @@ def edit(name):
|
|||
edit_cname = to_canonical(request.form['name'])
|
||||
if edit_cname.lower() != cname.lower():
|
||||
g.current_wiki.rename_page(cname, edit_cname)
|
||||
|
||||
g.current_wiki.write_page(edit_cname,
|
||||
request.form['content'],
|
||||
message=request.form['message'],
|
||||
username=g.current_user.get('username'))
|
||||
return redirect(url_for('wiki.page', name=edit_cname))
|
||||
else:
|
||||
if data:
|
||||
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/<name>", methods=['GET', 'POST'])
|
||||
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':
|
||||
g.current_wiki.write_page(request.form['name'],
|
||||
|
@ -83,8 +78,12 @@ def create(name):
|
|||
message=request.form['message'],
|
||||
create=True,
|
||||
username=g.current_user.get('username'))
|
||||
return redirect(url_for('wiki.page', name=cname))
|
||||
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="")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue