about summary refs log tree commit diff
path: root/search.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-12 12:17:44 -0400
committerJune McEnroe <june@causal.agency>2020-07-12 12:17:44 -0400
commit7ff6e16e8ccda2433006f949ffc7b1ee5eaf08cf (patch)
tree03abf9d87da7810b364d27f97f9e541df9c9e46f /search.c
parentClean up page error handling (diff)
downloadscooper-7ff6e16e8ccda2433006f949ffc7b1ee5eaf08cf.tar.gz
scooper-7ff6e16e8ccda2433006f949ffc7b1ee5eaf08cf.zip
Reorganize code and add earlier messages link
Diffstat (limited to 'search.c')
-rw-r--r--search.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/search.c b/search.c
index 1cfc0f1..7960d6b 100644
--- a/search.c
+++ b/search.c
@@ -44,8 +44,8 @@ const char *SearchQuery = SQL(
 	LIMIT :offset, :limit;
 );
 
-enum kcgi_err pageSearch(struct kreq *req) {
-	struct Scope scope = htmlScope(req);
+enum kcgi_err searchPage(struct kreq *req) {
+	struct Scope scope = pageScope(req);
 	if (!scope.query) return httpFail(req, KHTTP_400);
 	if (scope.context && !scope.network) return httpFail(req, KHTTP_400);
 
@@ -68,8 +68,8 @@ enum kcgi_err pageSearch(struct kreq *req) {
 	dbBindText(stmt.search, ":network", scope.network);
 	dbBindText(stmt.search, ":context", scope.context);
 	dbBindText(stmt.search, ":query", scope.query);
-	dbBindInt(stmt.search, ":public", pagePublic);
-	dbBindInt(stmt.search, ":limit", pageLimit);
+	dbBindInt(stmt.search, ":public", contextsPublic);
+	dbBindInt(stmt.search, ":limit", eventsLimit);
 	dbBindInt(stmt.search, ":offset", offset);
 	dbBindText(stmt.search, ":highlight", "\26");
 
@@ -88,8 +88,8 @@ enum kcgi_err pageSearch(struct kreq *req) {
 		event.target = sqlite3_column_text(stmt.search, i++);
 		event.message = sqlite3_column_text(stmt.search, i++);
 		error = htmlEvent(&html, scope, event);
-		if (error) break;
+		if (error) return error;
 	}
 	if (result != SQLITE_DONE) errx(EX_SOFTWARE, "%s", sqlite3_errmsg(db));
-	return error || htmlFooter(&html) || khtml_close(&html);
+	return htmlFooter(&html) || khtml_close(&html);
 }