aboutsummaryrefslogtreecommitdiff
path: root/form_head.c
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-09-22 17:32:44 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2026-02-13 09:57:39 +0100
commit78bf2fe4a5bf37514f6dfd203ef969da0bf40c2e (patch)
tree33f9440b8ee0fa7a3b3ad033616d722d2101bb4d /form_head.c
parent107a2e43d54f9a42fb85b00b83cb0d9abb194680 (diff)
Setup project skeletonHEADmaster
Diffstat (limited to 'form_head.c')
-rw-r--r--form_head.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/form_head.c b/form_head.c
new file mode 100644
index 0000000..64325e9
--- /dev/null
+++ b/form_head.c
@@ -0,0 +1,45 @@
+#define _POSIX_C_SOURCE 200809L
+
+#include "form.h"
+#include "defs.h"
+#include <libweb/html.h>
+#include <stdio.h>
+
+#if 0
+ "<link href=\"/" STYLE_PATH "\" rel=\"stylesheet\">"
+ " <meta charset=\"UTF-8\">\n" \
+ " <meta name=\"viewport\"\n" content=\"width=device-width, initial-scale=1, maximum-scale=1\">" \
+ "<title>" PROJECT_TITLE "</title>"
+#endif
+
+int form_head(struct html_node *const n)
+{
+ struct html_node *head, *link, *charset, *name, *title;
+
+ if (!(head = html_node_add_child(n, "head"))
+ || !(link = html_node_add_child(head, "link"))
+ || !(charset = html_node_add_child(head, "meta"))
+ || !(name = html_node_add_child(head, "meta"))
+ || !(title = html_node_add_child(head, "title")))
+ {
+ fprintf(stderr, "%s: html_node_add_child failed\n", __func__);
+ return -1;
+ }
+ else if (html_node_add_attr(link, "href", "/" STYLE_PATH)
+ || html_node_add_attr(link, "rel", "stylesheet")
+ || html_node_add_attr(charset, "charset", "UTF-8")
+ || html_node_add_attr(name, "name", "viewport")
+ || html_node_add_attr(name, "content",
+ "width=device-width, initial-scale=1, maximum-scale=1"))
+ {
+ fprintf(stderr, "%s: html_node_add_attr failed\n", __func__);
+ return -1;
+ }
+ else if (html_node_set_value(title, PROJECT_TITLE))
+ {
+ fprintf(stderr, "%s: html_node_set_value failed\n", __func__);
+ return -1;
+ }
+
+ return 0;
+}