packaging now working

This commit is contained in:
2024-07-17 15:31:46 +02:00
committed by Flo Greistorfer
parent 1aa729ef84
commit ad909282e6
8 changed files with 116 additions and 13 deletions

View File

@@ -12,9 +12,11 @@ jobs:
- name: Install Dependencies - name: Install Dependencies
run: pip install -r requirements.txt run: pip install -r requirements.txt
- name: Build Package - name: Build Package
run: pyinstaller builder.py modules/*.py -n StaticGalleryBuilder -F run: pyinstaller builder.py modules/*.py -n StaticGalleryBuilder -F --add-data files:files --add-data templates:templates --add-data .version:.
- name: Release - name: Release
uses: softprops/action-gh-release@v2 uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with: with:
files: dist/StaticGalleryBuilder make_latest: true
generate_release_notes: true
files: |
dist/StaticGalleryBuilder

1
.version Normal file
View File

@@ -0,0 +1 @@
2.2.5

View File

@@ -17,9 +17,11 @@ from modules.generate_html import list_folder, EXCLUDES
# fmt: off # fmt: off
# Constants # Constants
STATIC_FILES_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "files") if __package__ == None:
SCRIPT_DIR = os.path.abspath(os.path.dirname(__file__)) __package__ = ""
VERSION = "2.2.5" 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()
RAW_EXTENSIONS = [ RAW_EXTENSIONS = [
".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr", ".3fr", ".ari", ".arw", ".bay", ".braw", ".crw", ".cr2", ".cr3", ".cap", ".data", ".dcs", ".dcr",
".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos", ".dng", ".drf", ".eip", ".erf", ".fff", ".gpr", ".iiq", ".k25", ".kdc", ".mdc", ".mef", ".mos",
@@ -158,9 +160,7 @@ def get_total_folders(folder: str, _args: Args, _total: int = 0) -> int:
items = sorted(os.listdir(folder)) items = sorted(os.listdir(folder))
for item in items: 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)):
if item not in _args.exclude_folders and not any( if item not in _args.exclude_folders and not any(fnmatch.fnmatchcase(os.path.join(folder, item), exclude) for exclude in _args.exclude_folders):
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) _total = get_total_folders(os.path.join(folder, item), _args, _total)
return _total return _total

View File

@@ -4,7 +4,9 @@ import argparse
from rich_argparse import RichHelpFormatter, HelpPreviewAction from rich_argparse import RichHelpFormatter, HelpPreviewAction
DEFAULT_THEME_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "themes", "default.css") if __package__ == None:
__package__ = ""
DEFAULT_THEME_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__).removesuffix(__package__)), "templates", "default.css")
DEFAULT_AUTHOR = "Author" DEFAULT_AUTHOR = "Author"
@@ -41,6 +43,7 @@ class Args:
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.
""" """
author_name: str author_name: str
exclude_folders: List[str] exclude_folders: List[str]
file_extensions: List[str] file_extensions: List[str]

View File

@@ -13,6 +13,8 @@ import modules.cclicense as cclicense
from modules.argumentparser import Args from modules.argumentparser import Args
# Constants for file paths and exclusions # Constants for file paths and exclusions
if __package__ == None:
__package__ = ""
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"]
@@ -21,7 +23,7 @@ EXCLUDES = ["index.html", "manifest.json", "robots.txt"]
Image.MAX_IMAGE_PIXELS = 933120000 Image.MAX_IMAGE_PIXELS = 933120000
# Initialize Jinja2 environment for template rendering # Initialize Jinja2 environment for template rendering
env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", "templates"))) env = Environment(loader=FileSystemLoader(os.path.join(os.path.abspath(os.path.dirname(__file__).removesuffix(__package__)), "templates")))
thumbnails: List[Tuple[str, str]] = [] thumbnails: List[Tuple[str, str]] = []
info: Dict[str, str] = {} info: Dict[str, str] = {}
pbardict: Dict[str, tqdm] = {} pbardict: Dict[str, tqdm] = {}

View File

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

82
templates/default.css Normal file
View File

@@ -0,0 +1,82 @@
@import url("https://fonts.googleapis.com/css2?family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap");
* {
--color1: #333333;
--color2: #888888;
--color3: #dddddd;
--color4: #111111;
--color5: #0055ff;
--bcolor1: #ffffff;
--bcolor2: #000000;
}
.navbar {
font-weight: bold;
color: var(--bcolor1);
background-color: var(--color1);
}
.navbar li a {
font-weight: 700;
color: var(--bcolor1);
}
/* Change the link color on hover */
.navbar li a:hover {
background-color: var(--color4);
}
.footer {
color: var(--bcolor2);
background-color: var(--color3);
font-weight: 500;
}
.footer a {
color: var(--color5);
text-decoration: none;
}
.foldericon {
content: "templates/folder-2.svg.j2";
}
.folders a {
font-weight: 700;
color: var(--color5);
text-decoration: none;
}
.tooltiptext {
font-weight: 400;
background-color: var(--color2);
}
.column img {
background-color: var(--color2);
}
#totop:hover {
background-color: var(--color2);
}
#totop {
background-color: var(--color1);
color: var(--bcolor1);
font-weight: 800;
}
body {
color: var(--bcolor2);
background-color: var(--bcolor1);
font-family: "Ubuntu", sans-serif;
font-optical-sizing: auto;
font-weight: 400;
font-style: normal;
}
body a {
font-weight: 400;
color: var(--color5);
text-decoration: none;
}

11
templates/folder-2.svg.j2 Normal file
View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<svg width="800px" height="800px" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img"
preserveAspectRatio="xMidYMid meet">
<path fill="{{ color2 }}"
d="M491 326V92.143C491 79.021 480.259 68 467.137 68H341.13c-9.287 0-17.723 5.603-21.596 14.044l-12.709 27.903C302.952 118.388 294.516 124 285.229 124H67.538C54.416 124 44 134.426 44 147.549v216.363C44 377.034 54.416 388 67.538 388h399.599c.628 0 1.248-.36 1.863-.408V433h.342c0 6 4.877 10.636 10.829 10.636c5.952 0 10.829-4.967 10.829-10.919V326z">
</path>
<path fill="{{ color1 }}"
d="M480.171 443.636c-5.952 0-10.829-4.636-10.829-10.636H469V210.181C469 197.058 458.661 186 445.539 186H45.94C32.818 186 22 197.058 22 210.181V449.37C22 462.492 32.818 473 45.94 473h399.599c1.385 0 2.741-.06 4.061-.288c1.639.227 3.31.385 5.012.385c20.04 0 36.136-16.229 36.136-36.269c0-.534-.036-1.058-.058-1.586c-1.147 4.766-5.435 8.394-10.519 8.394z">
</path>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB