add: albums link under pictures
This commit is contained in:
parent
b434d0837a
commit
b895e5d85c
@ -15,10 +15,10 @@ album_template = env.get_template('album.jinja')
|
|||||||
class Album():
|
class Album():
|
||||||
|
|
||||||
def __init__(self, name: str, albums_path: Path, pictures: list[Picture] = None, is_repertoried: bool = False):
|
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._pictures: list[Picture] = pictures or []
|
||||||
self._is_repertoried: bool = is_repertoried
|
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:
|
def add_picture(self, picture: Picture) -> None:
|
||||||
self._pictures.append(picture)
|
self._pictures.append(picture)
|
||||||
@ -28,5 +28,5 @@ class Album():
|
|||||||
return html_rendered
|
return html_rendered
|
||||||
|
|
||||||
def create(self) -> Path:
|
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())
|
f.write(self._to_html())
|
26
src/main.py
26
src/main.py
@ -1,5 +1,4 @@
|
|||||||
import sys
|
import sys
|
||||||
import shutil
|
|
||||||
import os
|
import os
|
||||||
from progress.bar import Bar
|
from progress.bar import Bar
|
||||||
|
|
||||||
@ -61,6 +60,7 @@ def scan_albums(pages: list[Page], albums_path: Path) -> list[Album]:
|
|||||||
if (album is None):
|
if (album is None):
|
||||||
album = Album(album_name, albums_path)
|
album = Album(album_name, albums_path)
|
||||||
albums.update({album_name: album})
|
albums.update({album_name: album})
|
||||||
|
picture.albums.append(album)
|
||||||
album.add_picture(picture)
|
album.add_picture(picture)
|
||||||
bar.next()
|
bar.next()
|
||||||
return (albums.values())
|
return (albums.values())
|
||||||
@ -72,17 +72,25 @@ def create_albums(albums: list[Album]) -> None:
|
|||||||
bar.next()
|
bar.next()
|
||||||
|
|
||||||
def gen_bulk(bulk_path: Path):
|
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")
|
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()):
|
if (not album_path.exist()):
|
||||||
album_path.create()
|
album_path.create()
|
||||||
albums: list[Album] = scan_albums(pages, album_path)
|
|
||||||
create_albums(albums)
|
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):
|
def regen(bulk_path: Path, is_thumb: bool, is_small: bool):
|
||||||
for page in scan_pages(bulk_path.get_dirs()):
|
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():
|
def main():
|
||||||
args = argument_parsing()
|
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:
|
if args.regen is not None:
|
||||||
regen(bulk_path, 't' in args.regen, 's' in args.regen)
|
regen(bulk_path, 't' in args.regen, 's' in args.regen)
|
||||||
gen_bulk(bulk_path)
|
gen_bulk(bulk_path)
|
||||||
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import shutil
|
||||||
class Path():
|
class Path():
|
||||||
|
|
||||||
def __init__(self, *paths: str | Path):
|
def __init__(self, *paths: str | Path):
|
||||||
@ -56,6 +56,9 @@ class Path():
|
|||||||
files.append(path)
|
files.append(path)
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
def copy_to(self, destination: Path) -> None:
|
||||||
|
shutil.copy2(self.get_absolute_path(), destination.get_absolute_path())
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self._absolute_path
|
return self._absolute_path
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@ class Picture():
|
|||||||
self._raw: Path|None = raw
|
self._raw: Path|None = raw
|
||||||
self._page: Page = page
|
self._page: Page = page
|
||||||
self._albums_name: list[str] = []
|
self._albums_name: list[str] = []
|
||||||
|
self.albums: list[Album] = []
|
||||||
if self._albums_file.exist():
|
if self._albums_file.exist():
|
||||||
with open(self._albums_file.get_absolute_path(), "r+") as f:
|
with open(self._albums_file.get_absolute_path(), "r+") as f:
|
||||||
albums_name: list[str] = f.read()
|
albums_name: list[str] = f.read()
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>{{ album._name }}</h1>
|
<h1>{{ album.name }}</h1>
|
||||||
<div class="picture-container">
|
<div class="picture-container">
|
||||||
{% for picture in album._pictures %}
|
{% for picture in album._pictures %}
|
||||||
<a href="{{ picture.get_page().html.get_url() }}">
|
<a href="{{ picture.get_page().html.get_url() }}">
|
||||||
|
@ -28,11 +28,15 @@ body {
|
|||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.picture-container-item {
|
.picture {
|
||||||
padding: 5px;
|
padding: 5px;
|
||||||
background-color: var(--content1);
|
background-color: var(--content1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.albums_container {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
@ -29,14 +29,22 @@
|
|||||||
<div class="picture-container">
|
<div class="picture-container">
|
||||||
{% for picture in page._pictures %}
|
{% for picture in page._pictures %}
|
||||||
<div class="picture-container-item">
|
<div class="picture-container-item">
|
||||||
<a href="{{ picture.get_small().get_url() }}">
|
<div class="picture">
|
||||||
<img src='{{ picture.get_small().get_url() }}'>
|
<a href="{{ picture.get_small().get_url() }}">
|
||||||
</a>
|
<img src='{{ picture.get_small().get_url() }}'>
|
||||||
<div class="meta-picture">
|
</a>
|
||||||
<a href="{{ picture.get_large().get_url() }}">Large</a>
|
<div class="meta-picture">
|
||||||
{% if picture._profile_file.exist() %}
|
<a href="{{ picture.get_large().get_url() }}">Large</a>
|
||||||
<a class="profile" href="{{ picture.get_profile_file().get_url() }}">Raw therapee profile</a>
|
{% if picture._profile_file.exist() %}
|
||||||
{% endif %}
|
<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>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
Loading…
Reference in New Issue
Block a user