aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-04-17 02:58:38 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-04-17 03:01:19 +0200
commit2e2c9b4c93e7469f290f6c9a2c89ed5e41c2cd54 (patch)
tree51ccc550e7e5a9b4352453a9d7e7d9b7be667965
parentd9923273daffd8f20d1352483fd388d1e5a02130 (diff)
downloadslcl-2e2c9b4c93e7469f290f6c9a2c89ed5e41c2cd54.tar.gz
Improve CSS and apply to list_dir
-rw-r--r--page.c64
1 files changed, 54 insertions, 10 deletions
diff --git a/page.c b/page.c
index 9776349..e731177 100644
--- a/page.c
+++ b/page.c
@@ -681,7 +681,7 @@ end:
static int common_head(struct html_node *const head, const char *const tl)
{
int ret = -1;
- struct html_node *charset, *title, *viewport;
+ struct html_node *charset, *title, *viewport, *link;
struct dynstr t;
dynstr_init(&t);
@@ -696,6 +696,21 @@ static int common_head(struct html_node *const head, const char *const tl)
fprintf(stderr, "%s: html_node_add_child charset failed\n", __func__);
goto end;
}
+ else if (!(link = html_node_add_child(head, "link")))
+ {
+ fprintf(stderr, "%s: html_node_add_child link failed\n", __func__);
+ goto end;
+ }
+ else if (html_node_add_attr(link, "href", "/style.css"))
+ {
+ fprintf(stderr, "%s: html_node_add_attr href failed\n", __func__);
+ goto end;
+ }
+ else if (html_node_add_attr(link, "rel", "stylesheet"))
+ {
+ fprintf(stderr, "%s: html_node_add_attr rel failed\n", __func__);
+ goto end;
+ }
else if (html_node_add_attr(charset, "charset", "UTF-8"))
{
fprintf(stderr, "%s: html_node_add_attr charset failed\n", __func__);
@@ -745,7 +760,7 @@ static struct html_node *resource_layout(const char *const dir,
{
const char *const fdir = dir + strlen("/user");
struct html_node *const html = html_node_alloc("html"),
- *ret = NULL, *head, *body;
+ *ret = NULL, *head, *body, *div;
if (!html)
{
@@ -762,7 +777,12 @@ static struct html_node *resource_layout(const char *const dir,
fprintf(stderr, "%s: html_node_add_child body failed\n", __func__);
goto end;
}
- else if (!(*table = html_node_add_child(body, "table")))
+ else if (!(div = html_node_add_child(body, "div")))
+ {
+ fprintf(stderr, "%s: html_node_add_child div failed\n", __func__);
+ goto end;
+ }
+ else if (!(*table = html_node_add_child(div, "table")))
{
fprintf(stderr, "%s: html_node_add_child table failed\n", __func__);
goto end;
@@ -1209,18 +1229,42 @@ int page_bad_request(struct http_response *const r)
int page_style(struct http_response *const r)
{
static const char body[] =
- "body"
+ "body, input\n"
+ "{\n"
+ " font-family: 'Courier New', Courier, monospace;\n"
+ "}\n"
+ "td\n"
+ "{\n"
+ " font-size: 14px;\n"
+ "}\n"
+ "a\n"
+ "{\n"
+ " text-decoration: none;\n"
+ "}\n"
+ "form\n"
"{\n"
- " display: flex;\n"
- " flex-direction: column;\n"
+ " display: grid;\n"
"}\n"
- ".form-control\n"
+ "form, label, table, input\n"
"{\n"
- " display: block;\n"
+ " margin: auto;\n"
+ "}\n"
+ "div\n"
+ "{\n"
+ " align-items: center;\n"
+ " display: grid;\n"
+ "}\n"
+ "input\n"
+ "{\n"
+ " margin:auto;\n"
" border: 1px solid;\n"
- " width: 60%;\n"
" border-radius: 8px;\n"
- " align-content: center;\n"
+ "}\n"
+ "header, footer\n"
+ "{\n"
+ " display: flex;\n"
+ " justify-content: center;\n"
+ " text-decoration: auto;\n"
"}\n";
*r = (const struct http_response)