From 9f9401a7f74e1fcb637226370aa6807e7d10cdb1 Mon Sep 17 00:00:00 2001 From: Chase Sterling Date: Sun, 13 Dec 2015 11:52:27 -0500 Subject: [PATCH] Allow a flat view of index with the 'flat' query parameter --- realms/modules/wiki/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/realms/modules/wiki/views.py b/realms/modules/wiki/views.py index 2d5025d..1229ffb 100644 --- a/realms/modules/wiki/views.py +++ b/realms/modules/wiki/views.py @@ -113,7 +113,6 @@ def _get_subdir(path, depth): def _tree_index(items, path=""): depth = len(path.split("/")) - items = filter(lambda x: x['name'].startswith(path), items) items = sorted(items, key=lambda x: x['name']) for subdir, items in itertools.groupby(items, key=lambda x: _get_subdir(x['name'], depth)): if not subdir: @@ -144,8 +143,11 @@ def index(path): items = g.current_wiki.get_index() if path: path = to_canonical(path) + "/" + items = filter(lambda x: x['name'].startswith(path), items) + if not request.args.get('flat', '').lower() in ['yes', '1', 'true']: + items = _tree_index(items, path=path) - return render_template('wiki/index.html', index=_tree_index(items, path=path), path=path) + return render_template('wiki/index.html', index=items, path=path) @blueprint.route("/", methods=['POST', 'PUT', 'DELETE'])