diff --git a/README.md b/README.md index 2c51253..14a23f5 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,6 @@ The script supports several command-line options to customize its behavior. Belo - `-p ROOT, --root-directory ROOT`: Specify the root folder where the images are stored. This option is required. - `-w WEBROOT, --web-root-url WEBROOT`: Specify the web root URL where the images will be accessible. This option is required. - `-t TITLE, --site-title TITLE`: Specify the title for the root directory HTML file. This option is required. -- `-i ICON, --folder-icon-url ICON`: Specify the URL for the folder icon. Default is `https://www.svgrepo.com/show/400249/folder.svg`. - `-r, --regenerate-thumbnails`: Regenerate thumbnails even if they already exist. - `-n, --non-interactive-mode`: Disable interactive mode, which is useful for automated workflows. - `--use-fancy-folders`: Use fancy folders instead of the default Apache directory listing. diff --git a/files/global.css b/files/global.css index 9e31819..020efa3 100644 --- a/files/global.css +++ b/files/global.css @@ -13,10 +13,8 @@ body { .folders { text-align: center; display: -ms-flexbox; - /* IE10 */ display: flex; -ms-flex-wrap: wrap; - /* IE10 */ flex-wrap: wrap; justify-content: space-evenly; overflow: hidden; @@ -46,10 +44,8 @@ body { .row { display: -ms-flexbox; - /* IE10 */ display: flex; -ms-flex-wrap: wrap; - /* IE10 */ flex-wrap: wrap; padding: 0 2px; } @@ -61,7 +57,6 @@ figure { /* Create four equal columns that sits next to each other */ .column { -ms-flex: 12.5%; - /* IE10 */ flex: 12.5%; max-width: 12.5%; padding: 0 4px; @@ -168,4 +163,4 @@ figure { text-align: center; padding: 14px 16px; text-decoration: none; -} \ No newline at end of file +} diff --git a/generate_html.py b/generate_html.py index 79011fa..604c1eb 100755 --- a/generate_html.py +++ b/generate_html.py @@ -14,13 +14,12 @@ import cclicense # fmt: off # Constants -DEFAULT_FOLDER_ICON = "https://www.svgrepo.com/show/400249/folder.svg" STATIC_FILES_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "files") FAVICON_PATH = ".static/favicon.ico" GLOBAL_CSS_PATH = ".static/global.css" DEFAULT_THEME_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), "themes", "default.css") DEFAULT_AUTHOR = "Author" -VERSION = "1.4" +VERSION = "1.5" RAW_EXTENSIONS = [".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr", ".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".tif", ".tiff", ".x3f"] IMG_EXTENSIONS = [".jpg", ".jpeg"] EXCLUDES = [".lock", "index.html", ".thumbnails", ".static"] @@ -31,11 +30,11 @@ NOT_LIST = ["Galleries", "Archives"] env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath(os.path.dirname(__file__)), "templates"))) thumbnails: List[Tuple[str, str]] = [] + class Args: root_directory: str web_root_url: str site_title: str - folder_icon_url: str regenerate_thumbnails: bool non_interactive_mode: bool use_fancy_folders: bool @@ -52,7 +51,6 @@ def parse_arguments() -> Args: parser.add_argument("-p", "--root-directory", help="Root directory containing the images.", required=True, type=str, dest="root_directory") parser.add_argument("-w", "--web-root-url", help="Base URL of the web root for the image hosting site.", required=True, type=str, dest="web_root_url") parser.add_argument("-t", "--site-title", help="Title of the image hosting site.", required=True, type=str, dest="site_title") - parser.add_argument("-i", "--folder-icon-url", help="URL of the icon used for folders.", default=DEFAULT_FOLDER_ICON, type=str, metavar="ICON", dest="folder_icon_url") parser.add_argument("-r", "--regenerate-thumbnails", help="Regenerate thumbnails even if they already exist.", action="store_true", default=False, dest="regenerate_thumbnails") parser.add_argument("-n", "--non-interactive-mode", help="Run in non-interactive mode, disabling progress bars.", action="store_true", default=False, dest="non_interactive_mode") parser.add_argument("-l", "--license-type", help="Specify the license type for the images.", choices=["cc-zero", "cc-by", "cc-by-sa", "cc-by-nd", "cc-by-nc", "cc-by-nc-sa", "cc-by-nc-nd"], default=None, dest="license_type") @@ -69,7 +67,6 @@ def parse_arguments() -> Args: args.root_directory = parsed_args.root_directory args.web_root_url = parsed_args.web_root_url args.site_title = parsed_args.site_title - args.folder_icon_url = parsed_args.folder_icon_url args.regenerate_thumbnails = parsed_args.regenerate_thumbnails args.non_interactive_mode = parsed_args.non_interactive_mode args.use_fancy_folders = parsed_args.use_fancy_folders @@ -113,12 +110,17 @@ def generate_thumbnail(arguments: Tuple[str, str]) -> None: def get_total_folders(folder: str) -> None: global total + + total += 1 + + pbar.desc = f"Traversing filesystem - {folder}" + pbar.update(1) + items = os.listdir(folder) items.sort() for item in items: if item not in EXCLUDES: if os.path.isdir(os.path.join(folder, item)): - total += 1 if item not in args.exclude_folders: get_total_folders(os.path.join(folder, item)) @@ -191,7 +193,6 @@ def list_folder(folder: str, title: str) -> None: root=args.web_root_url, parent=parent, header=header, - foldericon=args.folder_icon_url, license=license_info, subdirectories=subfolders, images=image_chunks, @@ -234,7 +235,7 @@ def main() -> None: pbar.update(0) pbar.close() - pbar = tqdm(total=total + 1, desc="Generating HTML files", unit="files", ascii=True, dynamic_ncols=True) + pbar = tqdm(total=total, desc="Generating HTML files", unit="files", ascii=True, dynamic_ncols=True) list_folder(args.root_directory, args.site_title) pbar.desc = "Generating html files" pbar.update(0) diff --git a/templates/index.html.j2 b/templates/index.html.j2 index be69249..4c34c17 100644 --- a/templates/index.html.j2 +++ b/templates/index.html.j2 @@ -28,7 +28,7 @@