aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael McVady <femtonaut@gmail.com>2023-12-22 11:59:54 -0600
committerMichael McVady <femtonaut@gmail.com>2023-12-22 11:59:54 -0600
commit212bd22001b24023a72342fd17a04a4cc24ae305 (patch)
tree50c0ed18352a7c4d5a9bf5cb9e5179e884bd912a
parent2e3ceb247fa63db0bbf9ba71f06be50eeda74445 (diff)
Hack in form
-rw-r--r--assets/error.json1
-rw-r--r--assets/form.html20
-rw-r--r--assets/form_begin.html11
-rw-r--r--assets/form_end.html9
-rw-r--r--assets/static/css/retro.css200
-rw-r--r--conf/clog.conf4
-rw-r--r--src/clog.c31
7 files changed, 265 insertions, 11 deletions
diff --git a/assets/error.json b/assets/error.json
deleted file mode 100644
index 94d600d..0000000
--- a/assets/error.json
+++ /dev/null
@@ -1 +0,0 @@
-"%s"
diff --git a/assets/form.html b/assets/form.html
new file mode 100644
index 0000000..8bc0f17
--- /dev/null
+++ b/assets/form.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+<!--meta name="theme-color" content="#E6E6FF"-->
+<title>bunkergate.org</title>
+<link rel="icon" type="image/vnd.microsoft.icon" href="/static/favicon.ico">
+<link rel="stylesheet" type="text/css" href="/static/css/retro.css">
+</head>
+<body>
+%s
+<script src="https://cdn.jsdelivr.net/npm/mermaid@9.4.3/dist/mermaid.min.js"></script>
+<script>
+mermaid.initialize({theme: "dark"});
+mermaid.init(undefined, ".language-mermaid");
+</script>
+
+</body>
+</html> \ No newline at end of file
diff --git a/assets/form_begin.html b/assets/form_begin.html
new file mode 100644
index 0000000..4da1ce9
--- /dev/null
+++ b/assets/form_begin.html
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+<!--meta name="theme-color" content="#E6E6FF"-->
+<title>bunkergate.org</title>
+<link rel="icon" type="image/vnd.microsoft.icon" href="/static/favicon.ico">
+<link rel="stylesheet" type="text/css" href="/static/css/retro.css">
+</head>
+<body>
diff --git a/assets/form_end.html b/assets/form_end.html
new file mode 100644
index 0000000..6131a40
--- /dev/null
+++ b/assets/form_end.html
@@ -0,0 +1,9 @@
+
+<script src="https://cdn.jsdelivr.net/npm/mermaid@9.4.3/dist/mermaid.min.js"></script>
+<script>
+mermaid.initialize({theme: "dark"});
+mermaid.init(undefined, ".language-mermaid");
+</script>
+
+</body>
+</html> \ No newline at end of file
diff --git a/assets/static/css/retro.css b/assets/static/css/retro.css
new file mode 100644
index 0000000..7467a37
--- /dev/null
+++ b/assets/static/css/retro.css
@@ -0,0 +1,200 @@
+pre,
+code {
+ font-family: Menlo, Monaco, "Courier New", monospace;
+}
+
+pre {
+ padding: .5rem;
+ line-height: 1.25;
+ overflow-x: scroll;
+}
+
+@media print {
+ *,
+ *:before,
+ *:after {
+ background: transparent !important;
+ color: #000 !important;
+ box-shadow: none !important;
+ text-shadow: none !important;
+ }
+
+ a,
+ a:visited {
+ text-decoration: underline;
+ }
+
+ a[href]:after {
+ content: " (" attr(href) ")";
+ }
+
+ abbr[title]:after {
+ content: " (" attr(title) ")";
+ }
+
+ a[href^="#"]:after,
+ a[href^="javascript:"]:after {
+ content: "";
+ }
+
+ pre,
+ blockquote {
+ border: 1px solid #999;
+ page-break-inside: avoid;
+ }
+
+ thead {
+ display: table-header-group;
+ }
+
+ tr,
+ img {
+ page-break-inside: avoid;
+ }
+
+ img {
+ max-width: 100% !important;
+ }
+
+ p,
+ h2,
+ h3 {
+ orphans: 3;
+ widows: 3;
+ }
+
+ h2,
+ h3 {
+ page-break-after: avoid;
+ }
+}
+
+a,
+a:visited {
+ color: #01ff70;
+}
+
+a:hover,
+a:focus,
+a:active {
+ color: #2ecc40;
+}
+
+.retro-no-decoration {
+ text-decoration: none;
+}
+
+html {
+ font-size: 12px;
+}
+
+@media screen and (min-width: 32rem) and (max-width: 48rem) {
+ html {
+ font-size: 15px;
+ }
+}
+
+@media screen and (min-width: 48rem) {
+ html {
+ font-size: 16px;
+ }
+}
+
+body {
+ line-height: 1.85;
+}
+
+p,
+.retro-p {
+ font-size: 1rem;
+ margin-bottom: 1.3rem;
+}
+
+h1,
+.retro-h1,
+h2,
+.retro-h2,
+h3,
+.retro-h3,
+h4,
+.retro-h4 {
+ margin: 1.414rem 0 .5rem;
+ font-weight: inherit;
+ line-height: 1.42;
+}
+
+h1,
+.retro-h1 {
+ margin-top: 0;
+ font-size: 3.998rem;
+}
+
+h2,
+.retro-h2 {
+ font-size: 2.827rem;
+}
+
+h3,
+.retro-h3 {
+ font-size: 1.999rem;
+}
+
+h4,
+.retro-h4 {
+ font-size: 1.414rem;
+}
+
+h5,
+.retro-h5 {
+ font-size: 1.121rem;
+}
+
+h6,
+.retro-h6 {
+ font-size: .88rem;
+}
+
+small,
+.retro-small {
+ font-size: .707em;
+}
+
+/* https://github.com/mrmrs/fluidity */
+
+img,
+canvas,
+iframe,
+video,
+svg,
+select,
+textarea {
+ max-width: 100%;
+}
+
+html,
+body {
+ background-color: #222;
+ min-height: 100%;
+}
+
+html {
+ font-size: 18px;
+}
+
+body {
+ color: #fafafa;
+ font-family: "Courier New";
+ line-height: 1.45;
+ margin: 6rem auto 1rem;
+ max-width: 48rem;
+ padding: .25rem;
+}
+
+pre {
+ background-color: #333;
+}
+
+blockquote {
+ border-left: 3px solid #01ff70;
+ padding-left: 1rem;
+} \ No newline at end of file
diff --git a/conf/clog.conf b/conf/clog.conf
index 3476b52..c45e48d 100644
--- a/conf/clog.conf
+++ b/conf/clog.conf
@@ -57,12 +57,12 @@ domain * {
}
# toy endpoint
- route ^/form {
+ route /form {
handler get_entry_form
methods get
}
- route ^/form {
+ route /form {
handler post_entry_form
methods post
diff --git a/src/clog.c b/src/clog.c
index 87129e5..80906d3 100644
--- a/src/clog.c
+++ b/src/clog.c
@@ -240,17 +240,29 @@ int post_entry_form(struct http_request *req) {
// continue;
// }
+ http_response_header(req, "content-type", "text/html; charset=utf-8");
+
+ kore_buf_append(resp_buf, asset_form_begin_html, asset_len_form_begin_html);
+
// Append rendered MD entry.
- kore_buf_appendf(
+ size_t len = 0;
+ char *str = NULL;
+ str = kore_buf_stringify(html_buf, &len);
+ kore_buf_append(
resp_buf,
- (const char *) asset_entry_html,
- id,
- title,
- "1981-12-23 06:02:00",
- kore_buf_stringify(html_buf, NULL)
+ str,
+ len
+ );
+
+ kore_buf_append(resp_buf, asset_form_end_html, asset_len_form_end_html);
+
+ http_response(
+ req,
+ HTTP_STATUS_OK,
+ resp_buf->data,
+ resp_buf->offset
);
- http_ok_resp(req, HTTP_STATUS_OK, resp_buf);
kore_buf_free(html_buf);
kore_buf_free(resp_buf);
@@ -692,7 +704,10 @@ static int render_md(const char *in, struct kore_buf *out) {
int err = 0;
static unsigned parser_flags = 0;
- static unsigned renderer_flags = MD_HTML_FLAG_DEBUG;
+ static unsigned renderer_flags = 0;
+
+ parser_flags |= MD_FLAG_TABLES;
+ // render_flags |= MD_HTML_FLAG_DEBUG;
err = md_html(
in,