From 6500baa1ffc720ec4c0f256dd99dab478225122b Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 16 Jul 2020 17:46:19 -0400 Subject: Big refactor, remove struct Scope --- contexts.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'contexts.c') diff --git a/contexts.c b/contexts.c index 5eba403..5c5e5cc 100644 --- a/contexts.c +++ b/contexts.c @@ -58,8 +58,8 @@ const char *ContextsQuery = SQL( ); enum kcgi_err contextsPage(struct kreq *req) { - struct Scope scope = pageScope(req); - if (!scope.network) return httpFail(req, KHTTP_400); + if (!req->fieldmap[Network]) return httpFail(req, KHTTP_400); + const char *network = req->fieldmap[Network]->parsed.s; enum kcgi_err error = 0 || httpHead(req, KHTTP_200, KMIME_TEXT_HTML) @@ -69,12 +69,12 @@ enum kcgi_err contextsPage(struct kreq *req) { struct khtmlreq html; error = error || khtml_open(&html, req, 0) - || htmlHead(&html, scope.network) - || htmlNav(&html, scope); + || htmlHead(&html, network) + || htmlNav(&html, req); if (error) return error; sqlite3_reset(stmt.contexts); - dbBindText(stmt.contexts, ":network", scope.network); + dbBindText(stmt.contexts, ":network", network); dbBindInt(stmt.contexts, ":recent", contextsRecent); dbBindInt(stmt.contexts, ":public", contextsPublic); @@ -94,7 +94,7 @@ enum kcgi_err contextsPage(struct kreq *req) { bool active = sqlite3_column_int(stmt.contexts, i++); enum State prev = state; - state = (active ? Active : (query ? Queries : Channels)); + state = (active ? Active : query ? Queries : Channels); if (state != prev) { error = 0 || khtml_closeelem(&html, 1) @@ -107,7 +107,7 @@ enum kcgi_err contextsPage(struct kreq *req) { char *href = khttp_urlpart( NULL, NULL, Pages[Events], - Keys[Network].name, scope.network, + Keys[Network].name, network, Keys[Context].name, context, NULL ); @@ -126,7 +126,7 @@ enum kcgi_err contextsPage(struct kreq *req) { if (error) return error; sqlite3_reset(stmt.motd); - dbBindText(stmt.motd, ":network", scope.network); + dbBindText(stmt.motd, ":network", network); result = sqlite3_step(stmt.motd); if (result == SQLITE_ROW) { -- cgit 1.4.1