From d8f64511230b70c7b956f3071223612a0f69d514 Mon Sep 17 00:00:00 2001 From: Dooho Yi Date: Thu, 14 Jan 2021 18:31:40 +0900 Subject: [PATCH] added --no-underscore to support better _style.css & _main.js --- distribusi/cli.py | 5 +++++ distribusi/distribusi.py | 18 +++++++++++++++--- distribusi/page_template.py | 2 ++ inst_deps.sh | 0 run.sh | 2 +- styles/dark.css | 1 + 6 files changed, 24 insertions(+), 4 deletions(-) mode change 100644 => 100755 inst_deps.sh diff --git a/distribusi/cli.py b/distribusi/cli.py index b55fa80..1d00df8 100644 --- a/distribusi/cli.py +++ b/distribusi/cli.py @@ -79,6 +79,11 @@ def build_argparser(): help="Exclude hidden directories", action="store_true") + parser.add_argument( + '--no-underscore', + help="Exclude files/dirs starts with underscore(_)", + action="store_true") + parser.add_argument( '--menu-with-index', help="Append index.html to menu items to aid navigation", diff --git a/distribusi/distribusi.py b/distribusi/distribusi.py index 8e86592..c76defc 100644 --- a/distribusi/distribusi.py +++ b/distribusi/distribusi.py @@ -113,12 +113,17 @@ def write_index(args,index, html, html_head, html_footer): def render_dir(args, root): html = [] - for name in sorted(os.listdir(root)): + #for name in sorted(os.listdir(root)): + for name in sorted(os.listdir(root),reverse=True): if args.no_hidden: if name.startswith('.'): continue + if args.no_underscore: + if name.startswith('_'): + continue + lv = root.split("/") relative = lv[len(lv) - 1] relative_path = "./{}/{}".format(relative, name) @@ -218,6 +223,10 @@ def distribusify(args, directory): # noqa dirs = list(filter(lambda d: not d.startswith('.'), dirs)) files = list(filter(lambda f: not f.startswith('.'), files)) + if args.no_underscore: + dirs = list(filter(lambda d: not d.startswith('_'), dirs)) + files = list(filter(lambda f: not f.startswith('_'), files)) + dirs.sort() files.sort() @@ -227,7 +236,8 @@ def distribusify(args, directory): # noqa if args.verbose: print('Generating directory listing for', root) - for name in sorted(files): + #for name in sorted(files): + for name in sorted(files,reverse=True): if 'index.html' not in name: full_path = os.path.join(root, name) @@ -296,7 +306,9 @@ def distribusify(args, directory): # noqa else: html.append('../') - for name in dirs: + #for name in dirs: + for name in sorted(dirs,reverse=True): + #check - time string m = PATTERN_TSTR.search(name) tstring = "" diff --git a/distribusi/page_template.py b/distribusi/page_template.py index 43c6533..2ab67a5 100644 --- a/distribusi/page_template.py +++ b/distribusi/page_template.py @@ -11,6 +11,8 @@ html_head = """ + + diff --git a/inst_deps.sh b/inst_deps.sh old mode 100644 new mode 100755 diff --git a/run.sh b/run.sh index 9edda3c..39a9625 100755 --- a/run.sh +++ b/run.sh @@ -1,3 +1,3 @@ #!/bin/bash -python run.py -d ./data/ -nf -s styles/dark.css --no-hidden --unfolding +python run.py -d ./data/ -nf -s styles/white.css --no-hidden --no-underscore --unfolding diff --git a/styles/dark.css b/styles/dark.css index 48ba1d5..51a9f76 100644 --- a/styles/dark.css +++ b/styles/dark.css @@ -93,6 +93,7 @@ body::-webkit-scrollbar { #header { padding-bottom: 3em; + display: none; } .unfolded {