- removed foldericon argument
- added css foldericons
- added kjoe theme
- improved monokai-vibrant theme
This commit is contained in:
2024-07-01 13:11:27 +02:00
committed by Flo Greistorfer
parent d6c1ad5176
commit 7a42b41eac
8 changed files with 191 additions and 49 deletions

View File

@@ -46,7 +46,6 @@ The script supports several command-line options to customize its behavior. Belo
- `-p ROOT, --root-directory ROOT`: Specify the root folder where the images are stored. This option is required. - `-p ROOT, --root-directory ROOT`: Specify the root folder where the images are stored. This option is required.
- `-w WEBROOT, --web-root-url WEBROOT`: Specify the web root URL where the images will be accessible. This option is required. - `-w WEBROOT, --web-root-url WEBROOT`: Specify the web root URL where the images will be accessible. This option is required.
- `-t TITLE, --site-title TITLE`: Specify the title for the root directory HTML file. This option is required. - `-t TITLE, --site-title TITLE`: Specify the title for the root directory HTML file. This option is required.
- `-i ICON, --folder-icon-url ICON`: Specify the URL for the folder icon. Default is `https://www.svgrepo.com/show/400249/folder.svg`.
- `-r, --regenerate-thumbnails`: Regenerate thumbnails even if they already exist. - `-r, --regenerate-thumbnails`: Regenerate thumbnails even if they already exist.
- `-n, --non-interactive-mode`: Disable interactive mode, which is useful for automated workflows. - `-n, --non-interactive-mode`: Disable interactive mode, which is useful for automated workflows.
- `--use-fancy-folders`: Use fancy folders instead of the default Apache directory listing. - `--use-fancy-folders`: Use fancy folders instead of the default Apache directory listing.

View File

@@ -13,10 +13,8 @@ body {
.folders { .folders {
text-align: center; text-align: center;
display: -ms-flexbox; display: -ms-flexbox;
/* IE10 */
display: flex; display: flex;
-ms-flex-wrap: wrap; -ms-flex-wrap: wrap;
/* IE10 */
flex-wrap: wrap; flex-wrap: wrap;
justify-content: space-evenly; justify-content: space-evenly;
overflow: hidden; overflow: hidden;
@@ -46,10 +44,8 @@ body {
.row { .row {
display: -ms-flexbox; display: -ms-flexbox;
/* IE10 */
display: flex; display: flex;
-ms-flex-wrap: wrap; -ms-flex-wrap: wrap;
/* IE10 */
flex-wrap: wrap; flex-wrap: wrap;
padding: 0 2px; padding: 0 2px;
} }
@@ -61,7 +57,6 @@ figure {
/* Create four equal columns that sits next to each other */ /* Create four equal columns that sits next to each other */
.column { .column {
-ms-flex: 12.5%; -ms-flex: 12.5%;
/* IE10 */
flex: 12.5%; flex: 12.5%;
max-width: 12.5%; max-width: 12.5%;
padding: 0 4px; padding: 0 4px;

View File

@@ -14,13 +14,12 @@ import cclicense
# fmt: off # fmt: off
# Constants # Constants
DEFAULT_FOLDER_ICON = "https://www.svgrepo.com/show/400249/folder.svg"
STATIC_FILES_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "files") STATIC_FILES_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), "files")
FAVICON_PATH = ".static/favicon.ico" FAVICON_PATH = ".static/favicon.ico"
GLOBAL_CSS_PATH = ".static/global.css" GLOBAL_CSS_PATH = ".static/global.css"
DEFAULT_THEME_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), "themes", "default.css") DEFAULT_THEME_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), "themes", "default.css")
DEFAULT_AUTHOR = "Author" DEFAULT_AUTHOR = "Author"
VERSION = "1.4" VERSION = "1.5"
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", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".tif", ".tiff", ".x3f"] 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", ".mrw", ".nef", ".nrw", ".obm", ".orf", ".pef", ".ptx", ".pxn", ".r3d", ".raf", ".raw", ".rwl", ".rw2", ".rwz", ".sr2", ".srf", ".srw", ".tif", ".tiff", ".x3f"]
IMG_EXTENSIONS = [".jpg", ".jpeg"] IMG_EXTENSIONS = [".jpg", ".jpeg"]
EXCLUDES = [".lock", "index.html", ".thumbnails", ".static"] EXCLUDES = [".lock", "index.html", ".thumbnails", ".static"]
@@ -31,11 +30,11 @@ NOT_LIST = ["Galleries", "Archives"]
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__)), "templates")))
thumbnails: List[Tuple[str, str]] = [] thumbnails: List[Tuple[str, str]] = []
class Args: class Args:
root_directory: str root_directory: str
web_root_url: str web_root_url: str
site_title: str site_title: str
folder_icon_url: str
regenerate_thumbnails: bool regenerate_thumbnails: bool
non_interactive_mode: bool non_interactive_mode: bool
use_fancy_folders: bool use_fancy_folders: bool
@@ -52,7 +51,6 @@ def parse_arguments() -> Args:
parser.add_argument("-p", "--root-directory", help="Root directory containing the images.", required=True, type=str, dest="root_directory") parser.add_argument("-p", "--root-directory", help="Root directory containing the images.", required=True, type=str, dest="root_directory")
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") 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")
parser.add_argument("-t", "--site-title", help="Title of the image hosting site.", required=True, type=str, dest="site_title") parser.add_argument("-t", "--site-title", help="Title of the image hosting site.", required=True, type=str, dest="site_title")
parser.add_argument("-i", "--folder-icon-url", help="URL of the icon used for folders.", default=DEFAULT_FOLDER_ICON, type=str, metavar="ICON", dest="folder_icon_url")
parser.add_argument("-r", "--regenerate-thumbnails", help="Regenerate thumbnails even if they already exist.", action="store_true", default=False, dest="regenerate_thumbnails") parser.add_argument("-r", "--regenerate-thumbnails", help="Regenerate thumbnails even if they already exist.", action="store_true", default=False, dest="regenerate_thumbnails")
parser.add_argument("-n", "--non-interactive-mode", help="Run in non-interactive mode, disabling progress bars.", action="store_true", default=False, dest="non_interactive_mode") parser.add_argument("-n", "--non-interactive-mode", help="Run in non-interactive mode, disabling progress bars.", action="store_true", default=False, dest="non_interactive_mode")
parser.add_argument("-l", "--license-type", help="Specify the license type for the images.", choices=["cc-zero", "cc-by", "cc-by-sa", "cc-by-nd", "cc-by-nc", "cc-by-nc-sa", "cc-by-nc-nd"], default=None, dest="license_type") parser.add_argument("-l", "--license-type", help="Specify the license type for the images.", choices=["cc-zero", "cc-by", "cc-by-sa", "cc-by-nd", "cc-by-nc", "cc-by-nc-sa", "cc-by-nc-nd"], default=None, dest="license_type")
@@ -69,7 +67,6 @@ def parse_arguments() -> Args:
args.root_directory = parsed_args.root_directory args.root_directory = parsed_args.root_directory
args.web_root_url = parsed_args.web_root_url args.web_root_url = parsed_args.web_root_url
args.site_title = parsed_args.site_title args.site_title = parsed_args.site_title
args.folder_icon_url = parsed_args.folder_icon_url
args.regenerate_thumbnails = parsed_args.regenerate_thumbnails args.regenerate_thumbnails = parsed_args.regenerate_thumbnails
args.non_interactive_mode = parsed_args.non_interactive_mode args.non_interactive_mode = parsed_args.non_interactive_mode
args.use_fancy_folders = parsed_args.use_fancy_folders args.use_fancy_folders = parsed_args.use_fancy_folders
@@ -113,12 +110,17 @@ def generate_thumbnail(arguments: Tuple[str, str]) -> None:
def get_total_folders(folder: str) -> None: def get_total_folders(folder: str) -> None:
global total global total
total += 1
pbar.desc = f"Traversing filesystem - {folder}"
pbar.update(1)
items = os.listdir(folder) items = os.listdir(folder)
items.sort() items.sort()
for item in items: for item in items:
if item not in EXCLUDES: if item not in EXCLUDES:
if os.path.isdir(os.path.join(folder, item)): if os.path.isdir(os.path.join(folder, item)):
total += 1
if item not in args.exclude_folders: if item not in args.exclude_folders:
get_total_folders(os.path.join(folder, item)) get_total_folders(os.path.join(folder, item))
@@ -191,7 +193,6 @@ def list_folder(folder: str, title: str) -> None:
root=args.web_root_url, root=args.web_root_url,
parent=parent, parent=parent,
header=header, header=header,
foldericon=args.folder_icon_url,
license=license_info, license=license_info,
subdirectories=subfolders, subdirectories=subfolders,
images=image_chunks, images=image_chunks,
@@ -234,7 +235,7 @@ def main() -> None:
pbar.update(0) pbar.update(0)
pbar.close() pbar.close()
pbar = tqdm(total=total + 1, desc="Generating HTML files", unit="files", ascii=True, dynamic_ncols=True) pbar = tqdm(total=total, desc="Generating HTML files", unit="files", ascii=True, dynamic_ncols=True)
list_folder(args.root_directory, args.site_title) list_folder(args.root_directory, args.site_title)
pbar.desc = "Generating html files" pbar.desc = "Generating html files"
pbar.update(0) pbar.update(0)

