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. --- server.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'server.h') diff --git a/server.h b/server.h index 502e228..318d103 100644 --- a/server.h +++ b/server.h @@ -171,10 +171,24 @@ static inline enum kcgi_err httpFail(struct kreq *req, enum khttp http) { || khttp_printf(req, "%s\n", khttps[http]); } +struct Scope { + const char *network; + const char *context; + const char *query; +}; + +static inline struct Scope htmlScope(struct kreq *req) { + struct Scope s = {0}; + if (req->fieldmap[Network]) s.network = req->fieldmap[Network]->parsed.s; + if (req->fieldmap[Context]) s.context = req->fieldmap[Context]->parsed.s; + if (req->fieldmap[Query]) s.query = req->fieldmap[Query]->parsed.s; + return s; +} + extern const char *htmlStylesheet; 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 htmlNav(struct khtmlreq *html, struct Scope scope); enum kcgi_err htmlFooter(struct khtmlreq *html); -enum kcgi_err htmlEvent(struct khtmlreq *html, struct Event event); +enum kcgi_err htmlEvent( + struct khtmlreq *html, struct Scope scope, struct Event event +); -- cgit 1.4.1