From ff008cf17716c1b0b4394e9d0b83969e419eb844 Mon Sep 17 00:00:00 2001 From: Michael McVady Date: Fri, 12 Jan 2024 15:39:59 -0600 Subject: Clean up hardcoded strings --- src/clog.c | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/clog.c b/src/clog.c index 6f54d0f..5f41ce5 100644 --- a/src/clog.c +++ b/src/clog.c @@ -52,9 +52,6 @@ static const char * const error_msg[] = { [HTTP_STATUS_INTERNAL_ERROR] = "There was an error processing the request.", // 500 }; -// void entry_init(); -// void entry_cleanup(); - void entry_query_init(struct entry_query *eq, const char *id); void entry_query_cleanup(struct entry_query *eq); @@ -71,8 +68,6 @@ int get_entry(struct http_request *req); int edit_entry(struct http_request *req); int update_entry(struct http_request *req); -// int v_example_func(struct http_request *req, char *data); - int sql_select(struct entry_query *eq); int sql_update(const char *id, const char *title, const char *body); // int sql_delete(const char *id); @@ -152,9 +147,9 @@ int http_ok_resp( const char *body = kore_buf_stringify(content, NULL); http_response_header(req, "content-type", "text/html; charset=utf-8"); - kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html); + kore_buf_append(resp_buf, asset_header_html, asset_len_header_html); kore_buf_append(resp_buf, body, strlen(body)); - kore_buf_append(resp_buf, asset_index_end_html, asset_len_index_end_html); + kore_buf_append(resp_buf, asset_footer_html, asset_len_footer_html); http_response(req, status, resp_buf->data, resp_buf->offset); @@ -170,9 +165,9 @@ int http_err_resp( struct kore_buf *resp_buf = kore_buf_alloc(0); http_response_header(req, "content-type", "text/html; charset=utf-8"); - kore_buf_append(resp_buf, asset_index_begin_html, asset_len_index_begin_html); + kore_buf_append(resp_buf, asset_header_html, asset_len_header_html); kore_buf_appendf(resp_buf, (const char *) asset_error_html, error_msg[status]); - kore_buf_append(resp_buf, asset_index_end_html, asset_len_index_end_html); + kore_buf_append(resp_buf, asset_footer_html, asset_len_footer_html); http_response(req, status, resp_buf->data, resp_buf->offset); @@ -205,29 +200,21 @@ int get_index(struct http_request *req) { } // Write table header. - kore_buf_append( - content, - (const char *) "

clog.bunkergate.org

\r\n\r\n", - 94 - ); + kore_buf_append(content, asset_index_header_html, asset_len_index_header_html); // Iterate over entries and render them. for (row = 0; row < eq.num_entries; row++) { // Append rendered MD entry. kore_buf_appendf( content, - (const char *) "\r\n", + (const char *) asset_index_row_html, eq.entries[row]->id, eq.entries[row]->title, eq.entries[row]->created_at, eq.entries[row]->updated_at ); - } // Write table footer. - kore_buf_append( - content, - (const char *) "
titlecreatedupdated
%s%s%s
\r\n", - 10 - ); + kore_buf_append(content, asset_index_footer_html, asset_len_index_footer_html); + http_ok_resp(req, HTTP_STATUS_OK, content); @@ -403,7 +390,6 @@ int update_entry(struct http_request *req) { } err = sql_update(id, title, body); - // err = KORE_RESULT_ERROR; if (err == KORE_RESULT_ERROR) { kore_log(LOG_ERR, "Error updating entry id %s.", id); http_err_resp(req, HTTP_STATUS_INTERNAL_ERROR); -- cgit v1.2.3