Compare commits
No commits in common. "b434d0837a47ed6af1290ea136e8f24d2f66b953" and "8c2d5df0d2bb7b35e81fe760cda50a68e002f8a3" have entirely different histories.
b434d0837a
...
8c2d5df0d2
@ -1,4 +1,3 @@
|
||||
|
||||
|
||||
CREATE_GENERAL_ALBUM: bool = True
|
||||
THUMB_DIMENSION: tuple[int, int] = (200, 200)
|
||||
CREATE_GENERAL_ALBUM: bool = True
|
42
src/main.py
42
src/main.py
@ -7,15 +7,13 @@ from path import Path
|
||||
from picture import Picture
|
||||
from page import Page
|
||||
from album import Album
|
||||
import argparse
|
||||
import config
|
||||
|
||||
def argument_parsing():
|
||||
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
|
||||
if (len(sys.argv) < 2):
|
||||
print("error: missing argument", file=sys.stderr)
|
||||
exit(1)
|
||||
return sys.argv[1]
|
||||
|
||||
def scan_pages(folders: list[Path]) -> list[Page]:
|
||||
pages: list[Page] = []
|
||||
@ -71,36 +69,20 @@ def create_albums(albums: list[Album]) -> None:
|
||||
album.create()
|
||||
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())
|
||||
|
||||
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())
|
||||
create_pages(pages)
|
||||
album_path: Path = Path(bulk_path, "albums")
|
||||
album_path: Path = Path(site_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(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)
|
||||
|
||||
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())
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -60,7 +60,7 @@ class Picture():
|
||||
|
||||
def gen_thumb(self):
|
||||
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")
|
||||
|
||||
def gen_small(self):
|
||||
|
@ -28,13 +28,14 @@ body {
|
||||
}
|
||||
|
||||
img {
|
||||
object-fit: contain
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
a {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: var(--content1);
|
||||
padding: 10px;
|
||||
margin: 10px;
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="/bulk/album.css">
|
||||
<link rel="stylesheet" href="/album.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
@ -2,7 +2,7 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<link rel="stylesheet" href="/bulk/page.css">
|
||||
<link rel="stylesheet" href="/page.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
Loading…
Reference in New Issue
Block a user