Merge pull request #91 from gazpachoking/subdir_indexes

Support getting indexs of subdirs
这个提交包含在:
Matthew Scragg 2015-12-12 19:03:49 -06:00
当前提交 fbb5f2f995
共有 2 个文件被更改,包括 11 次插入5 次删除

查看文件

@ -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'])

查看文件

@ -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,11 +21,11 @@ $(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>
</tr>
{% endfor %}
</table>
{% endblock %}
{% endblock %}