diff options
author | June McEnroe <june@causal.agency> | 2020-07-09 19:21:28 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-07-09 19:21:28 -0400 |
commit | 87f73ddbc05b38113cb501aad4480490f6604704 (patch) | |
tree | 7629d2d6557f20daa75d38a006f643d25b19fd78 /html.c | |
parent | Split code and add breadcrumb nav (diff) | |
download | scooper-87f73ddbc05b38113cb501aad4480490f6604704.tar.gz scooper-87f73ddbc05b38113cb501aad4480490f6604704.zip |
Add search forms
Diffstat (limited to '')
-rw-r--r-- | html.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/html.c b/html.c index ad80b6f..59ecc30 100644 --- a/html.c +++ b/html.c @@ -89,3 +89,57 @@ htmlNav(struct khtmlreq *html, const char *network, const char *context) { return khtml_closeelem(html, 2); } + +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 + || khtml_attr( + html, KELEM_FORM, + KATTR_METHOD, "get", + KATTR_ACTION, Pages[Search], + KATTR__MAX + ) + || khtml_attr( + html, KELEM_INPUT, + KATTR_TYPE, "search", + KATTR_NAME, Keys[Query].name, + KATTR__MAX + ) + || khtml_attr( + html, KELEM_INPUT, + KATTR_TYPE, "submit", + KATTR_VALUE, label, + KATTR__MAX + ); + if (error) return error; + + if (network) { + error = khtml_attr( + html, KELEM_INPUT, + KATTR_TYPE, "hidden", + KATTR_NAME, Keys[Network].name, + KATTR_VALUE, network, + KATTR__MAX + ); + if (error) return error; + } + + if (context) { + error = khtml_attr( + html, KELEM_INPUT, + KATTR_TYPE, "hidden", + KATTR_NAME, Keys[Context].name, + KATTR_VALUE, context, + KATTR__MAX + ); + if (error) return error; + } + + return khtml_closeelem(html, 1); +} |