Preliminary subdirectory support. refs #50
This commit is contained in:
parent
917cc5b967
commit
9108f82149
|
@ -85,10 +85,10 @@ def to_canonical(s):
|
|||
"""
|
||||
Double space -> single dash
|
||||
Double dash -> single dash
|
||||
Remove all non alphanumeric and dash
|
||||
Remove all non alphanumeric and dash except path separatos (/)
|
||||
Limit to first 128 chars
|
||||
"""
|
||||
reserved_chars = "&$+,/:;=?@#"
|
||||
reserved_chars = "&$+,:;=?@#"
|
||||
unsafe_chars = "?<>[]{}|\^~%"
|
||||
|
||||
s = s.encode('utf8')
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
import posixpath
|
||||
import re
|
||||
import ghdiff
|
||||
import gittle.utils
|
||||
|
@ -82,6 +83,10 @@ class Wiki(HookMixin):
|
|||
|
||||
cname = to_canonical(name)
|
||||
filename = cname_to_filename(cname)
|
||||
dirname = posixpath.join(self.path, posixpath.dirname(filename))
|
||||
|
||||
if not os.path.exists(dirname):
|
||||
os.makedirs(dirname)
|
||||
|
||||
with open(self.path + "/" + filename, 'w') as f:
|
||||
f.write(content)
|
||||
|
|
|
@ -6,7 +6,7 @@ from .models import PageNotFound
|
|||
blueprint = Blueprint('wiki', __name__)
|
||||
|
||||
|
||||
@blueprint.route("/_commit/<sha>/<name>")
|
||||
@blueprint.route("/_commit/<sha>/<path:name>")
|
||||
def commit(name, sha):
|
||||
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
|
||||
return current_app.login_manager.unauthorized()
|
||||
|
@ -21,7 +21,7 @@ def commit(name, sha):
|
|||
return render_template('wiki/page.html', name=name, page=data, commit=sha)
|
||||
|
||||
|
||||
@blueprint.route("/_compare/<name>/<regex('[^.]+'):fsha><regex('\.{2,3}'):dots><regex('.+'):lsha>")
|
||||
@blueprint.route(r"/_compare/<path:name>/<regex('\w+'):fsha><regex('\.{2,3}'):dots><regex('\w+'):lsha>")
|
||||
def compare(name, fsha, dots, lsha):
|
||||
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
|
||||
return current_app.login_manager.unauthorized()
|
||||
|
@ -59,7 +59,7 @@ def revert():
|
|||
return dict(sha=sha)
|
||||
|
||||
|
||||
@blueprint.route("/_history/<name>")
|
||||
@blueprint.route("/_history/<path:name>")
|
||||
def history(name):
|
||||
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
|
||||
return current_app.login_manager.unauthorized()
|
||||
|
@ -67,7 +67,7 @@ def history(name):
|
|||
return render_template('wiki/history.html', name=name, history=g.current_wiki.get_history(name))
|
||||
|
||||
|
||||
@blueprint.route("/_edit/<name>")
|
||||
@blueprint.route("/_edit/<path:name>")
|
||||
@login_required
|
||||
def edit(name):
|
||||
cname = to_canonical(name)
|
||||
|
@ -88,7 +88,7 @@ def edit(name):
|
|||
|
||||
|
||||
@blueprint.route("/_create/", defaults={'name': None})
|
||||
@blueprint.route("/_create/<name>")
|
||||
@blueprint.route("/_create/<path:name>")
|
||||
@login_required
|
||||
def create(name):
|
||||
cname = to_canonical(name) if name else ""
|
||||
|
@ -111,7 +111,7 @@ def index():
|
|||
return render_template('wiki/index.html', index=g.current_wiki.get_index())
|
||||
|
||||
|
||||
@blueprint.route("/<name>", methods=['POST', 'PUT', 'DELETE'])
|
||||
@blueprint.route("/<path:name>", methods=['POST', 'PUT', 'DELETE'])
|
||||
@login_required
|
||||
def page_write(name):
|
||||
cname = to_canonical(name)
|
||||
|
@ -164,7 +164,7 @@ def page_write(name):
|
|||
|
||||
|
||||
@blueprint.route("/", defaults={'name': 'home'})
|
||||
@blueprint.route("/<name>")
|
||||
@blueprint.route("/<path:name>")
|
||||
def page(name):
|
||||
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
|
||||
return current_app.login_manager.unauthorized()
|
||||
|
|
Loading…
Reference in a new issue