Merge pull request #91 from gazpachoking/subdir_indexes

Support getting indexs of subdirs
This commit is contained in:
Matthew Scragg 2015-12-12 19:03:49 -06:00
commit fbb5f2f995
2 changed files with 11 additions and 5 deletions

View file

@ -103,12 +103,17 @@ def create(name):
info={})
@blueprint.route("/_index")
def index():
@blueprint.route("/_index", defaults={"path": ""})
@blueprint.route("/_index/<path:path>")
def index(path):
items = g.current_wiki.get_index()
if path:
path = to_canonical(path) + "/"
items = (i for i in items if i['name'].startswith(path))
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
return current_app.login_manager.unauthorized()
return render_template('wiki/index.html', index=g.current_wiki.get_index())
return render_template('wiki/index.html', index=items, path=path)
@blueprint.route("/<path:name>", methods=['POST', 'PUT', 'DELETE'])

View file

@ -9,6 +9,7 @@ $(document).ready(function() {
{% endblock %}
{% block body %}
<h2>Index of /{{ path }}</h2>
<table class="table table-bordered data-table">
<thead>
<tr>
@ -20,7 +21,7 @@ $(document).ready(function() {
</thead>
{% for file in index %}
<tr>
<td><a href="{{ url_for('wiki.page', name=file['name']) }}">{{ file['name'] }}</a></td>
<td><a href="{{ url_for('wiki.page', name=file['name']) }}">{{ file['name'][path|length:] }}</a></td>
<td class="hidden-xs">{{ file['size'] }}</td>
<td>{{ file['ctime']|datetime }}</td>
<td class="hidden-xs hidden-sm">{{ file['mtime']|datetime }}</td>