update to v1.4:

- major restructure
- added classes for args and cclicense
- separated global variable setting into separate function
- argument parse in separate function
This commit is contained in:
2024-07-01 10:24:30 +02:00
committed by Flo Greistorfer
parent 2c93e6c858
commit d6c1ad5176
3 changed files with 196 additions and 190 deletions

View File

@@ -37,25 +37,25 @@ pip install numpy tqdm Jinja2
The script supports several command-line options to customize its behavior. Below is the list of available options:
```sh
./generate_html.py [-h] -p ROOT -w WEBROOT -t TITLE [-i ICON] [-r] [-n] [--fancyfolders] [-l LICENSE] [-a AUTHOR] [-e EXTENSION] [--theme THEME] [--ignore-other-files] [--exclude EXCLUDE]
./generate_html.py [-h] -p ROOT -w WEBROOT -t TITLE [-i ICON] [-r] [-n] [--use-fancy-folders] [-l LICENSE] [-a AUTHOR] [-e EXTENSION] [--theme-path THEME] [--ignore-other-files] [--exclude-folders EXCLUDE]
```
### Options
- `-h, --help`: Show the help message and exit.
- `-p ROOT, --root ROOT`: Specify the root folder where the images are stored. This option is required.
- `-w WEBROOT, --webroot WEBROOT`: Specify the web root URL where the images will be accessible. This option is required.
- `-t TITLE, --title TITLE`: Specify the title for the root directory HTML file. This option is required.
- `-i ICON, --foldericon ICON`: Specify the URL for the folder icon. Default is `https://www.svgrepo.com/show/400249/folder.svg`.
- `-r, --regenerate`: Regenerate thumbnails even if they already exist.
- `-n, --non-interactive`: Disable interactive mode, which is useful for automated workflows.
- `--fancyfolders`: Use fancy folders instead of the default Apache directory listing.
- `-l LICENSE, --license 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 AUTHOR`: Specify the author of the content. Default is "Author".
- `-e EXTENSION, --extension EXTENSION`: Specify file extensions to include. This option can be used multiple times.
- `--theme THEME`: Specify the path to a custom CSS theme file. Default is `themes/default.css`.
- `-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.
- `-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 EXCLUDE`: Exclude folders from processing. Only provide the basename of the folders you want to exclude. This option can be used multiple times.
- `--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.
### Example
@@ -71,7 +71,7 @@ To regenerate thumbnails and run in non-interactive mode:
./generate_html.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" -r -n
```
To include a license, author, and custom title:
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"
@@ -80,22 +80,22 @@ To include a license, author, and custom title:
To specify a custom CSS theme:
```sh
./generate_html.py -p /data/pictures -w https://pictures.example.com -t "My Photo Gallery" --theme custom_theme.css
./generate_html.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 Archives --exclude Temp -e .jpg -e .jpeg -e .png
./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
```
## Notes
- The root and webroot paths must point to the same folder, one on the filesystem and one on the webserver. Use absolute paths.
- The root and web root paths must point to the same folder, one on the filesystem and one on the web server. Use absolute paths.
- Ensure that ImageMagick is installed and accessible in your system for thumbnail generation.
- The script generates the preview thumbnails in a `.thumbnails` subdirectory within the root folder.
- The `.lock` file prevents multiple instances of the script from running simultaneously. Make sure to remove it if the script terminates unexpectedly.
## License
This project is licensed under the AGPL-3.0 License. See the [LICENSE](LICENSE) file for details.
This project is licensed under the AGPL-3.0 License. See the [LICENSE](LICENSE) file for details.