diff options
author | June McEnroe <june@causal.agency> | 2020-07-11 14:04:25 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-07-11 14:04:25 -0400 |
commit | 24c7965d9d0aaf27985d29c5cbb12a4e08ac7d9c (patch) | |
tree | 2a9e3955d59c375edb7d02ae0bd195bf966d57ea /contexts.c | |
parent | Implement basic search page (diff) | |
download | scooper-24c7965d9d0aaf27985d29c5cbb12a4e08ac7d9c.tar.gz scooper-24c7965d9d0aaf27985d29c5cbb12a4e08ac7d9c.zip |
Factor out "scope" of pages
Use this to keep the search query around and hide network and context from the search results if the scope is already limited.
Diffstat (limited to 'contexts.c')
-rw-r--r-- | contexts.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/contexts.c b/contexts.c index d8eb4fd..e17ccfe 100644 --- a/contexts.c +++ b/contexts.c @@ -46,22 +46,22 @@ const char *ContextsQuery = SQL( ); enum kcgi_err pageContexts(struct kreq *req) { - if (!req->fieldmap[Network]) return httpFail(req, KHTTP_400); + struct Scope scope = htmlScope(req); + if (!scope.network) return httpFail(req, KHTTP_400); + enum kcgi_err error = httpHead(req, KHTTP_200, KMIME_TEXT_HTML); if (req->method == KMETHOD_HEAD) return error; - const char *network = req->fieldmap[Network]->parsed.s; - struct khtmlreq html; error = error || khttp_body(req) || khtml_open(&html, req, KHTML_PRETTY) - || htmlHead(&html, network) - || htmlNav(&html, network, NULL); + || htmlHead(&html, scope.network) + || htmlNav(&html, scope); if (error) return error; dbBindInt(stmt.contexts, ":recent", pageRecent); - dbBindText(stmt.contexts, ":network", network); + dbBindText(stmt.contexts, ":network", scope.network); if (pagePublic) dbBindInt(stmt.contexts, ":query", false); enum State { @@ -92,7 +92,7 @@ enum kcgi_err pageContexts(struct kreq *req) { char *href = khttp_urlpart( NULL, NULL, Pages[Events], - Keys[Network].name, network, + Keys[Network].name, scope.network, Keys[Context].name, context, NULL ); |