Merge pull request #91 from gazpachoking/subdir_indexes
Support getting indexs of subdirs
This commit is contained in:
commit
fbb5f2f995
|
@ -103,12 +103,17 @@ def create(name):
|
||||||
info={})
|
info={})
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route("/_index")
|
@blueprint.route("/_index", defaults={"path": ""})
|
||||||
def index():
|
@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():
|
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous():
|
||||||
return current_app.login_manager.unauthorized()
|
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'])
|
@blueprint.route("/<path:name>", methods=['POST', 'PUT', 'DELETE'])
|
||||||
|
|
|
@ -9,6 +9,7 @@ $(document).ready(function() {
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
<h2>Index of /{{ path }}</h2>
|
||||||
<table class="table table-bordered data-table">
|
<table class="table table-bordered data-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -20,11 +21,11 @@ $(document).ready(function() {
|
||||||
</thead>
|
</thead>
|
||||||
{% for file in index %}
|
{% for file in index %}
|
||||||
<tr>
|
<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 class="hidden-xs">{{ file['size'] }}</td>
|
||||||
<td>{{ file['ctime']|datetime }}</td>
|
<td>{{ file['ctime']|datetime }}</td>
|
||||||
<td class="hidden-xs hidden-sm">{{ file['mtime']|datetime }}</td>
|
<td class="hidden-xs hidden-sm">{{ file['mtime']|datetime }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue