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.
This commit is contained in:
Luke Murphy 2019-09-20 17:08:28 +02:00
parent 2a0834734f
commit cb9e19d1a2
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
3 changed files with 12 additions and 2 deletions

View File

@ -6,6 +6,7 @@ The changelog was only added at version 0.0.4.
* Allow to ignore hidden directories with `--no-hidden` * Allow to ignore hidden directories with `--no-hidden`
* Files and directories are now sorted during distribusification. * Files and directories are now sorted during distribusification.
* Allow to append `index.html` to the menu items with `--menu-with-index`
## 0.0.7 ## 0.0.7

View File

@ -77,6 +77,11 @@ def build_argparser():
help="Exclude hidden directories", help="Exclude hidden directories",
action="store_true") action="store_true")
parser.add_argument(
'--menu-with-index',
help="Append index.html to menu items to aid navigation",
action="store_true")
return parser return parser

View File

@ -183,8 +183,12 @@ def distribusify(args, directory): # noqa
html.append('<a href="../">../</a>') html.append('<a href="../">../</a>')
for name in dirs: for name in dirs:
if args.menu_with_index:
a = "<a href='{}/index.html'>{}</a>".replace('{}', name)
else:
a = "<a href='{}'>{}/</a>".replace('{}', name) a = "<a href='{}'>{}/</a>".replace('{}', name)
html.append(div(args, 'dir', 'dir', a, 'folder'))
html.insert(0, div(args, 'dir', 'dir', a, 'folder'))
index = os.path.join(root, 'index.html') index = os.path.join(root, 'index.html')
if os.path.exists(index): if os.path.exists(index):