This commit is contained in:
Starnakin 2024-12-01 14:31:35 +01:00
parent cc64d3012a
commit 3831d57fe6
4 changed files with 99 additions and 5 deletions

View File

@ -15,7 +15,7 @@ with open('config.json', 'r') as file:
# Initialiser l'environnement avec un dossier de templates
env = Environment(loader=FileSystemLoader('src/templates'))
template = env.get_template('index.html')
template = env.get_template('page.html')
def get_files_recursive(directory):
file_paths = []
@ -63,7 +63,10 @@ def get_exif(raws: list[str]):
def generate_page(output_path: str):
for folder in os.listdir(output_path):
folders = os.listdir(output_path)
if "general" in folders:
folders.remove("general")
for folder in folders:
path = os.path.join(output_path, folder)
if (os.path.isdir(path)):
files: list[str] = [os.path.join(path, file) for file in os.listdir(path) if os.path.isfile(os.path.join(path, file))]
@ -72,6 +75,7 @@ def generate_page(output_path: str):
larges = [file for ext in config["file_type_extensions"]["large"] for file in files if file.endswith(ext)]
smalls = [file for ext in config["file_type_extensions"]["small"] for file in files if file.endswith(ext)]
print(folder)
generate_missing_images(raws, larges, smalls)
exif = get_exif(raws)
@ -79,6 +83,7 @@ def generate_page(output_path: str):
large = os.path.basename(larges[0]) if len(larges) > 0 else None
small = os.path.basename(smalls[0]) if len(smalls) > 0 else None
print(f"Generate {folder} html")
html_rendered = template.render(exif=exif, raw=raw, large=large, small=small)
with open(os.path.join(path, f"{folder}.html"), "w") as f:
@ -99,5 +104,10 @@ def main():
generate_page(output_path)
general_path: str = os.path.join(output_path, "general")
if not os.path.exists(general_path):
#os.makedirs(general_path)
shutil.copytree("src/templates/", general_path)
if (__name__ == "__main__"):
main()

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

84
src/templates/page.css Normal file
View File

@ -0,0 +1,84 @@
body {
background-color: #002b36;
display: flex;
justify-content: center; /* Centre l'image */
align-items: center; /* Aligne verticalement */
position: relative;
flex-direction: column;
}
#small {
max-width: 100%;
height: auto;
display: block;
}
#download {
background-color: lightgray;
position: absolute;
margin: 10px;
right: 200px;
top: 200px;
}
#download * {
background-color: aqua;
display: flex;
margin: 10px;
}
#download * p {
align-items: center;
}
a {
text-decoration: none;
}
#download img {
height: 50px;
width: 50px;
}
pre {
background: #f4f4f4;
padding: 10px;
border-radius: 5px;
overflow-x: auto;
}
code {
font-family: "Courier New", monospace;
color: #333;
}
.dropdown-btn {
padding: 10px 20px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
font-size: 16px;
border-radius: 5px;
display: flex;
}
/* Cacher le checkbox (pour qu'il ne soit pas visible) */
.dropdown-checkbox {
display: none;
}
/* Style du texte qui apparaît lorsque la case est cochée */
.dropdown-text {
display: none;
margin-top: 10px;
padding: 10px;
background-color: #f1f1f1;
border: 1px solid #ddd;
border-radius: 5px;
}
/* Quand la case est cochée, afficher le texte */
.dropdown-checkbox:checked + .dropdown-btn + .dropdown-text {
display: flex;
}

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="img1.css">
<link rel="stylesheet" href="../general/page.css">
</head>
<body>
@ -10,13 +10,13 @@
<div id="download">
{% if large %}
<a id="large" href="{{ large }}">
<img src="../icons/file.png">
<img src="../general/icons/file.png">
<p>large</p>
</a>
{% endif %}
{% if raw %}
<a id="raw" href="{{ raw }}">
<img src="../icons/file.png">
<img src="../general/icons/file.png">
<p>raw</p>
</a>
{% endif %}