diff --git a/README.md b/README.md index 639bc2f..2ad9a34 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ - **Folder Exclusion:** Ability to exclude specific folders from processing. - **Selective File Extensions:** Ability to specify which file extensions to include in the gallery. - **Ignore Other Files:** Option to ignore files other than those specified by the included extensions. +- **Info Tooltips:** Display additional information as tooltips for images if an `info` file is present in the directory. ## Requirements @@ -43,48 +44,49 @@ The script supports several command-line options to customize its behavior. Belo - `-h, --help`: Show the help message and exit. - `-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. +- `-w URL, --web-root-url URL`: Specify the base URL for the web root of the image hosting site. This option is required. +- `-t TITLE, --site-title TITLE`: Specify the title of the image hosting site. This option is required. - `-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. -- `-l LICENSE, --license-type LICENSE`: Specify a license for the content. Options are `cc-zero`, `cc-by`, `cc-by-sa`, `cc-by-nd`, `cc-by-nc`, `cc-by-nc-sa`, and `cc-by-nc-nd`. -- `-a AUTHOR, --author-name AUTHOR`: Specify the author of the content. Default is "Author". -- `-e EXTENSION, --file-extensions EXTENSION`: Specify file extensions to include. This option can be used multiple times. -- `--theme-path THEME`: Specify the path to a custom CSS theme file. Default is `themes/default.css`. -- `--ignore-other-files`: Ignore files other than those specified by the included extensions. -- `--exclude-folder EXCLUDE`: Exclude folders from processing. Only provide the basename of the folders you want to exclude. This option can be used multiple times. +- `-n, --non-interactive-mode`: Run in non-interactive mode, disabling progress bars. +- `-l LICENSE, --license-type LICENSE`: Specify the license type for the images. Choices are `cc-zero`, `cc-by`, `cc-by-sa`, `cc-by-nd`, `cc-by-nc`, `cc-by-nc-sa`, and `cc-by-nc-nd`. +- `-a AUTHOR, --author-name AUTHOR`: Specify the name of the author of the images. Default is "Author". +- `-e EXTENSION, --file-extensions EXTENSION`: Specify the file extensions to include. This option can be specified multiple times. +- `--theme-path PATH`: Specify the path to the CSS theme file. Default is the provided default theme. +- `--use-fancy-folders`: Enable fancy folder view instead of the default Apache directory listing. +- `--ignore-other-files`: Ignore files that do not match the specified extensions. +- `--exclude-folder FOLDER`: Specify folders to exclude from processing. This option can be specified multiple times. +- `--version`: Show the version number of the script and exit. -### Example +### Examples To generate HTML files and thumbnails for a directory `/data/pictures` and host them on `https://pictures.example.com`, run: ```sh -./generate_html.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" +./builder.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" ``` To regenerate thumbnails and run in non-interactive mode: ```sh -./generate_html.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" -r -n +./builder.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" -r -n ``` To include a license and author: ```sh -./generate_html.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" -l cc-by -a "John Doe" +./builder.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" -l cc-by -a "John Doe" ``` To specify a custom CSS theme: ```sh -./generate_html.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" --theme-path custom_theme.css +./builder.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" --theme-path custom_theme.css ``` To exclude specific folders and specify file extensions: ```sh -./generate_html.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" --exclude-folder Archives --exclude-folders Temp -e .jpg -e .jpeg -e .png +./builder.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" --exclude-folder Archives --exclude-folder Temp -e .jpg -e .jpeg -e .png ``` ## Notes diff --git a/builder.py b/builder.py index 333f5b7..89858be 100755 --- a/builder.py +++ b/builder.py @@ -10,7 +10,7 @@ import numpy as np from jinja2 import Environment, FileSystemLoader from tqdm.auto import tqdm from PIL import Image -from rich_argparse import RichHelpFormatter +from rich_argparse import RichHelpFormatter, HelpPreviewAction import cclicense @@ -21,7 +21,7 @@ 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.6.1" +VERSION = "1.7.0" 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"] @@ -52,20 +52,20 @@ class Args: # fmt: off def parse_arguments() -> Args: parser = argparse.ArgumentParser(description="Generate HTML files for a static image hosting website.", formatter_class=RichHelpFormatter) - 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("-p", "--root-directory", help="Root directory containing the images.", required=True, type=str, dest="root_directory", metavar="ROOT") + 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", metavar="URL") + parser.add_argument("-t", "--site-title", help="Title of the image hosting site.", required=True, type=str, dest="site_title", metavar="TITLE") 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") - parser.add_argument("-a", "--author-name", help="Name of the author of the images.", default=DEFAULT_AUTHOR, type=str, dest="author_name") - parser.add_argument("-e", "--file-extensions", help="File extensions to include (can be specified multiple times).", action="append", dest="file_extensions") - parser.add_argument("--theme-path", help="Path to the CSS theme file.", default=DEFAULT_THEME_PATH, type=str, dest="theme_path") + 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", metavar="LICENSE") + parser.add_argument("-a", "--author-name", help="Name of the author of the images.", default=DEFAULT_AUTHOR, type=str, dest="author_name", metavar="AUTHOR") + parser.add_argument("-e", "--file-extensions", help="File extensions to include (can be specified multiple times).", action="append", dest="file_extensions", metavar="EXTENSION") + parser.add_argument("--theme-path", help="Path to the CSS theme file.", default=DEFAULT_THEME_PATH, type=str, dest="theme_path", metavar="PATH") parser.add_argument("--use-fancy-folders", help="Enable fancy folder view instead of the default Apache directory listing.", action="store_true", default=False, dest="use_fancy_folders") parser.add_argument("--ignore-other-files", help="Ignore files that do not match the specified extensions.", action="store_true", default=False, dest="ignore_other_files") - parser.add_argument("--exclude-folder", help="Folders to exclude from processing (can be specified multiple times).", action="append", dest="exclude_folders") + parser.add_argument("--exclude-folder", help="Folders to exclude from processing (can be specified multiple times).", action="append", dest="exclude_folders", metavar="FOLDER") parser.add_argument("--version", action="version", version=f"%(prog)s {VERSION}") - + parser.add_argument("--generate-help-preview", action=HelpPreviewAction, path="help.svg") parsed_args = parser.parse_args() _args = Args() _args.root_directory = parsed_args.root_directory diff --git a/help.svg b/help.svg index 0f8dbfb..f6d53b5 100644 --- a/help.svg +++ b/help.svg @@ -1,184 +1,285 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - Usage:generate_html.py [-h-pROOT_DIRECTORY-wWEB_ROOT_URL-tSITE_TITLE [-r] [-n] -                        [-l{cc-zero,cc-by,cc-by-sa,cc-by-nd,cc-by-nc,cc-by-nc-sa,cc-by-nc-nd}] [-aAUTHOR_NAME] -                        [-eFILE_EXTENSIONS] [--theme-pathTHEME_PATH] [--use-fancy-folders] [--ignore-other-files] -                        [--exclude-folderEXCLUDE_FOLDERS] [--version] - -Generate HTML files for a static image hosting website. - -Options: --h--helpshow this help message and exit --p--root-directoryROOT_DIRECTORY -Root directory containing the images. --w--web-root-urlWEB_ROOT_URL -Base URL of the web root for the image hosting site. --t--site-titleSITE_TITLE -Title of the image hosting site. --r--regenerate-thumbnails -Regenerate thumbnails even if they already exist. --n--non-interactive-mode -Run in non-interactive mode, disabling progress bars. --l--license-type{cc-zero,cc-by,cc-by-sa,cc-by-nd,cc-by-nc,cc-by-nc-sa,cc-by-nc-nd} -Specify the license type for the images. --a--author-nameAUTHOR_NAME -Name of the author of the images. --e--file-extensionsFILE_EXTENSIONS -File extensions to include (can be specified multiple times). ---theme-pathTHEME_PATH -Path to the CSS theme file. ---use-fancy-foldersEnable fancy folder view instead of the default Apache directory listing. ---ignore-other-filesIgnore files that do not match the specified extensions. ---exclude-folderEXCLUDE_FOLDERS -Folders to exclude from processing (can be specified multiple times). ---versionshow program's version number and exit - + + + + + + + + + + Usage:builder.py [-h-pROOT-wURL-tTITLE [-r] [-n] [-lLICENSE] [-aAUTHOR] [-eEXTENSION] [--theme-pathPATH] +                   [--use-fancy-folders] [--ignore-other-files] [--exclude-folderFOLDER] [--version] + + Generate HTML files for a static image hosting website. + + Options: + -h--helpshow this help message and exit + -p--root-directoryROOT + Root directory containing the images. + -w--web-root-urlURL + Base URL of the web root for the image hosting site. + -t--site-titleTITLE + Title of the image hosting site. + -r--regenerate-thumbnails + Regenerate thumbnails even if they already exist. + -n--non-interactive-mode + Run in non-interactive mode, disabling progress bars. + -l--license-typeLICENSE + Specify the license type for the images. + -a--author-nameAUTHOR + Name of the author of the images. + -e--file-extensionsEXTENSION + File extensions to include (can be specified multiple times). + --theme-pathPATHPath to the CSS theme file. + --use-fancy-foldersEnable fancy folder view instead of the default Apache directory listing. + --ignore-other-filesIgnore files that do not match the specified extensions. + --exclude-folderFOLDER + Folders to exclude from processing (can be specified multiple times). + --versionshow program's version number and exit + + - + \ No newline at end of file