diff options
| -rw-r--r-- | page.c | 64 | ||||
| -rw-r--r-- | style.c | 18 |
2 files changed, 70 insertions, 12 deletions
@@ -32,10 +32,11 @@ PROJECT_TAG "\n" #define STYLE_A "<link href=\"/style.css\" rel=\"stylesheet\">" #define LOGIN_BODY \ - "<header>\n" \ - " <a href=\"" PROJECT_URL "\">" PROJECT_NAME "</a>," \ - " a simple and lightweight cloud\n" \ - "</header>\n" \ + "<div class=\"center\">\n" \ + " <header>\n" \ + " <a href=\"" PROJECT_URL "\">" PROJECT_NAME "</a>," \ + " a simple and lightweight cloud\n" \ + " </header>\n" \ " <form class=\"loginform\" action=\"/login\" method=\"post\">\n" \ " <label for=\"username\">Username:</label>\n" \ " <input type=\"text\" class=\"form-control\"\n" \ @@ -44,7 +45,8 @@ " <input type=\"password\" class=\"form-control\" \n" \ " id=\"password\" name=\"password\"><br>\n" \ " <input type=\"submit\" value=\"Submit\">\n" \ - " </form>\n" + " </form>\n" \ + "</div>" #define MAXSIZEFMT "18446744073709551615.0 XiB" #define RM_FORM_ID "rm" @@ -133,6 +135,11 @@ static int prepare_name(struct html_node *const n, struct stat *const sb, fprintf(stderr, "%s: html_node_add_attr href failed\n", __func__); goto end; } + else if (html_node_add_attr(a, "class", "wrap-anywhere")) + { + fprintf(stderr, "%s: html_node_add_attr class failed\n", __func__); + goto end; + } else if (dynstr_append(&dname, "%s%s", name, sep)) { fprintf(stderr, "%s: dynstr_append [2] failed\n", __func__); @@ -219,6 +226,11 @@ static int prepare_date(struct html_node *const n, const struct stat *const sb) fprintf(stderr, "%s: strftime(3) failed\n", __func__); return -1; } + else if (html_node_add_attr(n, "class", "wrap-anywhere")) + { + fprintf(stderr, "%s: html_node_add_attr class failed\n", __func__); + return -1; + } else if (html_node_set_value(n, date)) { fprintf(stderr, "%s: html_node_set_value failed\n", __func__); @@ -1078,7 +1090,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, *div; + *ret = NULL, *head, *cnt, *div; if (!html) { @@ -1095,6 +1107,16 @@ 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 (!(cnt = html_node_add_child(*body, "div"))) + { + fprintf(stderr, "%s: html_node_add_child cnt failed\n", __func__); + goto end; + } + else if (html_node_add_attr(cnt, "class", "center")) + { + fprintf(stderr, "%s: html_node_add_attr center failed\n", __func__); + goto end; + } else if (!(div = html_node_add_child(*body, "div"))) { fprintf(stderr, "%s: html_node_add_child div failed\n", __func__); @@ -2182,7 +2204,7 @@ int page_rm(struct http_response *r, const struct page_rm *const rm) int ret = -1; struct dynstr out; struct html_node *const html = html_node_alloc("html"), - *p, *p2, *head, *body; + *p, *p2, *head, *body, *div, *div2; static const char question[] = "Are you sure to remove the " "following files and/or directories? Remember that removing a " "directory will remove all of the files and directories inside it.", @@ -2205,12 +2227,32 @@ int page_rm(struct http_response *r, const struct page_rm *const rm) fprintf(stderr, "%s: html_node_add_child body failed\n", __func__); goto end; } - else if (!(p = html_node_add_child(body, "p"))) + else if (!(div = html_node_add_child(body, "div"))) + { + fprintf(stderr, "%s: html_node_add_child div failed\n", __func__); + goto end; + } + else if (html_node_add_attr(div, "class", "center")) + { + fprintf(stderr, "%s: html_node_add_attr center failed\n", __func__); + goto end; + } + else if (!(div2 = html_node_add_child(div, "div"))) + { + fprintf(stderr, "%s: html_node_add_child div2 failed\n", __func__); + goto end; + } + else if (html_node_add_attr(div2, "class", "center mw-75")) + { + fprintf(stderr, "%s: html_node_add_attr center failed\n", __func__); + goto end; + } + else if (!(p = html_node_add_child(div2, "p"))) { fprintf(stderr, "%s: html_node_add_child p failed\n", __func__); goto end; } - else if (!(p2 = html_node_add_child(body, "p"))) + else if (!(p2 = html_node_add_child(div2, "p"))) { fprintf(stderr, "%s: html_node_add_child p2 failed\n", __func__); goto end; @@ -2230,12 +2272,12 @@ int page_rm(struct http_response *r, const struct page_rm *const rm) fprintf(stderr, "%s: html_node_set_value reminder failed\n", __func__); goto end; } - else if (append_rm_items(body, rm)) + else if (append_rm_items(div2, rm)) { fprintf(stderr, "%s: append_rm_items failed\n", __func__); goto end; } - else if (prepare_footer(body)) + else if (prepare_footer(div2)) { fprintf(stderr, "%s: prepare_footer failed\n", __func__); goto end; @@ -22,10 +22,26 @@ const char style_default[] = "{\n" " display: grid;\n" "}\n" + ".center\n" + "{\n" + " justify-content: center;\n" + " justify-items: center;\n" + " min-height: 100vh;\n" + " align-content: center;\n" + " align-items: center;\n" + "}\n" + ".mw-75\n" + "{\n" + " max-width: 75%;\n" + "}\n" "form, label, table\n" "{\n" " margin: auto;\n" "}\n" + ".wrap-anywhere\n" + "{\n" + " overflow-wrap: anywhere;\n" + "}\n" "div\n" "{\n" " align-items: center;\n" @@ -45,7 +61,7 @@ const char style_default[] = "}\n" "table\n" "{\n" - " max-width: 50%;\n" + " max-width: 90vw;\n" "}\n" "tr:nth-child(even)\n" "{\n" |
