add: albums link under pictures

This commit is contained in:
Starnakin 2025-05-06 20:03:32 +02:00
parent b434d0837a
commit b895e5d85c
7 changed files with 47 additions and 23 deletions

View File

@ -15,10 +15,10 @@ album_template = env.get_template('album.jinja')
class Album():
def __init__(self, name: str, albums_path: Path, pictures: list[Picture] = None, is_repertoried: bool = False):
self._name: str = name
self.name: str = name
self._pictures: list[Picture] = pictures or []
self._is_repertoried: bool = is_repertoried
self._path: Path = Path(albums_path, f"{name}.html")
self.path: Path = Path(albums_path, f"{name}.html")
def add_picture(self, picture: Picture) -> None:
self._pictures.append(picture)
@ -28,5 +28,5 @@ class Album():
return html_rendered
def create(self) -> Path:
with open(self._path.get_absolute_path(), "w") as f:
with open(self.path.get_absolute_path(), "w") as f:
f.write(self._to_html())

View File

@ -1,5 +1,4 @@
import sys
import shutil
import os
from progress.bar import Bar
@ -61,6 +60,7 @@ def scan_albums(pages: list[Page], albums_path: Path) -> list[Album]:
if (album is None):
album = Album(album_name, albums_path)
albums.update({album_name: album})
picture.albums.append(album)
album.add_picture(picture)
bar.next()
return (albums.values())
@ -72,17 +72,25 @@ def create_albums(albums: list[Album]) -> None:
bar.next()
def gen_bulk(bulk_path: Path):
pages: list[Page] = scan_pages(bulk_path.get_dirs())
shutil.copy2("./src/templates/page.css", bulk_path.get_absolute_path())
create_pages(pages)
album_path: Path = Path(bulk_path, "albums")
pages: list[Page] = scan_pages(bulk_path.get_dirs())
albums: list[Album] = scan_albums(pages, album_path)
if config.CREATE_GENERAL_ALBUM:
for album in albums:
if (album.name == "general"):
album.path = Path(bulk_path, "general.html")
Path("./src/templates/page.css").copy_to(Path(bulk_path, "page.css"))
create_pages(pages)
Path("./src/templates/album.css").copy_to(Path(bulk_path, "album.css"))
if (not album_path.exist()):
album_path.create()
albums: list[Album] = scan_albums(pages, album_path)
create_albums(albums)
if config.CREATE_GENERAL_ALBUM:
shutil.move(os.path.join(album_path.get_absolute_path(), "general.html"), os.path.join(bulk_path.get_absolute_path(), "index.html"))
shutil.copy2("./src/templates/album.css", bulk_path.get_absolute_path())
def regen(bulk_path: Path, is_thumb: bool, is_small: bool):
for page in scan_pages(bulk_path.get_dirs()):
@ -96,7 +104,7 @@ def regen(bulk_path: Path, is_thumb: bool, is_small: bool):
def main():
args = argument_parsing()
bulk_path: Path = Path(args.site_path, "bulk")
bulk_path: Path = Path(args.site_path, "bulk/")
if args.regen is not None:
regen(bulk_path, 't' in args.regen, 's' in args.regen)
gen_bulk(bulk_path)

View File

@ -2,7 +2,7 @@ from __future__ import annotations
import os
import sys
import shutil
class Path():
def __init__(self, *paths: str | Path):
@ -56,6 +56,9 @@ class Path():
files.append(path)
return files
def copy_to(self, destination: Path) -> None:
shutil.copy2(self.get_absolute_path(), destination.get_absolute_path())
def __str__(self):
return self._absolute_path

View File

@ -23,6 +23,7 @@ class Picture():
self._raw: Path|None = raw
self._page: Page = page
self._albums_name: list[str] = []
self.albums: list[Album] = []
if self._albums_file.exist():
with open(self._albums_file.get_absolute_path(), "r+") as f:
albums_name: list[str] = f.read()

View File

@ -6,7 +6,7 @@
</head>
<body>
<h1>{{ album._name }}</h1>
<h1>{{ album.name }}</h1>
<div class="picture-container">
{% for picture in album._pictures %}
<a href="{{ picture.get_page().html.get_url() }}">

View File

@ -28,11 +28,15 @@ body {
padding: 10px;
}
.picture-container-item {
.picture {
padding: 5px;
background-color: var(--content1);
}
.albums_container {
margin-right: 0;
}
img {
max-width: 100%;
height: auto;

View File

@ -29,14 +29,22 @@
<div class="picture-container">
{% for picture in page._pictures %}
<div class="picture-container-item">
<a href="{{ picture.get_small().get_url() }}">
<img src='{{ picture.get_small().get_url() }}'>
</a>
<div class="meta-picture">
<a href="{{ picture.get_large().get_url() }}">Large</a>
{% if picture._profile_file.exist() %}
<a class="profile" href="{{ picture.get_profile_file().get_url() }}">Raw therapee profile</a>
{% endif %}
<div class="picture">
<a href="{{ picture.get_small().get_url() }}">
<img src='{{ picture.get_small().get_url() }}'>
</a>
<div class="meta-picture">
<a href="{{ picture.get_large().get_url() }}">Large</a>
{% if picture._profile_file.exist() %}
<a class="profile" href="{{ picture.get_profile_file().get_url() }}">Raw therapee profile</a>
{% endif %}
</div>
</div>
<div class="albums_container">
<h1>Albums:</h1>
{% for album in picture.albums %}
<a href="{{ album.path.get_url() }}" class="album_item">{{ album.name }}</a>
{% endfor %}
</div>
</div>
{% endfor %}