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 -13Add The Demolished ManJune McEnroe 2019-04-07Add AmatkaJune McEnroe 2019-04-03Add Space OperaJune McEnroe 2019-03-22Add An Unkindness of GhostsJune McEnroe 2019-03-14Highlight line continuations in line commentsJune McEnroe 2019-03-14Add The Long Way to a Small Angry PlanetJune McEnroe 2019-03-10Add Bleachers Tiny Desk ConcertJune McEnroe 2019-02-28Add Station ElevenJune McEnroe 2019-02-27Use getsubopt(3) to parse -o options in hiJune McEnroe 2019-02-27Add type and ulimit shell keywordsJune McEnroe 2019-02-27Fix make target pattern whitespace in hiJune McEnroe 2019-02-27Delete extraneous <pre> in html.shJune McEnroe 2019-02-24Use setopt in upJune McEnroe 2019-02-24Add setoptJune McEnroe 2019-02-20Match make targets as TagJune McEnroe 2019-02-20Use $PWD in html.sh to pass absolute path to manJune McEnroe 2019-02-20Factor out html.sh and produce html for all sourcesJune McEnroe Except for gfx-cocoa because I don't have an Objective-C highlighter. Also hypothetically the .h rule could match up headers with .3 manual pages if I cared to write them. 2019-02-20Add Dirk Gently's Holistic Detective AgencyJune McEnroe 2019-02-20Move /opt/pkg after /usr in PATHJune McEnroe Installing mandoc from pkgsrc also installs a man executable which is horribly broken. Keep using the system man. 2019-02-20Set man_hard_wrap in nvimJune McEnroe Vendoring man.vim until <https://github.com/neovim/neovim/pull/9633> is merged and appears in a release. 2019-02-18Use hi -o anchor in upJune McEnroe 2019-02-18Don't match nested parentheses in Tag for CJune McEnroe Fixes mistaken highlight of: pngWrite(file, (uint8_t []) { 0, 0, 0 }, 3); 2019-02-18Match whitespace between * [] {}June McEnroe 2019-02-18Fix function-like #define regexJune McEnroe A define like #define FOO (1) is not function-like. 2019-02-18Match Tag in RustJune McEnroe 2019-02-18Match sh functions as TagJune McEnroe 2019-02-18Match Sh and Ss as Tag in mdocJune McEnroe 2019-02-18Match statics and typedefs as TagJune McEnroe 2019-02-18Clean up htmlHeaderJune McEnroe 2019-02-18Remove hi line numberingJune McEnroe Tags are much better for referring to specific parts of a file and line numbering is better done by a post-processing tool such as cat -n or producing a two-column HTML <table>. 2019-02-18Add Tag class to hiJune McEnroe 2019-02-17Generate HTML with hi -n -f html -o anchorJune McEnroe Running hi twice to insert stuff between the head and the content is a bit of a hack but oh well. 2019-02-17Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe Renames previous -n option to -m to stay consistent with cat -n. Prefixing lines with line numbers affects where the first tab indent ends up relative to the text above it. Not sure if it's worth fixing somehow. 2019-02-17Always split spans after newlinesJune McEnroe Simplifies ANSI and IRC output code, and prepares for line numbered output. 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe