mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 02:59:27 +00:00
recursive darktheme applied
This commit is contained in:
@@ -218,7 +218,7 @@ def main(args) -> None:
|
|||||||
shutil.rmtree(thumbdir)
|
shutil.rmtree(thumbdir)
|
||||||
os.makedirs(thumbdir, exist_ok=True)
|
os.makedirs(thumbdir, exist_ok=True)
|
||||||
|
|
||||||
darktheme = copy_static_files(args)
|
args.darktheme = copy_static_files(args)
|
||||||
icons(args)
|
icons(args)
|
||||||
|
|
||||||
if args.generate_webmanifest:
|
if args.generate_webmanifest:
|
||||||
@@ -228,13 +228,13 @@ def main(args) -> None:
|
|||||||
if args.non_interactive_mode:
|
if args.non_interactive_mode:
|
||||||
logger.info("generating HTML files")
|
logger.info("generating HTML files")
|
||||||
print("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:
|
with Pool(os.cpu_count()) as pool:
|
||||||
logger.info("generating thumbnails")
|
logger.info("generating thumbnails")
|
||||||
print("Generating thumbnails...")
|
print("Generating thumbnails...")
|
||||||
pool.map(generate_thumbnail, thumbnails)
|
pool.map(generate_thumbnail, thumbnails)
|
||||||
else:
|
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:
|
with Pool(os.cpu_count()) as pool:
|
||||||
logger.info("generating thumbnails")
|
logger.info("generating thumbnails")
|
||||||
|
|||||||
@@ -302,6 +302,11 @@ input {
|
|||||||
border-style: none;
|
border-style: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.darkmodeswitch {
|
||||||
|
font-size: smaller;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
#dark-mode-switch {
|
#dark-mode-switch {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@@ -60,6 +60,8 @@ class Args:
|
|||||||
Whether to enable fancy folder view.
|
Whether to enable fancy folder view.
|
||||||
web_root_url : str
|
web_root_url : str
|
||||||
The base URL of the web root for the image hosting site.
|
The base URL of the web root for the image hosting site.
|
||||||
|
darktheme : bool
|
||||||
|
Whether a dark theme is present.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
author_name: str
|
author_name: str
|
||||||
@@ -80,6 +82,7 @@ class Args:
|
|||||||
theme_path: str
|
theme_path: str
|
||||||
use_fancy_folders: bool
|
use_fancy_folders: bool
|
||||||
web_root_url: str
|
web_root_url: str
|
||||||
|
darktheme: bool = False
|
||||||
|
|
||||||
def to_dict(self) -> dict:
|
def to_dict(self) -> dict:
|
||||||
result: dict = {}
|
result: dict = {}
|
||||||
@@ -102,6 +105,7 @@ class Args:
|
|||||||
result["theme_path"] = self.theme_path
|
result["theme_path"] = self.theme_path
|
||||||
result["use_fancy_folders"] = self.use_fancy_folders
|
result["use_fancy_folders"] = self.use_fancy_folders
|
||||||
result["web_root_url"] = self.web_root_url
|
result["web_root_url"] = self.web_root_url
|
||||||
|
result["darktheme"] = self.darktheme
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
@@ -172,5 +176,6 @@ def parse_arguments(version: str) -> Args:
|
|||||||
theme_path=parsed_args.theme_path,
|
theme_path=parsed_args.theme_path,
|
||||||
use_fancy_folders=parsed_args.use_fancy_folders,
|
use_fancy_folders=parsed_args.use_fancy_folders,
|
||||||
web_root_url=parsed_args.web_root_url,
|
web_root_url=parsed_args.web_root_url,
|
||||||
|
darktheme=False,
|
||||||
)
|
)
|
||||||
return _args
|
return _args
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ def process_image(item: str, folder: str, _args: Args, baseurl: str, metadata: M
|
|||||||
return image, metadata
|
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.
|
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)
|
update_metadata(metadata, folder)
|
||||||
|
|
||||||
if should_generate_html(images, contains_files, _args):
|
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:
|
else:
|
||||||
if os.path.exists(os.path.join(folder, "index.html")):
|
if os.path.exists(os.path.join(folder, "index.html")):
|
||||||
logger.info("removing existing index.html", extra={"folder": folder})
|
logger.info("removing existing index.html", extra={"folder": folder})
|
||||||
@@ -564,16 +564,7 @@ def format_html(html: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def create_html_file(
|
def create_html_file(
|
||||||
folder: str,
|
folder: str, title: str, foldername: str, images: list[ImageMetadata], subfolders: list[SubfolderMetadata], _args: Args, version: str, logo: str, subfoldertags: set[str]
|
||||||
title: str,
|
|
||||||
foldername: str,
|
|
||||||
images: list[ImageMetadata],
|
|
||||||
subfolders: list[SubfolderMetadata],
|
|
||||||
_args: Args,
|
|
||||||
version: str,
|
|
||||||
logo: str,
|
|
||||||
subfoldertags: set[str],
|
|
||||||
darktheme: bool = False,
|
|
||||||
) -> set[str]:
|
) -> set[str]:
|
||||||
"""
|
"""
|
||||||
Creates the HTML file using the template.
|
Creates the HTML file using the template.
|
||||||
@@ -630,7 +621,7 @@ def create_html_file(
|
|||||||
favicon=f"{_args.web_root_url}{FAVICON_PATH}",
|
favicon=f"{_args.web_root_url}{FAVICON_PATH}",
|
||||||
stylesheet=f"{_args.web_root_url}{GLOBAL_CSS_PATH}",
|
stylesheet=f"{_args.web_root_url}{GLOBAL_CSS_PATH}",
|
||||||
theme=f"{_args.web_root_url}.static/theme.css",
|
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,
|
root=_args.web_root_url,
|
||||||
parent=f"{_args.web_root_url}{urllib.parse.quote(foldername)}",
|
parent=f"{_args.web_root_url}{urllib.parse.quote(foldername)}",
|
||||||
header=f"{header} - LICENSE",
|
header=f"{header} - LICENSE",
|
||||||
@@ -648,7 +639,7 @@ def create_html_file(
|
|||||||
favicon=f"{_args.web_root_url}{FAVICON_PATH}",
|
favicon=f"{_args.web_root_url}{FAVICON_PATH}",
|
||||||
stylesheet=f"{_args.web_root_url}{GLOBAL_CSS_PATH}",
|
stylesheet=f"{_args.web_root_url}{GLOBAL_CSS_PATH}",
|
||||||
theme=f"{_args.web_root_url}.static/theme.css",
|
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,
|
root=_args.web_root_url,
|
||||||
parent=parent,
|
parent=parent,
|
||||||
header=header,
|
header=header,
|
||||||
@@ -669,7 +660,7 @@ def create_html_file(
|
|||||||
return set(sorted(alltags))
|
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.
|
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:
|
Returns:
|
||||||
list[tuple[str, str]]: list of thumbnails generated.
|
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
|
return thumbnails
|
||||||
|
|||||||
@@ -100,7 +100,7 @@
|
|||||||
<li class="license"><a href="{{ licensefile }}">License</a></li>
|
<li class="license"><a href="{{ licensefile }}">License</a></li>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if darktheme %}
|
{%- if darktheme %}
|
||||||
<li>
|
<li class="darkmodeswitch">
|
||||||
<a class="button" id="dark-mode-switch">
|
<a class="button" id="dark-mode-switch">
|
||||||
<input type="checkbox" class="checkbox" id="dark-mode-switch-check" />
|
<input type="checkbox" class="checkbox" id="dark-mode-switch-check" />
|
||||||
<div class="knobs">
|
<div class="knobs">
|
||||||
|
|||||||
Reference in New Issue
Block a user