summary refs log tree commit diff
path: root/events.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-10 14:54:45 -0400
committerJune McEnroe <june@causal.agency>2020-07-10 14:54:45 -0400
commit3926094bc216277ff6c58e6e9efba64fc7af91da (patch)
tree55362740094489c3e59fbc125ed181dd18cf0077 /events.c
parentAdd -l and -r options (diff)
downloadscooper-3926094bc216277ff6c58e6e9efba64fc7af91da.tar.gz
scooper-3926094bc216277ff6c58e6e9efba64fc7af91da.zip
Implement partial table output of events
This should work for both events and search pages.
Diffstat (limited to 'events.c')
-rw-r--r--events.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/events.c b/events.c
index 7962ab3..32e94c2 100644
--- a/events.c
+++ b/events.c
@@ -107,7 +107,8 @@ enum kcgi_err pageEvents(struct kreq *req) {
 		|| khttp_body(req)
 		|| khtml_open(&html, req, KHTML_PRETTY)
 		|| htmlHead(&html, context)
-		|| htmlNav(&html, network, context);
+		|| htmlNav(&html, network, context)
+		|| khtml_elem(&html, KELEM_TABLE);
 	if (error) return error;
 
 	sqlite3_stmt *events = stmt.eventsAfter;
@@ -121,11 +122,17 @@ enum kcgi_err pageEvents(struct kreq *req) {
 
 	int result;
 	while (SQLITE_ROW == (result = sqlite3_step(events))) {
-		const char *msg = (const char *)sqlite3_column_text(events, 7);
-		if (!msg) continue;
-		error = 0
-			|| khtml_puts(&html, msg)
-			|| khtml_elem(&html, KELEM_BR);
+		struct Event event = {
+			.event = sqlite3_column_int64(events, 0),
+			.time = sqlite3_column_int64(events, 1),
+			.type = sqlite3_column_int(events, 2),
+			.nick = (const char *)sqlite3_column_text(events, 3),
+			.user = (const char *)sqlite3_column_text(events, 4),
+			.host = (const char *)sqlite3_column_text(events, 5),
+			.target = (const char *)sqlite3_column_text(events, 6),
+			.message = (const char *)sqlite3_column_text(events, 7),
+		};
+		error = htmlEvent(&html, event);
 		if (error) break;
 	}
 	if (result != SQLITE_DONE) errx(EX_SOFTWARE, "%s", sqlite3_errmsg(db));