diff --git a/generate_index.py b/generate_index.py index 72c5b7c..b97ee9a 100644 --- a/generate_index.py +++ b/generate_index.py @@ -13,22 +13,24 @@ def generate_index(dir_path): files = sorted(os.listdir(dir_path)) - # Get the name of the directory for the heading - dir_name = os.path.dirname(dir_path).replace(base_dir, "") + # Get the full relative path of the directory for the heading + dir_relative_path = os.path.relpath(dir_path, base_dir).replace(os.sep, "/") # Create index.html file with a heading and a "Go to Parent Directory" link index_content = f'
' # Add a link to go to the parent directory - parent_dir_url = os.path.dirname(dir_path).replace(base_dir, "").replace(os.sep, "/") - if parent_dir_url != "": + parent_dir_url = os.path.dirname(dir_path) + if parent_dir_url != base_dir: + # Use `..` to go one level up from the current directory index_content += f'' - + if dir_path != base_dir and dir_path.split("_")[-1].isdigit(): if int(dir_path.split("_")[-1]) < 2000: index_content += 'Destination MGRA in red; MGRA or TAZ w access in blue.
' + # Add the heading for the current directory - index_content += f'