mirror of
https://github.com/greflm13/StaticGalleryBuilder.git
synced 2026-02-05 02:59:27 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 895ac03590 | |||
| cad6d88b22 | |||
| e06df9444d | |||
| 9d5ce13e14 |
@@ -12,7 +12,7 @@ except ModuleNotFoundError:
|
|||||||
RICH = False
|
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_THEME_PATH = os.path.join(SCRIPTDIR, "templates", "default.css")
|
||||||
DEFAULT_AUTHOR = "Author"
|
DEFAULT_AUTHOR = "Author"
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ from modules.argumentparser import Args
|
|||||||
from modules.datatypes.metadata import Metadata, ImageMetadata, SubfolderMetadata
|
from modules.datatypes.metadata import Metadata, ImageMetadata, SubfolderMetadata
|
||||||
|
|
||||||
# Constants for file paths and exclusions
|
# 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"
|
FAVICON_PATH = ".static/favicon.ico"
|
||||||
GLOBAL_CSS_PATH = ".static/global.css"
|
GLOBAL_CSS_PATH = ".static/global.css"
|
||||||
EXCLUDES = ["index.html", "manifest.json", "robots.txt"]
|
EXCLUDES = ["index.html", "manifest.json", "robots.txt"]
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ import gzip
|
|||||||
import shutil
|
import shutil
|
||||||
import logging
|
import logging
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pythonjsonlogger import jsonlogger
|
from pythonjsonlogger import json as jsonlogger
|
||||||
|
|
||||||
# Constants for file paths and exclusions
|
# 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")
|
LOG_DIR = os.path.join(SCRIPTDIR, "logs")
|
||||||
LATEST_LOG_FILE = os.path.join(LOG_DIR, "latest.jsonl")
|
LATEST_LOG_FILE = os.path.join(LOG_DIR, "latest.jsonl")
|
||||||
|
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ except ImportError:
|
|||||||
|
|
||||||
from modules.logger import logger
|
from modules.logger import logger
|
||||||
from modules.argumentparser import Args
|
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
|
# 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")
|
STATIC_FILES_DIR = os.path.join(SCRIPTDIR, "files")
|
||||||
ICON_SIZES = ["36x36", "48x48", "72x72", "96x96", "144x144", "192x192", "512x512"]
|
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,
|
short_name=_args.site_title,
|
||||||
icons=icon_list,
|
icons=icon_list,
|
||||||
background_color=colors["bcolor1"],
|
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:
|
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")})
|
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
|
return
|
||||||
|
|
||||||
colorscheme = extract_colorscheme(os.path.join(_args.root_directory, ".static", "theme.css"))
|
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)
|
render_manifest_json(_args, icon_list, colorscheme)
|
||||||
|
|||||||
Reference in New Issue
Block a user