Compare commits

...

4 Commits

Author SHA1 Message Date
b434d0837a add: regen parameter 2025-05-06 19:30:42 +02:00
b9f7090e96 add: center img without deform it 2025-05-06 19:24:56 +02:00
fe1f7d1485 add: thumb dimension is a global 2025-05-06 18:59:45 +02:00
2dd1fcfb0c add: bulk 2025-05-06 18:55:14 +02:00
6 changed files with 37 additions and 19 deletions

View File

@ -1,3 +1,4 @@
CREATE_GENERAL_ALBUM: bool = True
CREATE_GENERAL_ALBUM: bool = True
THUMB_DIMENSION: tuple[int, int] = (200, 200)

View File

@ -7,13 +7,15 @@ from path import Path
from picture import Picture
from page import Page
from album import Album
import argparse
import config
def argument_parsing():
if (len(sys.argv) < 2):
print("error: missing argument", file=sys.stderr)
exit(1)
return sys.argv[1]
parser = argparse.ArgumentParser()
parser.add_argument("site_path", help="the folder of your site MUST BE ALWAYS BEFORT PARAMETERS", type=str)
parser.add_argument("-r", '--regen', help="Regenerate (t)thumb (s)small", type=str)
args = parser.parse_args()
return args
def scan_pages(folders: list[Path]) -> list[Page]:
pages: list[Page] = []
@ -69,20 +71,36 @@ def create_albums(albums: list[Album]) -> None:
album.create()
bar.next()
def main():
site_path = Path(argument_parsing())
pages: list[Page] = scan_pages(site_path.get_dirs())
shutil.copy2("./src/templates/page.css", site_path.get_absolute_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(site_path, "albums")
album_path: Path = Path(bulk_path, "albums")
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(site_path.get_absolute_path(), "index.html"))
shutil.copy2("./src/templates/album.css", site_path.get_absolute_path())
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()):
for picture in page.get_pictures():
if is_thumb:
picture.gen_thumb()
if is_small:
picture.gen_small()
def main():
args = argument_parsing()
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)
if __name__ == "__main__":
main()

View File

@ -60,7 +60,7 @@ class Picture():
def gen_thumb(self):
im = Image.open(self._large.get_absolute_path())
im.thumbnail((500,500))
im.thumbnail(config.THUMB_DIMENSION)
im.save(self._thumb.get_absolute_path(), "JPEG")
def gen_small(self):

View File

@ -28,14 +28,13 @@ body {
}
img {
width: 100%;
height: auto;
object-fit: contain
}
a {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
background-color: var(--content1);
padding: 10px;
margin: 10px;

View File

@ -2,7 +2,7 @@
<html>
<head>
<link rel="stylesheet" href="/album.css">
<link rel="stylesheet" href="/bulk/album.css">
</head>
<body>

View File

@ -2,7 +2,7 @@
<html>
<head>
<link rel="stylesheet" href="/page.css">
<link rel="stylesheet" href="/bulk/page.css">
</head>
<body>