Compare commits

..

No commits in common. "c68f393703cf05c3d305827ef350b99e0c534b3c" and "a4324c61d0c2fc0e8e076a645e62c872d0d7b82e" have entirely different histories.

2 changed files with 16 additions and 68 deletions

View File

@ -4,10 +4,6 @@ from progress.bar import Bar
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
import subprocess import subprocess
import time import time
import markdown
env = Environment(loader=FileSystemLoader('src/templates'))
page_template = env.get_template('page.jinja')
def argument_parsing(): def argument_parsing():
if (len(sys.argv) < 2): if (len(sys.argv) < 2):
@ -24,16 +20,14 @@ def get_exif(folder: str, raw: str):
os.remove(absolut_path) os.remove(absolut_path)
return None return None
def get_images(folder: str, files: list[str]): def get_images(files):
length: int = len(folder) + 1
images_datas: list[str] = [] images_datas: list[str] = []
images: list[str] = [file for file in files if os.path.isfile(file) and file.endswith(".png")] images: list[str] = [file for file in files if os.path.isfile(file) and file.endswith(".png")]
for image in images: for image in images:
export_data_file: str = image + ".out.pp3" export_data_file: str = image + ".out.pp3"
if (os.path.exists(export_data_file) and os.path.isfile(export_data_file)): if (os.path.exists(export_data_file) and os.path.isfile(export_data_file)):
images_datas.append((image[length:], export_data_file[length:])) images_datas.append((image, export_data_file))
else: images_datas.append((image,))
images_datas.append((image[length:],))
return images_datas return images_datas
def get_updated_folders(path: str): def get_updated_folders(path: str):
@ -56,46 +50,16 @@ def get_updated_folders(path: str):
return updated_folders return updated_folders
def get_readme(folder):
absolut_path: str = os.path.join(folder, "readme.md")
if (os.path.exists(absolut_path)):
return absolut_path
return None
def get_raw(folder, files: list[str]):
raws: list[str] = [file for file in files if file.endswith(".NEF")]
raw: str = raws[0] if len(raws) > 0 else None
return raw[len(folder) + 1:]
def get_html_readme(readme_path: str):
if readme_path is None:
return None
with open(readme_path, 'r') as f:
text = f.read()
html = markdown.markdown(text)
return html
def gen_pages(folders: list[str]): def gen_pages(folders: list[str]):
with Bar("generating...", max=len(folders)) as bar: with Bar("generating...", max=len(folders)) as bar:
for folder in folders: for folder in folders:
files: list[str] = [os.path.join(folder, file) for file in os.listdir(folder)] files: list[str] = [os.path.join(folder, file) for file in os.listdir(folder)]
images: list[str] = get_images(folder, files) images: list[str] = get_images(files)
raw: str = get_raw(folder, files) raws: list[str] = [file for file in files if file.endswith(".NEF")]
raw: str = raws[0] if len(raws) > 0 else None
if len(images) == 0:
bar.next()
continue
exif: str = get_exif(folder, raw) exif: str = get_exif(folder, raw)
readme: str = get_readme(folder) readmes: list[str] = [file for file in files if file == "readme.md"]
readme_html: str = get_html_readme(readme) readme: str = readmes[0] if len(readmes) > 0 else None
html_rendered = page_template.render(exif=exif, raw=raw, images=images, readme=readme_html)
with open(os.path.join(folder, "page.html"), "w") as f:
f.write(html_rendered)
bar.next() bar.next()
def main(): def main():

View File

@ -1,36 +1,20 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<link rel="stylesheet" href="../page.css"> <link rel="stylesheet" href="../general/page.css">
</head> </head>
<body> <body>
{% if readme %} {% if readme %}
<div class="readme"> {{readme}}
<div class="readme-content">
{{readme}}
</div>
</div>
{% endif %} {% endif %}
{% for image in images %} {% for image in images %}
<div class="image-container"> <img src="{{ image }}">
<div class="image-container-element">
<img src='{{ image[0] }}'>
{% if image | length > 1 %}
<a class="export" href="{{ image[1] }}">export file</a>
{% endif %}
</div>
</div>
{% endfor %} {% endfor %}
{% if raw or exif %} {% if exif %}
<div class="download"> <a href="{{ exif }}">Exif</a>
<h1>Download</h1> {% endif %}
{% if raw %} {% if raw %}
<a href="{{ raw }}">RAW</a> <a href="{{ raw }}">RAW</a>
{% endif %}
{% if exif %}
<a href="{{ exif }}">Exif</a>
{% endif %}
</div>
{% endif %} {% endif %}
</body> </body>
</html> </html>