Compare commits
4 Commits
8c2d5df0d2
...
b434d0837a
Author | SHA1 | Date | |
---|---|---|---|
b434d0837a | |||
b9f7090e96 | |||
fe1f7d1485 | |||
2dd1fcfb0c |
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
|
|
||||||
CREATE_GENERAL_ALBUM: bool = True
|
CREATE_GENERAL_ALBUM: bool = True
|
||||||
|
THUMB_DIMENSION: tuple[int, int] = (200, 200)
|
42
src/main.py
42
src/main.py
@ -7,13 +7,15 @@ from path import Path
|
|||||||
from picture import Picture
|
from picture import Picture
|
||||||
from page import Page
|
from page import Page
|
||||||
from album import Album
|
from album import Album
|
||||||
|
import argparse
|
||||||
import config
|
import config
|
||||||
|
|
||||||
def argument_parsing():
|
def argument_parsing():
|
||||||
if (len(sys.argv) < 2):
|
parser = argparse.ArgumentParser()
|
||||||
print("error: missing argument", file=sys.stderr)
|
parser.add_argument("site_path", help="the folder of your site MUST BE ALWAYS BEFORT PARAMETERS", type=str)
|
||||||
exit(1)
|
parser.add_argument("-r", '--regen', help="Regenerate (t)thumb (s)small", type=str)
|
||||||
return sys.argv[1]
|
args = parser.parse_args()
|
||||||
|
return args
|
||||||
|
|
||||||
def scan_pages(folders: list[Path]) -> list[Page]:
|
def scan_pages(folders: list[Path]) -> list[Page]:
|
||||||
pages: list[Page] = []
|
pages: list[Page] = []
|
||||||
@ -69,20 +71,36 @@ def create_albums(albums: list[Album]) -> None:
|
|||||||
album.create()
|
album.create()
|
||||||
bar.next()
|
bar.next()
|
||||||
|
|
||||||
|
def gen_bulk(bulk_path: Path):
|
||||||
def main():
|
pages: list[Page] = scan_pages(bulk_path.get_dirs())
|
||||||
site_path = Path(argument_parsing())
|
shutil.copy2("./src/templates/page.css", bulk_path.get_absolute_path())
|
||||||
pages: list[Page] = scan_pages(site_path.get_dirs())
|
|
||||||
shutil.copy2("./src/templates/page.css", site_path.get_absolute_path())
|
|
||||||
create_pages(pages)
|
create_pages(pages)
|
||||||
album_path: Path = Path(site_path, "albums")
|
album_path: Path = Path(bulk_path, "albums")
|
||||||
if (not album_path.exist()):
|
if (not album_path.exist()):
|
||||||
album_path.create()
|
album_path.create()
|
||||||
albums: list[Album] = scan_albums(pages, album_path)
|
albums: list[Album] = scan_albums(pages, album_path)
|
||||||
create_albums(albums)
|
create_albums(albums)
|
||||||
if config.CREATE_GENERAL_ALBUM:
|
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.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", site_path.get_absolute_path())
|
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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
@ -60,7 +60,7 @@ class Picture():
|
|||||||
|
|
||||||
def gen_thumb(self):
|
def gen_thumb(self):
|
||||||
im = Image.open(self._large.get_absolute_path())
|
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")
|
im.save(self._thumb.get_absolute_path(), "JPEG")
|
||||||
|
|
||||||
def gen_small(self):
|
def gen_small(self):
|
||||||
|
@ -28,14 +28,13 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
width: 100%;
|
object-fit: contain
|
||||||
height: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-items: center;
|
justify-content: center;
|
||||||
background-color: var(--content1);
|
background-color: var(--content1);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin: 10px;
|
margin: 10px;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="/album.css">
|
<link rel="stylesheet" href="/bulk/album.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="/page.css">
|
<link rel="stylesheet" href="/bulk/page.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
Reference in New Issue
Block a user