diff options
author | Michael McVady <femtonaut@gmail.com> | 2022-03-10 21:07:10 -0500 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2022-03-10 21:07:10 -0500 |
commit | 91723dca0ee9bf68b0147dcf233274cd93f911c8 (patch) | |
tree | 9821689c75986b52d56ef59cfab719d2c787fa28 | |
parent | bbf79174149cf9dde3e08c42d01ba752c6589afe (diff) |
Render something on errors
-rw-r--r-- | assets/error.html | 5 | ||||
-rw-r--r-- | assets/post.html | 8 | ||||
-rw-r--r-- | assets/static/css/default.css | 2 | ||||
-rw-r--r-- | conf/clog.conf | 3 | ||||
-rw-r--r-- | src/clog.c | 24 |
5 files changed, 30 insertions, 12 deletions
diff --git a/assets/error.html b/assets/error.html new file mode 100644 index 0000000..789988a --- /dev/null +++ b/assets/error.html @@ -0,0 +1,5 @@ + +<div class="head"> +<h1>%s</h1> +</div> + diff --git a/assets/post.html b/assets/post.html index 8b105aa..a199fd6 100644 --- a/assets/post.html +++ b/assets/post.html @@ -1,13 +1,13 @@ -<!-- begin post: {{ post.id }} --> + <div class="post"> <hr class="hdiv"/> <div class="head"> <h2><span class="title">%s</span></h2> -<span class="date">%s <!-- {{ post.epoch }} --></span> +<span class="date">%s</span> </div> <div class="body"> %s -</div> <!--body--> +</div> <hr class="hdiv"/> </div> -<!-- end post: {{ post.id }} --> + diff --git a/assets/static/css/default.css b/assets/static/css/default.css index 3db6da0..c6dcf9a 100644 --- a/assets/static/css/default.css +++ b/assets/static/css/default.css @@ -102,7 +102,7 @@ body { opacity: 0.5; padding: 1px; font-size: 40pt; - height: 0.9em; + /* height: 0.9em; */ text-shadow: 0.0em 0.0em 0.2em rgb(230,230,255); } diff --git a/conf/clog.conf b/conf/clog.conf index c22fc73..a45a039 100644 --- a/conf/clog.conf +++ b/conf/clog.conf @@ -9,7 +9,8 @@ load ./clog.so init workers 4 -seccomp_tracing no +# seccomp_tracing no +seccomp_tracing yes domain * { attach notls @@ -13,7 +13,9 @@ #include "../lib/md4c/src/md4c-html.c" KORE_SECCOMP_FILTER("clog", - KORE_SYSCALL_ALLOW(getdents64) + KORE_SYSCALL_ALLOW(getdents64), + KORE_SYSCALL_ALLOW(sendmmsg), + KORE_SYSCALL_ALLOW(uname) ) int init(int); @@ -68,6 +70,9 @@ render_posts(struct http_request *req, const char *resource) // Post attributes/query results. char *id, *title, *created_at, *body; + // Start writing HTML. + kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html); + // Setup SQL kore_pgsql_init(&sql); @@ -76,16 +81,18 @@ render_posts(struct http_request *req, const char *resource) // kore_pgsql_register()). We also say we will perform a synchronous // query (KORE_PGSQL_SYNC). err = kore_pgsql_setup(&sql, database, KORE_PGSQL_SYNC); - kore_log(LOG_ERR, "kore_pgsql_setup: %d", err); + kore_log(LOG_DEBUG, "kore_pgsql_setup: %d", err); if (!err) { + kore_buf_appendf( + resp_buf, + (const char *) asset_error_html, + "There was an error processing the request." + ); kore_pgsql_logerror(&sql); goto out; } - // Start writing HTML. - kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html); - // Query for posts, check for error. if (!resource) { // Query all posts. @@ -107,6 +114,11 @@ render_posts(struct http_request *req, const char *resource) ); } if (!err) { + kore_buf_appendf( + resp_buf, + (const char *) asset_error_html, + "There was an error processing the request." + ); kore_pgsql_logerror(&sql); goto out; } @@ -118,7 +130,7 @@ render_posts(struct http_request *req, const char *resource) title = kore_pgsql_getvalue(&sql, row, 1); created_at = kore_pgsql_getvalue(&sql, row, 2); body = kore_pgsql_getvalue(&sql, row, 3); - kore_log(LOG_NOTICE, "id: '%s'; title '%s'", id, title); + kore_log(LOG_DEBUG, "id: '%s'; title '%s'", id, title); // Allocate a buffer to render the markdown as HTML into. struct kore_buf *html_buf = kore_buf_alloc(0); |