From 31c9ac2062844d655e7a5331386add8a4d927ff3 Mon Sep 17 00:00:00 2001 From: gurkenhabicht Date: Thu, 20 Oct 2022 23:39:10 +0200 Subject: [PATCH] do not show empty directories --- husk_helpers.py | 36 ++++++++++++++++++++++++++++++++++-- static/github-dark.css | 7 ++++++- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/husk_helpers.py b/husk_helpers.py index 1c825af..cb23fc5 100644 --- a/husk_helpers.py +++ b/husk_helpers.py @@ -6,7 +6,7 @@ from collections import deque def sort_branch( lst ): ''' - sorts directories before files and + put directories in front of files and sorts both alphabetically ''' files = [] @@ -36,12 +36,44 @@ def make_tree(path="templates/content"): for name in lst: fn = os.path.join(path, name) if os.path.isdir(fn) and not fn.endswith(".git"): - tree['children'].append(make_tree(fn)) + if os.listdir(fn): # this line is experimental and needs to be tested + tree['children'].append(make_tree(fn)) else: if fn.endswith('.md') and not name == "README.md": tree['children'].append(dict(name=fn)) return tree +#def clean_up_tree(tree): +# for key, val in tree.items(): +# if isinstance(val, list): +# val = [ x for x in val if len(val) > 0] +# if isinstance(val, dict): +# clean_tree(tree) +# return tree +#def clean_up_tree(tree): +# ''' +# create a clean directory structure inside the dict without empty lists +# ''' +# import copy +# for key, val in tree.items(): +# if isinstance(val, list): +# if len(val) < 1: +# del tree[key] +# else: +# for item in val: +# if isinstance(item, dict): +# clean_up_tree(item) +# return tree + +#def clean_up_tree(tree): +# ''' +# delete directories without content +# ''' +# for key, val in tree.items(): +# if isinstance(val, list) and len(val) == 0: +# del tree[key] +# return tree + def cut_path_tree(tree, subdir, file_ending): ''' pruning of the tree structure from make_tree() diff --git a/static/github-dark.css b/static/github-dark.css index 656cbb7..5a1b95c 100644 --- a/static/github-dark.css +++ b/static/github-dark.css @@ -61,13 +61,18 @@ details summary::marker { content: "\1F4C1\20";} .HolyGrail-nav li { list-style-type: none!important; - padding-left : 0.5ch; + /* padding-left : 0.5ch; */ margin: 0em; text-align: left; /* experimental line height */ line-height: 1.5em; + list-style-position: inside; } + .HolyGrail-nav li::marker { + content: "\1F4DD\20"; + } + .HolyGrail-nav a{ overflow-wrap: break-word; text-decoration: none;