commit b91b6f9ef609efc87cdf743497afc8638ceaebc1
parent 1515c0248a00fe78171026f52583dfabc1c6b9a8
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Mon, 11 Mar 2024 01:35:58 -0700
Set title and doctype in starthtmldoc()
Diffstat:
6 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/pages/account.c b/pages/account.c
@@ -18,7 +18,7 @@ pageaccount(struct pagedata *pd)
return errorpage(pd, KHTTP_500);
}
- if ((status = starthtmldoc(pd, KHTTP_200)) != KCGI_OK ||
+ if ((status = starthtmldoc(pd, KHTTP_200, "Account")) != KCGI_OK ||
(status = htmlwithin(pd, KELEM_H1, "Account")) != KCGI_OK ||
(status = htmlwithin(pd, KELEM_H2, "Delete account")) != KCGI_OK ||
(status = htmlwithin(pd, KELEM_P, "Deleting an account is irreversible:"
diff --git a/pages/index.c b/pages/index.c
@@ -7,7 +7,7 @@ pageindex(struct pagedata *pd)
{
enum kcgi_err status;
- if ((status = starthtmldoc(pd, KHTTP_200)) != KCGI_OK)
+ if ((status = starthtmldoc(pd, KHTTP_200, "Timekeeper")) != KCGI_OK)
return status;
khtml_elem(&pd->html, KELEM_H1);
diff --git a/pages/login.c b/pages/login.c
@@ -62,7 +62,7 @@ pagelogin(struct pagedata *pd)
}
}
- if ((status = starthtmldoc(pd, KHTTP_200)) != KCGI_OK)
+ if ((status = starthtmldoc(pd, KHTTP_200, "Login")) != KCGI_OK)
return status;
if ((status = htmlwithin(pd, KELEM_H1, "Login")) != KCGI_OK)
diff --git a/pages/main.c b/pages/main.c
@@ -274,7 +274,7 @@ pagemain(struct pagedata *pd)
return KCGI_SYSTEM;
}
- status = starthtmldoc(pd, KHTTP_200);
+ status = starthtmldoc(pd, KHTTP_200, "Timesheets");
if (status != KCGI_OK)
return status;
diff --git a/pages/util.c b/pages/util.c
@@ -25,7 +25,7 @@ errorpage(struct pagedata *pd, enum khttp code)
}
enum kcgi_err
-starthtmldoc(struct pagedata *pd, enum khttp code)
+starthtmldoc(struct pagedata *pd, enum khttp code, char *title)
{
enum kcgi_err status;
@@ -33,8 +33,12 @@ starthtmldoc(struct pagedata *pd, enum khttp code)
(status = khttp_head(&pd->req, kresps[KRESP_CONTENT_TYPE], "%s", kmimetypes[KMIME_TEXT_HTML])) != KCGI_OK ||
(status = khttp_body(&pd->req)) != KCGI_OK ||
(status = khtml_open(&pd->html, &pd->req, KHTML_PRETTY)) != KCGI_OK ||
+ (status = khtml_elem(&pd->html, KELEM_DOCTYPE)) != KCGI_OK ||
(status = khtml_elem(&pd->html, KELEM_HTML)) != KCGI_OK ||
(status = khtml_elem(&pd->html, KELEM_HEAD)) != KCGI_OK ||
+ (status = khtml_elem(&pd->html, KELEM_TITLE)) != KCGI_OK ||
+ (status = khtml_puts(&pd->html, title)) != KCGI_OK ||
+ (status = khtml_closeelem(&pd->html, 1)) != KCGI_OK ||
(status = khtml_attr(&pd->html, KELEM_LINK,
KATTR_HREF, "css/main.css", KATTR_REL, "stylesheet", KATTR__MAX)) != KCGI_OK ||
(status = khtml_closeelem(&pd->html, 1)) != KCGI_OK ||
@@ -52,7 +56,7 @@ redirect(struct pagedata *pd, char *to, char *msg)
if ((status = khttp_head(&pd->req, kresps[KRESP_LOCATION], "%s", to)) != KCGI_OK)
return status;
- if ((status = starthtmldoc(pd, KHTTP_303)) != KCGI_OK)
+ if ((status = starthtmldoc(pd, KHTTP_303, "Redirect")) != KCGI_OK)
return status;
if ((status = khtml_elem(&pd->html, KELEM_H1)) != KCGI_OK ||
(status = khtml_puts(&pd->html, msg)) != KCGI_OK ||
diff --git a/pages/util.h b/pages/util.h
@@ -1,3 +1,3 @@
enum kcgi_err errorpage(struct pagedata *pd, enum khttp code);
-enum kcgi_err starthtmldoc(struct pagedata *pd, enum khttp code);
+enum kcgi_err starthtmldoc(struct pagedata *pd, enum khttp code, char *title);
enum kcgi_err redirect(struct pagedata *pd, char *to, char *msg);