From 046ec8d7e528dbef753e7b19ab4b38756c81cdca Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 10 Jul 2020 10:22:54 -0400 Subject: Fold search form into nav CSS is kind of almost working for me here. I await its inevitable betrayal. --- contexts.c | 3 +-- default.css | 34 ++++++++++++++++++++++++++++++++++ events.c | 3 +-- html.c | 43 +++++++++++++++++++------------------------ networks.c | 3 +-- server.h | 3 --- 6 files changed, 56 insertions(+), 33 deletions(-) diff --git a/contexts.c b/contexts.c index bf5811f..b81c515 100644 --- a/contexts.c +++ b/contexts.c @@ -57,8 +57,7 @@ enum kcgi_err pageContexts(struct kreq *req) { || khttp_body(req) || khtml_open(&html, req, KHTML_PRETTY) || htmlHead(&html, network) - || htmlNav(&html, network, NULL) - || htmlSearch(&html, network, NULL); + || htmlNav(&html, network, NULL); if (error) return error; dbBindText(stmt.contexts, ":network", network); diff --git a/default.css b/default.css index edd2af3..5ed641e 100644 --- a/default.css +++ b/default.css @@ -5,4 +5,38 @@ html { body { max-width: 130ch; margin: auto; + padding: 1em 1ch; +} + +h1 { + margin: 0; +} + +nav { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + margin-bottom: 1em; +} + +nav ol { + margin: 1em 0 0; + padding: 0; + list-style-type: none; +} +nav ol li { + display: inline; +} +nav ol li::before { + content: '/'; +} + +nav form { + margin-top: 1em; +} +nav form span[title] { + text-decoration: underline; + text-decoration-style: dotted; + cursor: help; } diff --git a/events.c b/events.c index f40e5ae..deedc59 100644 --- a/events.c +++ b/events.c @@ -107,8 +107,7 @@ enum kcgi_err pageEvents(struct kreq *req) { || khttp_body(req) || khtml_open(&html, req, KHTML_PRETTY) || htmlHead(&html, context) - || htmlNav(&html, network, context) - || htmlSearch(&html, network, context); + || htmlNav(&html, network, context); if (error) return error; sqlite3_stmt *events = stmt.eventsAfter; diff --git a/html.c b/html.c index dbc6631..af1ffb2 100644 --- a/html.c +++ b/html.c @@ -40,6 +40,13 @@ enum kcgi_err htmlHead(struct khtmlreq *html, const char *title) { || khtml_closeelem(html, 1); } +static const char *SyntaxURL = { + "https://www.sqlite.org/fts5.html#full_text_query_syntax" +}; +static const char *Columns = { + "network, channel, query, nick, user, target, message" +}; + enum kcgi_err htmlNav(struct khtmlreq *html, const char *network, const char *context) { enum kcgi_err error = 0 @@ -82,40 +89,20 @@ htmlNav(struct khtmlreq *html, const char *network, const char *context) { if (error) return error; } - return khtml_closeelem(html, 2); -} - -static const char *SyntaxURL = { - "https://www.sqlite.org/fts5.html#full_text_query_syntax" -}; - -static const char *Columns = { - "network, channel, query, nick, user, target, message" -}; - -enum kcgi_err -htmlSearch(struct khtmlreq *html, const char *network, const char *context) { char label[256]; snprintf( label, sizeof(label), "Search%s%s", (network ? " " : ""), (context ? context : network ? network : "") ); - enum kcgi_err error = 0 + error = 0 + || khtml_closeelem(html, 1) || khtml_attr( html, KELEM_FORM, KATTR_METHOD, "get", KATTR_ACTION, Pages[Search], KATTR__MAX ) - || khtml_attr(html, KELEM_A, KATTR_HREF, SyntaxURL, KATTR__MAX) - || khtml_puts(html, "Syntax") - || khtml_closeelem(html, 1) - || khtml_putc(html, ' ') - || khtml_attr(html, KELEM_SPAN, KATTR_TITLE, Columns, KATTR__MAX) - || khtml_puts(html, "Columns") - || khtml_closeelem(html, 1) - || khtml_putc(html, ' ') || khtml_attr( html, KELEM_INPUT, KATTR_TYPE, "search", @@ -127,7 +114,15 @@ htmlSearch(struct khtmlreq *html, const char *network, const char *context) { KATTR_TYPE, "submit", KATTR_VALUE, label, KATTR__MAX - ); + ) + || khtml_putc(html, ' ') + || khtml_attr(html, KELEM_A, KATTR_HREF, SyntaxURL, KATTR__MAX) + || khtml_puts(html, "Syntax") + || khtml_closeelem(html, 1) + || khtml_putc(html, ' ') + || khtml_attr(html, KELEM_SPAN, KATTR_TITLE, Columns, KATTR__MAX) + || khtml_puts(html, "Columns") + || khtml_closeelem(html, 1); if (error) return error; if (network) { @@ -152,5 +147,5 @@ htmlSearch(struct khtmlreq *html, const char *network, const char *context) { if (error) return error; } - return khtml_closeelem(html, 1); + return khtml_closeelem(html, 2); } diff --git a/networks.c b/networks.c index ed19394..d1e292d 100644 --- a/networks.c +++ b/networks.c @@ -52,8 +52,7 @@ enum kcgi_err pageNetworks(struct kreq *req) { || khttp_body(req) || khtml_open(&html, req, KHTML_PRETTY) || htmlHead(&html, "Litterbox") - || htmlNav(&html, NULL, NULL) - || htmlSearch(&html, NULL, NULL); + || htmlNav(&html, NULL, NULL); if (error) return error; enum State { diff --git a/server.h b/server.h index f863b75..d07631e 100644 --- a/server.h +++ b/server.h @@ -141,6 +141,3 @@ enum kcgi_err htmlHead(struct khtmlreq *html, const char *title); enum kcgi_err htmlNav( struct khtmlreq *html, const char *network, const char *context ); -enum kcgi_err htmlSearch( - struct khtmlreq *html, const char *network, const char *context -); -- cgit 1.4.1