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():
|
||||
|
||||
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())
|
26
src/main.py
26
src/main.py
@ -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)
|
||||
|
@ -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
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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() }}">
|
||||
|
@ -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;
|
||||
|
@ -29,6 +29,7 @@
|
||||
<div class="picture-container">
|
||||
{% for picture in page._pictures %}
|
||||
<div class="picture-container-item">
|
||||
<div class="picture">
|
||||
<a href="{{ picture.get_small().get_url() }}">
|
||||
<img src='{{ picture.get_small().get_url() }}'>
|
||||
</a>
|
||||
@ -39,6 +40,13 @@
|
||||
{% 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 %}
|
||||
</div>
|
||||
{% if page.get_raw().exist() %}
|
||||
|
Loading…
Reference in New Issue
Block a user