Compare commits
No commits in common. "b434d0837a47ed6af1290ea136e8f24d2f66b953" and "8c2d5df0d2bb7b35e81fe760cda50a68e002f8a3" have entirely different histories.
b434d0837a
...
8c2d5df0d2
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
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,15 +7,13 @@ 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():
|
||||||
parser = argparse.ArgumentParser()
|
if (len(sys.argv) < 2):
|
||||||
parser.add_argument("site_path", help="the folder of your site MUST BE ALWAYS BEFORT PARAMETERS", type=str)
|
print("error: missing argument", file=sys.stderr)
|
||||||
parser.add_argument("-r", '--regen', help="Regenerate (t)thumb (s)small", type=str)
|
exit(1)
|
||||||
args = parser.parse_args()
|
return sys.argv[1]
|
||||||
return args
|
|
||||||
|
|
||||||
def scan_pages(folders: list[Path]) -> list[Page]:
|
def scan_pages(folders: list[Path]) -> list[Page]:
|
||||||
pages: list[Page] = []
|
pages: list[Page] = []
|
||||||
@ -71,36 +69,20 @@ def create_albums(albums: list[Album]) -> None:
|
|||||||
album.create()
|
album.create()
|
||||||
bar.next()
|
bar.next()
|
||||||
|
|
||||||
def gen_bulk(bulk_path: Path):
|
|
||||||
pages: list[Page] = scan_pages(bulk_path.get_dirs())
|
def main():
|
||||||
shutil.copy2("./src/templates/page.css", bulk_path.get_absolute_path())
|
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())
|
||||||
create_pages(pages)
|
create_pages(pages)
|
||||||
album_path: Path = Path(bulk_path, "albums")
|
album_path: Path = Path(site_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(bulk_path.get_absolute_path(), "index.html"))
|
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", bulk_path.get_absolute_path())
|
shutil.copy2("./src/templates/album.css", site_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(config.THUMB_DIMENSION)
|
im.thumbnail((500,500))
|
||||||
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,13 +28,14 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
object-fit: contain
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
justify-content: center;
|
align-items: 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="/bulk/album.css">
|
<link rel="stylesheet" href="/album.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="/bulk/page.css">
|
<link rel="stylesheet" href="/page.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
Loading…
Reference in New Issue
Block a user