From 212bd22001b24023a72342fd17a04a4cc24ae305 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Fri, 22 Dec 2023 11:59:54 -0600 Subject: Hack in form --- src/clog.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'src/clog.c') 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, -- cgit v1.2.3