View File

@@ -28,7 +28,7 @@
<div class="folders"> <div class="folders">
{%- for subdirectory in subdirectories %} {%- for subdirectory in subdirectories %}
<figure> <figure>
<a href="{{ subdirectory.url }}"><img src="{{ foldericon }}" alt="Folder icon" /></a> <a href="{{ subdirectory.url }}"><img /></a>
<figcaption><a href="{{ subdirectory.url }}">{{ subdirectory.name }}</a></figcaption> <figcaption><a href="{{ subdirectory.url }}">{{ subdirectory.name }}</a></figcaption>
</figure> </figure>
{%- endfor %} {%- endfor %}

View File

@@ -1,3 +1,5 @@
@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");
.navbar { .navbar {
font-weight: bold; font-weight: bold;
color: #e8e6e3; color: #e8e6e3;
@@ -17,13 +19,35 @@
.license { .license {
color: #e8e6e3; color: #e8e6e3;
background-color: #313537; background-color: #313537;
font-weight: 500;
}
.license a {
color: #5483ef;
text-decoration: none;
}
.folders img {
content: url(https://www.svgrepo.com/show/474853/gallery.svg);
}
.folders a {
font-weight: 700;
color: #5483ef;
text-decoration: none;
} }
body { body {
color: #e8e6e3; color: #e8e6e3;
background-color: #181a1b; background-color: #181a1b;
font-family: "Ubuntu", sans-serif;
font-optical-sizing: auto;
font-weight: 400;
font-style: normal;
} }
a { body a {
font-weight: 400;
color: #5483ef; color: #5483ef;
text-decoration: none;
} }

View File

@@ -1,3 +1,5 @@
@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");
.navbar { .navbar {
font-weight: bold; font-weight: bold;
color: #fff; color: #fff;
@@ -5,7 +7,7 @@
} }
.navbar li a { .navbar li a {
font-weight: bold; font-weight: 700;
color: #fff; color: #fff;
} }
@@ -17,8 +19,35 @@
.license { .license {
color: #000; color: #000;
background-color: #ddd; background-color: #ddd;
font-weight: 500;
}
.license a {
color: #0055ff;
text-decoration: none;
}
.folders img {
content: url(https://www.svgrepo.com/show/474852/folder.svg);
}
.folders a {
font-weight: 700;
color: #0055ff;
text-decoration: none;
} }
body { body {
color: #000;
background-color: #fff; background-color: #fff;
font-family: "Ubuntu", sans-serif;
font-optical-sizing: auto;
font-weight: 400;
font-style: normal;
}
body a {
font-weight: 400;
color: #0055ff;
text-decoration: none;
} }

70
themes/kjoe.css Normal file
View File

@@ -0,0 +1,70 @@
@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap");
.navbar {
font-weight: bold;
color: #ebebeb;
background-color: #260000;
font-weight: 900;
}
.navbar li a {
font-weight: 800;
color: #ebebeb;
}
/* Change the link color on hover */
.navbar li a:hover {
font-weight: 900;
text-decoration: none;
}
.license {
color: #ebebeb;
background-color: #191313;
font-weight: 700;
}
.license a {
color: #ff2727;
text-decoration: none;
}
.license a:hover {
font-weight: 800;
text-decoration: none;
}
.folders img {
content: url("data:image/svg+xml,%3Csvg width='800px' height='800px' viewBox='0 0 1024 1024' class='icon' version='1.1' xmlns='http://www.w3.org/2000/svg' fill='%23000000'%3E%3Cg id='SVGRepo_bgCarrier' stroke-width='0' /%3E%3Cg id='SVGRepo_tracerCarrier' stroke-linecap='round' stroke-linejoin='round' /%3E%3Cg id='SVGRepo_iconCarrier'%3E%3Cpath d='M853.333333 256H469.333333l-85.333333-85.333333H170.666667c-46.933333 0-85.333333 38.4-85.333334 85.333333v170.666667h853.333334v-85.333334c0-46.933333-38.4-85.333333-85.333334-85.333333z' fill='%238e0000' /%3E%3Cpath d='M853.333333 256H170.666667c-46.933333 0-85.333333 38.4-85.333334 85.333333v426.666667c0 46.933333 38.4 85.333333 85.333334 85.333333h682.666666c46.933333 0 85.333333-38.4 85.333334-85.333333V341.333333c0-46.933333-38.4-85.333333-85.333334-85.333333z' fill='%23FF2727' /%3E%3C/g%3E%3C/svg%3E");
fill: #f00f0f;
}
.folders a {
font-weight: 800;
color: #ebebeb;
text-decoration: none;
}
.folders a:hover {
font-weight: 900;
text-decoration: none;
}
.row a {
font-weight: 800;
color: #ff2727;
text-decoration: none;
}
.row a:hover {
text-decoration: underline;
}
body {
color: #ebebeb;
background-color: #171717;
font-family: "Montserrat", sans-serif;
font-optical-sizing: auto;
font-weight: 700;
font-style: normal;
}

View File

@@ -1,11 +1,14 @@
@import url("https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap");
.navbar { .navbar {
font-weight: bold; font-weight: bold;
color: #f6f6f6; color: #f6f6f6;
background-color: #191b20; background-color: #191b20;
font-weight: 900;
} }
.navbar li a { .navbar li a {
font-weight: bold; font-weight: 900;
color: #f6f6f6; color: #f6f6f6;
} }
@@ -17,14 +20,35 @@
.license { .license {
color: #f6f6f6; color: #f6f6f6;
background-color: #2c313a; background-color: #2c313a;
font-weight: 700;
}
.license a {
color: #528bff;
text-decoration: none;
}
.folders img {
content: url(https://www.svgrepo.com/show/400249/folder.svg);
}
.folders a {
font-weight: 900;
color: #ffd945;
text-decoration: none;
} }
body { body {
color: #f6f6f6; color: #f6f6f6;
background-color: #16171d background-color: #16171d;
font-family: "Montserrat", sans-serif;
font-optical-sizing: auto;
font-weight: 800;
font-style: normal;
} }
a { body a {
font-weight: bold; font-weight: 900;
color: #ffd945; color: #e542ff;
text-decoration: none;
} }