mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 02:59:27 +00:00
Compare commits
7 Commits
d1f7f62229
...
895ac03590
| Author | SHA1 | Date | |
|---|---|---|---|
| 895ac03590 | |||
| cad6d88b22 | |||
| e06df9444d | |||
| 9d5ce13e14 | |||
| 6593e63ea9 | |||
| 027a5688cb | |||
| 1aa9dd716b |
2
.github/workflows/build-release.yml
vendored
2
.github/workflows/build-release.yml
vendored
@@ -9,6 +9,8 @@ jobs:
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.12'
|
||||
- name: Install PyInstaller
|
||||
run: pip install pyinstaller
|
||||
- name: Install Dependencies
|
||||
run: pip install -r requirements.txt
|
||||
- name: Build Package
|
||||
|
||||
@@ -218,7 +218,7 @@ def main(args) -> None:
|
||||
shutil.rmtree(thumbdir)
|
||||
os.makedirs(thumbdir, exist_ok=True)
|
||||
|
||||
darktheme = copy_static_files(args)
|
||||
args.darktheme = copy_static_files(args)
|
||||
icons(args)
|
||||
|
||||
if args.generate_webmanifest:
|
||||
@@ -228,13 +228,13 @@ def main(args) -> None:
|
||||
if args.non_interactive_mode:
|
||||
logger.info("generating HTML files")
|
||||
print("Generating HTML files...")
|
||||
thumbnails = list_folder(args.root_directory, args.site_title, args, raw, VERSION, logo, darktheme=darktheme)
|
||||
thumbnails = list_folder(args.root_directory, args.site_title, args, raw, VERSION, logo)
|
||||
with Pool(os.cpu_count()) as pool:
|
||||
logger.info("generating thumbnails")
|
||||
print("Generating thumbnails...")
|
||||
pool.map(generate_thumbnail, thumbnails)
|
||||
else:
|
||||
thumbnails = list_folder(args.root_directory, args.site_title, args, raw, VERSION, logo, darktheme=darktheme)
|
||||
thumbnails = list_folder(args.root_directory, args.site_title, args, raw, VERSION, logo)
|
||||
|
||||
with Pool(os.cpu_count()) as pool:
|
||||
logger.info("generating thumbnails")
|
||||
|
||||
@@ -302,6 +302,11 @@ input {
|
||||
border-style: none;
|
||||
}
|
||||
|
||||
.darkmodeswitch {
|
||||
font-size: smaller;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#dark-mode-switch {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -12,7 +12,7 @@ except ModuleNotFoundError:
|
||||
RICH = False
|
||||
|
||||
|
||||
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__)).removesuffix(__package__)
|
||||
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__)).removesuffix(__package__ if __package__ else "")
|
||||
DEFAULT_THEME_PATH = os.path.join(SCRIPTDIR, "templates", "default.css")
|
||||
DEFAULT_AUTHOR = "Author"
|
||||
|
||||
@@ -60,6 +60,8 @@ class Args:
|
||||
Whether to enable fancy folder view.
|
||||
web_root_url : str
|
||||
The base URL of the web root for the image hosting site.
|
||||
darktheme : bool
|
||||
Whether a dark theme is present.
|
||||
"""
|
||||
|
||||
author_name: str
|
||||
@@ -80,6 +82,7 @@ class Args:
|
||||
theme_path: str
|
||||
use_fancy_folders: bool
|
||||
web_root_url: str
|
||||
darktheme: bool = False
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
result: dict = {}
|
||||
@@ -102,6 +105,7 @@ class Args:
|
||||
result["theme_path"] = self.theme_path
|
||||
result["use_fancy_folders"] = self.use_fancy_folders
|
||||
result["web_root_url"] = self.web_root_url
|
||||
result["darktheme"] = self.darktheme
|
||||
return result
|
||||
|
||||
|
||||
@@ -172,5 +176,6 @@ def parse_arguments(version: str) -> Args:
|
||||
theme_path=parsed_args.theme_path,
|
||||
use_fancy_folders=parsed_args.use_fancy_folders,
|
||||
web_root_url=parsed_args.web_root_url,
|
||||
darktheme=False,
|
||||
)
|
||||
return _args
|
||||
|
||||
@@ -20,7 +20,7 @@ from modules.argumentparser import Args
|
||||
from modules.datatypes.metadata import Metadata, ImageMetadata, SubfolderMetadata
|
||||
|
||||
# Constants for file paths and exclusions
|
||||
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__)).removesuffix(__package__)
|
||||
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__)).removesuffix(__package__ if __package__ else "")
|
||||
FAVICON_PATH = ".static/favicon.ico"
|
||||
GLOBAL_CSS_PATH = ".static/global.css"
|
||||
EXCLUDES = ["index.html", "manifest.json", "robots.txt"]
|
||||
@@ -389,7 +389,7 @@ def process_image(item: str, folder: str, _args: Args, baseurl: str, metadata: M
|
||||
return image, metadata
|
||||
|
||||
|
||||
def generate_html(folder: str, title: str, _args: Args, raw: list[str], version: str, logo: str, darktheme: bool = False) -> set[str]:
|
||||
def generate_html(folder: str, title: str, _args: Args, raw: list[str], version: str, logo: str) -> set[str]:
|
||||
"""
|
||||
Generates HTML content for a folder of images.
|
||||
|
||||
@@ -459,7 +459,7 @@ def generate_html(folder: str, title: str, _args: Args, raw: list[str], version:
|
||||
update_metadata(metadata, folder)
|
||||
|
||||
if should_generate_html(images, contains_files, _args):
|
||||
subfoldertags = create_html_file(folder, title, foldername, images, subfolders, _args, version, logo, subfoldertags, darktheme=darktheme)
|
||||
subfoldertags = create_html_file(folder, title, foldername, images, subfolders, _args, version, logo, subfoldertags)
|
||||
else:
|
||||
if os.path.exists(os.path.join(folder, "index.html")):
|
||||
logger.info("removing existing index.html", extra={"folder": folder})
|
||||
@@ -564,16 +564,7 @@ def format_html(html: str) -> str:
|
||||
|
||||
|
||||
def create_html_file(
|
||||
folder: str,
|
||||
title: str,
|
||||
foldername: str,
|
||||
images: list[ImageMetadata],
|
||||
subfolders: list[SubfolderMetadata],
|
||||
_args: Args,
|
||||
version: str,
|
||||
logo: str,
|
||||
subfoldertags: set[str],
|
||||
darktheme: bool = False,
|
||||
folder: str, title: str, foldername: str, images: list[ImageMetadata], subfolders: list[SubfolderMetadata], _args: Args, version: str, logo: str, subfoldertags: set[str]
|
||||
) -> set[str]:
|
||||
"""
|
||||
Creates the HTML file using the template.
|
||||
@@ -630,7 +621,7 @@ def create_html_file(
|
||||
favicon=f"{_args.web_root_url}{FAVICON_PATH}",
|
||||
stylesheet=f"{_args.web_root_url}{GLOBAL_CSS_PATH}",
|
||||
theme=f"{_args.web_root_url}.static/theme.css",
|
||||
darktheme=f"{_args.web_root_url}.static/theme-dark.css" if darktheme else None,
|
||||
darktheme=f"{_args.web_root_url}.static/theme-dark.css" if _args.darktheme else None,
|
||||
root=_args.web_root_url,
|
||||
parent=f"{_args.web_root_url}{urllib.parse.quote(foldername)}",
|
||||
header=f"{header} - LICENSE",
|
||||
@@ -648,7 +639,7 @@ def create_html_file(
|
||||
favicon=f"{_args.web_root_url}{FAVICON_PATH}",
|
||||
stylesheet=f"{_args.web_root_url}{GLOBAL_CSS_PATH}",
|
||||
theme=f"{_args.web_root_url}.static/theme.css",
|
||||
darktheme=f"{_args.web_root_url}.static/theme-dark.css" if darktheme else None,
|
||||
darktheme=f"{_args.web_root_url}.static/theme-dark.css" if _args.darktheme else None,
|
||||
root=_args.web_root_url,
|
||||
parent=parent,
|
||||
header=header,
|
||||
@@ -669,7 +660,7 @@ def create_html_file(
|
||||
return set(sorted(alltags))
|
||||
|
||||
|
||||
def list_folder(folder: str, title: str, _args: Args, raw: list[str], version: str, logo: str, darktheme: bool = False) -> list[tuple[str, str, str]]:
|
||||
def list_folder(folder: str, title: str, _args: Args, raw: list[str], version: str, logo: str) -> list[tuple[str, str, str]]:
|
||||
"""
|
||||
lists and processes a folder, generating HTML files.
|
||||
|
||||
@@ -683,5 +674,5 @@ def list_folder(folder: str, title: str, _args: Args, raw: list[str], version: s
|
||||
Returns:
|
||||
list[tuple[str, str]]: list of thumbnails generated.
|
||||
"""
|
||||
generate_html(folder, title, _args, raw, version, logo, darktheme=darktheme)
|
||||
generate_html(folder, title, _args, raw, version, logo)
|
||||
return thumbnails
|
||||
|
||||
@@ -18,10 +18,10 @@ import gzip
|
||||
import shutil
|
||||
import logging
|
||||
from datetime import datetime
|
||||
from pythonjsonlogger import jsonlogger
|
||||
from pythonjsonlogger import json as jsonlogger
|
||||
|
||||
# Constants for file paths and exclusions
|
||||
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__)).removesuffix(__package__)
|
||||
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__)).removesuffix(__package__ if __package__ else "")
|
||||
LOG_DIR = os.path.join(SCRIPTDIR, "logs")
|
||||
LATEST_LOG_FILE = os.path.join(LOG_DIR, "latest.jsonl")
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ except ImportError:
|
||||
|
||||
from modules.logger import logger
|
||||
from modules.argumentparser import Args
|
||||
from modules.css_color import extract_theme_color, extract_colorscheme
|
||||
from modules.css_color import extract_colorscheme
|
||||
|
||||
# Define constants for static files directory and icon sizes
|
||||
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__)).removesuffix(__package__)
|
||||
SCRIPTDIR = os.path.dirname(os.path.realpath(__file__)).removesuffix(__package__ if __package__ else "")
|
||||
STATIC_FILES_DIR = os.path.join(SCRIPTDIR, "files")
|
||||
ICON_SIZES = ["36x36", "48x48", "72x72", "96x96", "144x144", "192x192", "512x512"]
|
||||
|
||||
@@ -148,7 +148,7 @@ def render_manifest_json(_args: Args, icon_list: list[Icon], colors: dict[str, s
|
||||
short_name=_args.site_title,
|
||||
icons=icon_list,
|
||||
background_color=colors["bcolor1"],
|
||||
theme_color=colors["theme_color"],
|
||||
theme_color=colors["color1"],
|
||||
)
|
||||
with open(os.path.join(_args.root_directory, ".static", "manifest.webmanifest"), "w", encoding="utf-8") as f:
|
||||
logger.info("rendering manifest.webmanifest", extra={"path": os.path.join(_args.root_directory, ".static", "manifest.webmanifest")})
|
||||
@@ -262,5 +262,4 @@ def webmanifest(_args: Args) -> None:
|
||||
return
|
||||
|
||||
colorscheme = extract_colorscheme(os.path.join(_args.root_directory, ".static", "theme.css"))
|
||||
colorscheme["theme_color"] = extract_theme_color(os.path.join(_args.root_directory, ".static", "theme.css"))
|
||||
render_manifest_json(_args, icon_list, colorscheme)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
beautifulsoup4~=4.13.4
|
||||
beautifulsoup4~=4.14.3
|
||||
CairoSVG~=2.7.1
|
||||
ConfigArgParse~=1.7.1
|
||||
defusedxml~=0.7.1
|
||||
html5lib~=1.1
|
||||
Jinja2~=3.1.6
|
||||
jsmin~=3.0.1
|
||||
Pillow~=11.3.0
|
||||
pyinstaller~=6.11.1
|
||||
Pillow~=12.1.0
|
||||
python_json_logger~=2.0.7
|
||||
rich_argparse~=1.7.1
|
||||
selenium~=4.34.2
|
||||
tqdm~=4.66.4
|
||||
rich_argparse~=1.7.2
|
||||
selenium~=4.40.0
|
||||
tqdm~=4.66.6
|
||||
|
||||
@@ -100,7 +100,7 @@
|
||||
<li class="license"><a href="{{ licensefile }}">License</a></li>
|
||||
{%- endif %}
|
||||
{%- if darktheme %}
|
||||
<li>
|
||||
<li class="darkmodeswitch">
|
||||
<a class="button" id="dark-mode-switch">
|
||||
<input type="checkbox" class="checkbox" id="dark-mode-switch-check" />
|
||||
<div class="knobs">
|
||||
|
||||
2
themes
2
themes
Submodule themes updated: 51696f2a4d...3bb36480e7
Reference in New Issue
Block a user