commit 298a5211d5da0069c256e1025da13b73c16b45ee
parent 73062e3966f44909de2c9c6113a81a6b8dae68d6
Author: Jacob R. Edwards <jacob@jacobedwards.org>
Date: Sat, 23 Mar 2024 20:42:24 -0700
Add fragpage function
This function generates a page using the given fragment. It uses
the tk_startpage function so the common elements of the timekeeper
pages are inserted.
Diffstat:
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/pages/util.c b/pages/util.c
@@ -1,6 +1,7 @@
#define const
#include "common.h"
+#include "../frag.h"
enum kcgi_err
redirect(struct pagedata *pd, char *to, char *msg)
@@ -31,3 +32,23 @@ redirect(struct pagedata *pd, char *to, char *msg)
return status;
return khtml_close(&pd->html);
}
+
+enum kcgi_err
+fragpage(struct pagedata *pd, char *name, char *fragname)
+{
+ static char *css[] = { "css/main.css", NULL };
+
+ enum kcgi_err status;
+ struct pagetemplate template = {
+ name,
+ .css = css
+ };
+
+ if ((status = tk_startpage(pd, &template, KHTTP_200)) != KCGI_OK)
+ return status;
+
+ if (frag(pd, fragname))
+ return KCGI_SYSTEM;
+
+ return endpage(pd, &template);
+}
diff --git a/pages/util.h b/pages/util.h
@@ -1 +1,2 @@
enum kcgi_err redirect(struct pagedata *pd, char *to, char *msg);
+enum kcgi_err fragpage(struct pagedata *pd, char *name, char *fragname);