updated wiki routes
This commit is contained in:
parent
408d474f1a
commit
d31930bf10
|
@ -247,7 +247,7 @@ else:
|
||||||
@app.before_request
|
@app.before_request
|
||||||
def check_subdomain():
|
def check_subdomain():
|
||||||
if not g.current_site:
|
if not g.current_site:
|
||||||
return redirect('http://%s' % config.SERVER_NAME)
|
return redirect('http://%s' % config.DOMAIN)
|
||||||
|
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
|
@ -296,6 +296,5 @@ def new():
|
||||||
def account():
|
def account():
|
||||||
return render_template('account/index.html')
|
return render_template('account/index.html')
|
||||||
|
|
||||||
if 'devserver' not in sys.argv or os.environ.get('WERKZEUG_RUN_MAIN'):
|
app.discover()
|
||||||
app.discover()
|
|
||||||
|
|
||||||
|
|
|
@ -2,10 +2,10 @@ from flask import g, render_template, request, redirect, Blueprint, flash, url_f
|
||||||
from flask.ext.login import login_required
|
from flask.ext.login import login_required
|
||||||
from realms.lib.util import to_canonical, remove_ext
|
from realms.lib.util import to_canonical, remove_ext
|
||||||
|
|
||||||
blueprint = Blueprint('wiki', __name__, url_prefix='/wiki')
|
blueprint = Blueprint('wiki', __name__)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/_commit/<sha>/<name>")
|
@blueprint.route("/wiki/_commit/<sha>/<name>")
|
||||||
def commit(name, sha):
|
def commit(name, sha):
|
||||||
cname = to_canonical(name)
|
cname = to_canonical(name)
|
||||||
|
|
||||||
|
@ -13,16 +13,16 @@ def commit(name, sha):
|
||||||
if data:
|
if data:
|
||||||
return render_template('wiki/page.html', name=name, page=data, commit=sha)
|
return render_template('wiki/page.html', name=name, page=data, commit=sha)
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('.create', name=cname))
|
return redirect(url_for('wiki.create', name=cname))
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/_compare/<name>/<regex('[^.]+'):fsha><regex('\.{2,3}'):dots><regex('.+'):lsha>")
|
@blueprint.route("/wiki/_compare/<name>/<regex('[^.]+'):fsha><regex('\.{2,3}'):dots><regex('.+'):lsha>")
|
||||||
def compare(name, fsha, dots, lsha):
|
def compare(name, fsha, dots, lsha):
|
||||||
diff = g.current_wiki.compare(name, fsha, lsha)
|
diff = g.current_wiki.compare(name, fsha, lsha)
|
||||||
return render_template('wiki/compare.html', name=name, diff=diff, old=fsha, new=lsha)
|
return render_template('wiki/compare.html', name=name, diff=diff, old=fsha, new=lsha)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/_revert", methods=['POST'])
|
@blueprint.route("/wiki/_revert", methods=['POST'])
|
||||||
def revert():
|
def revert():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
name = request.form.get('name')
|
name = request.form.get('name')
|
||||||
|
@ -31,15 +31,15 @@ def revert():
|
||||||
g.current_wiki.revert_page(name, commit, message="Reverting %s" % cname,
|
g.current_wiki.revert_page(name, commit, message="Reverting %s" % cname,
|
||||||
username=g.current_user.get('username'))
|
username=g.current_user.get('username'))
|
||||||
flash('Page reverted', 'success')
|
flash('Page reverted', 'success')
|
||||||
return redirect(url_for('.page', name=cname))
|
return redirect(url_for('wiki.page', name=cname))
|
||||||
|
|
||||||
@blueprint.route("/_history/<name>")
|
@blueprint.route("/wiki/_history/<name>")
|
||||||
def history(name):
|
def history(name):
|
||||||
history = g.current_wiki.get_history(name)
|
history = g.current_wiki.get_history(name)
|
||||||
return render_template('wiki/history.html', name=name, history=history, wiki_home=url_for('wiki.page'))
|
return render_template('wiki/history.html', name=name, history=history, wiki_home=url_for('wiki.page'))
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/_edit/<name>", methods=['GET', 'POST'])
|
@blueprint.route("/wiki/_edit/<name>", methods=['GET', 'POST'])
|
||||||
def edit(name):
|
def edit(name):
|
||||||
data = g.current_wiki.get_page(name)
|
data = g.current_wiki.get_page(name)
|
||||||
cname = to_canonical(name)
|
cname = to_canonical(name)
|
||||||
|
@ -51,31 +51,31 @@ def edit(name):
|
||||||
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('.page', name=edit_cname))
|
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'])
|
||||||
content = data['data']
|
content = data['data']
|
||||||
return render_template('wiki/edit.html', name=name, content=content)
|
return render_template('wiki/edit.html', name=name, content=content)
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('.create', name=cname))
|
return redirect(url_for('wiki.create', name=cname))
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/_delete/<name>", methods=['POST'])
|
@blueprint.route("/wiki/_delete/<name>", methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def delete(name):
|
def delete(name):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/_create/", defaults={'name': None}, methods=['GET', 'POST'])
|
@blueprint.route("/wiki/_create/", defaults={'name': None}, methods=['GET', 'POST'])
|
||||||
@blueprint.route("/_create/<name>", methods=['GET', 'POST'])
|
@blueprint.route("/wiki/_create/<name>", methods=['GET', 'POST'])
|
||||||
def create(name):
|
def create(name):
|
||||||
cname = ""
|
cname = ""
|
||||||
if name:
|
if name:
|
||||||
cname = to_canonical(name)
|
cname = to_canonical(name)
|
||||||
if g.current_wiki.get_page(cname):
|
if g.current_wiki.get_page(cname):
|
||||||
# Page exists, edit instead
|
# Page exists, edit instead
|
||||||
return redirect(url_for('.edit', name=cname))
|
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,21 +83,21 @@ 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('.page', name=cname))
|
return redirect(url_for('wiki.page', name=cname))
|
||||||
else:
|
else:
|
||||||
return render_template('wiki/edit.html', name=cname, content="")
|
return render_template('wiki/edit.html', name=cname, content="")
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/", defaults={'name': 'home'})
|
@blueprint.route("/wiki", defaults={'name': 'home'})
|
||||||
@blueprint.route("/<name>")
|
@blueprint.route("/wiki/<name>")
|
||||||
def page(name):
|
def page(name):
|
||||||
cname = to_canonical(name)
|
cname = to_canonical(name)
|
||||||
if cname != name:
|
if cname != name:
|
||||||
return redirect(url_for('.page', name=cname))
|
return redirect(url_for('wiki.page', name=cname))
|
||||||
|
|
||||||
data = g.current_wiki.get_page(cname)
|
data = g.current_wiki.get_page(cname)
|
||||||
|
|
||||||
if data:
|
if data:
|
||||||
return render_template('wiki/page.html', name=cname, page=data)
|
return render_template('wiki/page.html', name=cname, page=data)
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('.create', name=cname))
|
return redirect(url_for('wiki.create', name=cname))
|
Loading…
Reference in a new issue