From 6a9fbe98567d87a20b15667cd2996c66e6a50fa0 Mon Sep 17 00:00:00 2001 From: rra Date: Sun, 15 Sep 2019 17:39:04 +0200 Subject: [PATCH] files are listed alphabetically, fixes to css and html --- distribusi/distribusi.py | 18 +++++++++++------- distribusi/mappings.py | 4 ++-- distribusi/page_template.py | 8 ++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 024c1a4..5a24ae0 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -116,18 +116,24 @@ def distribusify(args, directory): # noqa if args.verbose: print('Generating directory listing for', root) - for name in files: + for name in sorted(files): + if 'index.html' not in name: full_path = os.path.join(root, name) mime = MIME_TYPE.from_file(full_path) # example: MIME plain/text becomes 'type' plain 'subtype' text type_, subtype = mime.split('/') + caption = name + if args.verbose: print('Found', name, 'as', mime) if type_ in FILE_TYPES: - # expansion for different kind of textfiles + + a = FILE_TYPES[type_].format(name, caption) + + # expansion for different kind of text files if type_ == 'text': if name.endswith('.html') or subtype == 'html': subtype = 'html' @@ -143,14 +149,12 @@ def distribusify(args, directory): # noqa # a = FILE_TYPES[type_] if type_ == 'image': - caption = name if args.thumbnail: a = thumbnail(full_path, name, args) if args.no_filenames: caption = "" if args.captions: caption = caption(full_path) - a = FILE_TYPES[type_].format(name, caption) if subtype in SUB_TYPES: @@ -162,8 +166,10 @@ def distribusify(args, directory): # noqa if args.verbose: message = 'not in list of file types, adding as plain href: \n' print(type_, subtype, message, name) - type_ = 'unkown-file' + subtype = subtype + ' unkown-file' + a = a.replace('{}', name) + html.append(div(args, type_, subtype, a, name)) if root != directory: @@ -180,8 +186,6 @@ def distribusify(args, directory): # noqa elif not os.path.exists(index): write_index(args,index,html, html_head, html_footer) - - if args.remove_index: index = os.path.join(root, 'index.html') if 'index.html' in files: diff --git a/distribusi/mappings.py b/distribusi/mappings.py index b360c33..d9fb9dc 100644 --- a/distribusi/mappings.py +++ b/distribusi/mappings.py @@ -3,8 +3,8 @@ CODE_TYPES = ['x-c', 'x-shellscript', 'x-python'] FILE_TYPES = { 'image': '
{}
', 'text': '{}', - 'video': (''), - 'audio': (''), + 'video': (''), + 'audio': (''), } SUB_TYPES = { diff --git a/distribusi/page_template.py b/distribusi/page_template.py index 6ada8d3..24a1e93 100644 --- a/distribusi/page_template.py +++ b/distribusi/page_template.py @@ -7,12 +7,12 @@ html_head = """