From cb9e19d1a257d54a6419b6d26cf2001c761ba7bf Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Fri, 20 Sep 2019 17:08:28 +0200 Subject: [PATCH] Allow to append index.html files on menus There is also this `html.insert(0...` change that I am not sure about but it seems to be working for us now. --- CHANGELOG.md | 1 + distribusi/cli.py | 5 +++++ distribusi/distribusi.py | 8 ++++++-- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23c06f8..b300882 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The changelog was only added at version 0.0.4. * Allow to ignore hidden directories with `--no-hidden` * Files and directories are now sorted during distribusification. +* Allow to append `index.html` to the menu items with `--menu-with-index` ## 0.0.7 diff --git a/distribusi/cli.py b/distribusi/cli.py index 3afff70..c978dac 100644 --- a/distribusi/cli.py +++ b/distribusi/cli.py @@ -77,6 +77,11 @@ def build_argparser(): help="Exclude hidden directories", action="store_true") + parser.add_argument( + '--menu-with-index', + help="Append index.html to menu items to aid navigation", + action="store_true") + return parser diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 81157aa..65ad7c6 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -183,8 +183,12 @@ def distribusify(args, directory): # noqa html.append('../') for name in dirs: - a = "{}/".replace('{}', name) - html.append(div(args, 'dir', 'dir', a, 'folder')) + if args.menu_with_index: + a = "{}".replace('{}', name) + else: + a = "{}/".replace('{}', name) + + html.insert(0, div(args, 'dir', 'dir', a, 'folder')) index = os.path.join(root, 'index.html') if os.path.exists(index):