From 24c7965d9d0aaf27985d29c5cbb12a4e08ac7d9c Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sat, 11 Jul 2020 14:04:25 -0400 Subject: 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. --- contexts.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'contexts.c') 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 ); -- cgit 1.4.1