8 Commits

Author SHA1 Message Date
9de971d2ac Fixed package detection 2024-08-14 10:46:05 +02:00
e0cb13771c formatting 2024-07-24 17:39:47 +02:00
cd3f2959c0 upsii 2024-07-24 13:17:07 +02:00
285d286baf fixed dependency issue 2024-07-18 09:59:16 +02:00
08299abd2a added class constructor and regenerate now deletes .previews 2024-07-18 09:17:55 +02:00
d76d2e146d okidokili 2024-07-17 15:47:51 +02:00
f52b0e7778 idfk 2024-07-17 15:45:53 +02:00
d6a4e1cc82 please work 2024-07-17 15:39:15 +02:00
27 changed files with 86 additions and 50 deletions

View File

@@ -1,6 +1,6 @@
name: build-release
run-name: build-release
on: [push]
on: push
jobs:
build:
runs-on: ubuntu-latest
@@ -15,8 +15,9 @@ jobs:
run: pyinstaller builder.py modules/*.py -n StaticGalleryBuilder -F --add-data files:files --add-data templates:templates --add-data .version:.
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
make_latest: true
generate_release_notes: true
files: |
dist/StaticGalleryBuilder
dist/StaticGalleryBuilder

View File

@@ -1 +1 @@
2.2.5
2.2.7

View File

@@ -17,11 +17,13 @@ from modules.generate_html import list_folder, EXCLUDES
# fmt: off
# Constants
if __package__ == None:
__package__ = ""
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__).removesuffix(__package__))
STATIC_FILES_DIR = os.path.join(os.path.abspath(SCRIPT_DIR), "files")
VERSION = open(os.path.join(SCRIPT_DIR, ".version"), "r", encoding="utf-8").read()
if __package__ is None:
PACKAGE = ""
else:
PACKAGE = __package__
SCRIPTDIR = os.path.abspath(os.path.dirname(__file__).removesuffix(PACKAGE))
STATIC_FILES_DIR = os.path.join(os.path.abspath(SCRIPTDIR), "files")
VERSION = open(os.path.join(SCRIPTDIR, ".version"), "r", encoding="utf-8").read()
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",
@@ -94,7 +96,7 @@ def copy_static_files(_args: Args) -> None:
if "url" in foldericon:
shutil.copyfile(_args.theme_path, os.path.join(static_dir, "theme.css"))
return
with open(os.path.join(SCRIPT_DIR, foldericon), "r", encoding="utf-8") as f:
with open(os.path.join(SCRIPTDIR, foldericon), "r", encoding="utf-8") as f:
svg = f.read()
if "svg.j2" in foldericon:
colorscheme = extract_colorscheme(_args.theme_path)
@@ -159,7 +161,7 @@ def get_total_folders(folder: str, _args: Args, _total: int = 0) -> int:
items = sorted(os.listdir(folder))
for item in items:
if item not in EXCLUDES and os.path.isdir(os.path.join(folder, item)):
if item not in EXCLUDES and os.path.isdir(os.path.join(folder, item)) and not item.startswith("."):
if item not in _args.exclude_folders and not any(fnmatch.fnmatchcase(os.path.join(folder, item), exclude) for exclude in _args.exclude_folders):
_total = get_total_folders(os.path.join(folder, item), _args, _total)
return _total
@@ -181,6 +183,9 @@ def main() -> None:
try:
Path(lock_file).touch()
if args.regenerate_thumbnails:
if os.path.exists(os.path.join(args.root_directory, ".thumbnails")):
shutil.rmtree(os.path.join(args.root_directory, ".thumbnails"))
os.makedirs(os.path.join(args.root_directory, ".thumbnails"), exist_ok=True)
copy_static_files(args)

View File

@@ -1,15 +1,19 @@
from dataclasses import dataclass
from typing import List, Optional
import os
import argparse
from rich_argparse import RichHelpFormatter, HelpPreviewAction
if __package__ == None:
__package__ = ""
DEFAULT_THEME_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__).removesuffix(__package__)), "templates", "default.css")
if __package__ is None:
PACKAGE = ""
else:
PACKAGE = __package__
SCRIPTDIR = os.path.abspath(os.path.dirname(__file__).removesuffix(PACKAGE))
DEFAULT_THEME_PATH = os.path.join(SCRIPTDIR, "templates", "default.css")
DEFAULT_AUTHOR = "Author"
@dataclass(init=True)
class Args:
"""
A class to store command-line arguments for the script.
@@ -58,6 +62,24 @@ class Args:
use_fancy_folders: bool
web_root_url: str
def to_dict(self) -> dict:
result: dict = {}
result["author_name"] = self.author_name
result["exclude_folders"] = self.exclude_folders
result["file_extensions"] = self.file_extensions
result["generate_webmanifest"] = self.generate_webmanifest
result["ignore_other_files"] = self.ignore_other_files
if self.license_type is not None:
result["license_type"] = self.license_type
result["non_interactive_mode"] = self.non_interactive_mode
result["regenerate_thumbnails"] = self.regenerate_thumbnails
result["root_directory"] = self.root_directory
result["site_title"] = self.site_title
result["theme_path"] = self.theme_path
result["use_fancy_folders"] = self.use_fancy_folders
result["web_root_url"] = self.web_root_url
return result
def parse_arguments(version: str) -> Args:
"""
@@ -73,6 +95,7 @@ def parse_arguments(version: str) -> Args:
Args
An instance of the Args class containing the parsed arguments.
"""
# fmt: off
parser = argparse.ArgumentParser(description="Generate HTML files for a static image hosting website.", formatter_class=RichHelpFormatter)
parser.add_argument("--exclude-folder", help="Folders to exclude from processing, globs supported (can be specified multiple times).", action="append", dest="exclude_folders", metavar="FOLDER")
parser.add_argument("--generate-help-preview", action=HelpPreviewAction, path="help.svg")
@@ -90,18 +113,20 @@ def parse_arguments(version: str) -> Args:
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("-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")
parsed_args = parser.parse_args()
_args = Args()
_args.author_name = parsed_args.author_name
_args.exclude_folders = parsed_args.exclude_folders
_args.file_extensions = parsed_args.file_extensions
_args.generate_webmanifest = parsed_args.generate_webmanifest
_args.ignore_other_files = parsed_args.ignore_other_files
_args.license_type = parsed_args.license_type
_args.non_interactive_mode = parsed_args.non_interactive_mode
_args.regenerate_thumbnails = parsed_args.regenerate_thumbnails
_args.root_directory = parsed_args.root_directory
_args.site_title = parsed_args.site_title
_args.theme_path = parsed_args.theme_path
_args.use_fancy_folders = parsed_args.use_fancy_folders
_args.web_root_url = parsed_args.web_root_url
# fmt: on
_args = Args(
author_name=parsed_args.author_name,
exclude_folders=parsed_args.exclude_folders,
file_extensions=parsed_args.file_extensions,
generate_webmanifest=parsed_args.generate_webmanifest,
ignore_other_files=parsed_args.ignore_other_files,
license_type=parsed_args.license_type,
non_interactive_mode=parsed_args.non_interactive_mode,
regenerate_thumbnails=parsed_args.regenerate_thumbnails,
root_directory=parsed_args.root_directory,
site_title=parsed_args.site_title,
theme_path=parsed_args.theme_path,
use_fancy_folders=parsed_args.use_fancy_folders,
web_root_url=parsed_args.web_root_url,
)
return _args

View File

@@ -13,8 +13,11 @@ import modules.cclicense as cclicense
from modules.argumentparser import Args
# Constants for file paths and exclusions
if __package__ == None:
__package__ = ""
if __package__ is None:
PACKAGE = ""
else:
PACKAGE = __package__
SCRIPTDIR = os.path.abspath(os.path.dirname(__file__).removesuffix(PACKAGE))
FAVICON_PATH = ".static/favicon.ico"
GLOBAL_CSS_PATH = ".static/global.css"
EXCLUDES = ["index.html", "manifest.json", "robots.txt"]
@@ -23,7 +26,7 @@ EXCLUDES = ["index.html", "manifest.json", "robots.txt"]
Image.MAX_IMAGE_PIXELS = 933120000
# Initialize Jinja2 environment for template rendering
env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath(os.path.dirname(__file__).removesuffix(__package__)), "templates")))
env = Environment(loader=FileSystemLoader(os.path.join(SCRIPTDIR, "templates")))
thumbnails: List[Tuple[str, str]] = []
info: Dict[str, str] = {}
pbardict: Dict[str, tqdm] = {}

View File

@@ -14,16 +14,19 @@ except ImportError:
SVGSUPPORT = False
from modules.argumentparser import Args
from modules.css_color import css_color_to_hex, extract_theme_color, extract_colorscheme
from modules.css_color import extract_theme_color, extract_colorscheme
# Define constants for static files directory and icon sizes
if __package__ == None:
__package__ = ""
STATIC_FILES_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__).removesuffix(__package__)), "files")
if __package__ is None:
PACKAGE = ""
else:
PACKAGE = __package__
SCRIPTDIR = os.path.abspath(os.path.dirname(__file__).removesuffix(PACKAGE))
STATIC_FILES_DIR = os.path.join(SCRIPTDIR, "files")
ICON_SIZES = ["36x36", "48x48", "72x72", "96x96", "144x144", "192x192", "512x512"]
# Initialize Jinja2 environment for template rendering
env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath(os.path.dirname(__file__).removesuffix(__package__)), "templates")))
env = Environment(loader=FileSystemLoader(os.path.join(SCRIPTDIR, "templates")))
class Icon:

View File

@@ -4,4 +4,5 @@ numpy==2.0.0
pillow==10.4.0
pyinstaller==6.9.0
rich-argparse==1.5.2
setuptools==70.3.0
tqdm==4.66.4

View File

@@ -12,19 +12,17 @@
--bcolor2: #20123b;
--bcolor3: #2b1753;
--bcolor4: #321c64;
--gradient: linear-gradient(
80deg,
var(--bcolor2) 0%,
var(--color3) 1%,
var(--color4) 2%,
var(--color5) 3%,
var(--color1) 4%,
var(--color1) 96%,
var(--color5) 97%,
var(--color4) 98%,
var(--color3) 99%,
var(--bcolor2) 100%
);
--gradient: linear-gradient(80deg,
var(--bcolor2) 0%,
var(--color3) 1%,
var(--color4) 2%,
var(--color5) 3%,
var(--color1) 4%,
var(--color1) 96%,
var(--color5) 97%,
var(--color4) 98%,
var(--color3) 99%,
var(--bcolor2) 100%);
}
body {
@@ -110,4 +108,4 @@ body {
background-color: var(--color2);
color: var(--bcolor2);
font-weight: 600;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 MiB

After

Width:  |  Height:  |  Size: 1.5 MiB