From 9297781c79dbfe68a817474d0395001fd9746770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yaroslav=20de=20la=20Pe=C3=B1a=20Smirnov?= Date: Thu, 16 Dec 2021 02:04:43 +0300 Subject: Added basic builtin templates and css --- assets/static/css/gallery.css | 85 +++++++++++++++++++++++++++++++++++++++++++ assets/templates/album.html | 24 ++++++++++++ assets/templates/base.html | 17 +++++++++ assets/templates/image.html | 31 ++++++++++++++++ assets/templates/index.html | 33 +++++++++++++++++ src/render.c | 6 +-- 6 files changed, 191 insertions(+), 5 deletions(-) create mode 100644 assets/static/css/gallery.css create mode 100644 assets/templates/album.html create mode 100644 assets/templates/base.html create mode 100644 assets/templates/image.html create mode 100644 assets/templates/index.html diff --git a/assets/static/css/gallery.css b/assets/static/css/gallery.css new file mode 100644 index 0000000..c72dd80 --- /dev/null +++ b/assets/static/css/gallery.css @@ -0,0 +1,85 @@ +* { + box-sizing: border-box; +} + +html, body { + margin: 0; + padding: 0; + width: 100%; + min-height: 100vh; + background-color: #faf6e5; + font-family: Helvetica, Verdana, sans-serif; +} + +.header-container, +.gallery-container { + width: 90vw; + height: auto; + margin: 0 auto; + padding: 1em; +} + +.album-container { + display: flex; + flex-wrap: wrap; +} + +.album-container a { + text-decoration: none; + flex-grow: 1; + height: 150px; +} + +.album-container img { + max-height: 100%; + min-width: 100%; + object-fit: cover; +} + +.album-container::after { + content: ""; + flex-grow: 10; +} + +.image-container { + text-align: center; + background-color: #000; +} + +.image-container img { + display: inline-block; + max-width: 100vw; + max-height: 85vh; +} + +.control-btn { + display: inline-block; + text-decoration: none; + padding: 0.5em; + color: #fff !important; +} + +.control-btn:hover { + text-decoration: none; + background-color: #333; + color: #fff; +} + +.control-btn.hidden { + visibility: hidden; +} + +@media (prefers-color-scheme: dark) { + html, body { + background-color: #151517; + color: #fcf8e2; + } + + a { + color: #3f6e90; + } + + a:visited { + color: #9c6992; + } +} diff --git a/assets/templates/album.html b/assets/templates/album.html new file mode 100644 index 0000000..95d9935 --- /dev/null +++ b/assets/templates/album.html @@ -0,0 +1,24 @@ +{% extends "base.html" %} +{% block content %} +
+

+ {{ album.year }} + {% if album.title %} + {{ album.title }} + {% else %} + Untitled + {% endif %} +

+

from {{ title }}

+
+ +{% endblock %} diff --git a/assets/templates/base.html b/assets/templates/base.html new file mode 100644 index 0000000..1f2d8dc --- /dev/null +++ b/assets/templates/base.html @@ -0,0 +1,17 @@ + + + + + + + {% block title %} + A photo gallery by Yaroslav de la Peña Smirnov + {% endblock %} + + + + + {% block content %} + {% endblock %} + + diff --git a/assets/templates/image.html b/assets/templates/image.html new file mode 100644 index 0000000..8f7dd11 --- /dev/null +++ b/assets/templates/image.html @@ -0,0 +1,31 @@ +{% extends "base.html" %} +{% block content %} +
+ +
+ {% if image.prev %} + ⮜ Previous + {% else %} + + {% endif %} + {% if image.next %} + Next ⮞ + {% else %} + + {% endif %} +
+
+ +{% endblock %} + diff --git a/assets/templates/index.html b/assets/templates/index.html new file mode 100644 index 0000000..61160a5 --- /dev/null +++ b/assets/templates/index.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} +{% block content %} +
+

{{ title }}

+
+ +{% endblock %} diff --git a/src/render.c b/src/render.c index 7008e50..17436f8 100644 --- a/src/render.c +++ b/src/render.c @@ -227,11 +227,7 @@ render_init(struct render *r, const char *root, struct site_config *conf, r->common_vars = hashmap_new_with_cap(16); hashmap_insert(r->common_vars, "title", conf->title); - if (strlen(conf->base_url) == 0) { - hashmap_insert(r->common_vars, "index", "/"); - } else { - hashmap_insert(r->common_vars, "index", conf->base_url); - } + hashmap_insert(r->common_vars, "index", conf->base_url); //bstree_inorder_walk(albums->root, albums_walk, (void *)r); -- cgit v1.2.3