simple-s3-gallery/test.py

107 lines
3.2 KiB
Python
Raw Normal View History

2023-12-29 04:09:37 +00:00
#!/usr/bin/python3
"""
test template rendering
python3 test.py | tee test.html
python3 -m http.server
"""
from jinja2 import Environment, FileSystemLoader, select_autoescape
template_vars = {
"charset": "utf-8",
"language": "en",
"css_theme_name": "auto",
"canonical_url": "http://example.com",
"page_title": "This is a title",
"theme": "dark",
"text_theme": "white",
"static": {
"scripts": {
"bootstrap": {
"src": "./templates/example/bootstrap.bundle.min.js",
},
2023-12-29 05:36:56 +00:00
"theme": {"src": "./templates/example/color-modes.js"},
2023-12-29 04:09:37 +00:00
},
"css": {
"bootstrap": {"src": "./templates/example/bootstrap.min.css"},
"theme": {"src": "./templates/example/gallery.css"},
2023-12-29 04:09:37 +00:00
"icons": {
"src": "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.2/font/bootstrap-icons.min.css"
},
},
2023-12-29 04:09:37 +00:00
},
"meta_list": [
{"name": "description", "content": "This is a description"},
{"name": "generator", "content": "simple-s3-gallery v.2023.12"},
{"name": "author", "content": "Code Fox"},
{"name": "theme-color", "content": "#712cf9"},
2023-12-29 04:09:37 +00:00
],
"left_header": "About the gallery",
"left_text": "This is an example gallery that is generated via a template",
"right_header": "Contact",
"link_list": [
{"href": "https://c0defox.es", "text": "Fox :3"},
{"href": "https://furry.engineer/c0de", "text": "Mastodon", "icon": "mastodon"},
2023-12-29 04:09:37 +00:00
],
"footer": {
"main_line": "Copyright 2024 Code Fox",
"extra_lines": ["This is another line", "This is yet another line"],
2023-12-29 04:09:37 +00:00
},
2023-12-29 16:18:03 +00:00
"call_to_action": {
"active": True,
"header": "This is a call to action",
"lead_text": "Some interesting text for the user",
"buttons": [
{"href": "1"},
{"href": "2", "theme": "danger"},
{"href": "3", "theme": "warning", "icon": "exclamation-diamond-fill"},
{
"href": "3",
"theme": "warning",
"icon": "exclamation-diamond-fill",
"text": "some text",
},
],
},
2023-12-29 17:24:16 +00:00
"gallery": {
"max_reactions_per_card": 10,
},
2023-12-29 04:40:44 +00:00
"gallery_items": [
{
"src": "https://files.c0defox.es/Pictures/arctic-fox.jpg",
"description": "An arctic fox :3",
"title": "fox",
2023-12-29 17:24:16 +00:00
"reactions": {"heart-fill":4, "backpack4":1, "balloon-fill":45, "bag-x-fill":0},
2023-12-29 04:40:44 +00:00
},
{
"src": "https://files.c0defox.es/Pictures/arctic-fox.jpg",
"description": "An arctic fox :3",
"title": "fox",
2023-12-29 17:24:16 +00:00
"reactions": {"heart-fill":1024, "bag-x-fill":50},
},
{
"src": "https://files.c0defox.es/Pictures/arctic-fox.jpg",
"description": "An arctic fox :3",
"title": "fox",
},
],
2023-12-29 04:09:37 +00:00
}
2023-12-29 04:09:37 +00:00
def main():
"""main method"""
env = Environment(
loader=FileSystemLoader("templates"),
autoescape=select_autoescape(),
trim_blocks=True,
lstrip_blocks=True,
)
2023-12-29 04:09:37 +00:00
template = env.get_template("base.html")
print(template.render(**template_vars))
2023-12-29 04:09:37 +00:00
if __name__ == "__main__":
main()