about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-07-12 21:20:41 -0400
committerJune McEnroe <june@causal.agency>2020-07-12 21:21:59 -0400
commit05331f57640df204534cfee80c3f4f5255132d15 (patch)
tree6a0148e5d43310bf9bb32d483a31baaba31cb738
parentMove nick delimiters into HTML generation (diff)
downloadscooper-05331f57640df204534cfee80c3f4f5255132d15.tar.gz
scooper-05331f57640df204534cfee80c3f4f5255132d15.zip
Use overlap in search result links
-rw-r--r--html.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/html.c b/html.c
index eefb6e7..7975aab 100644
--- a/html.c
+++ b/html.c
@@ -178,17 +178,20 @@ enum kcgi_err htmlFooter(struct khtmlreq *html) {
 		|| khtml_closeto(html, 0);
 }
 
-static enum kcgi_err eventTime(struct khtmlreq *html, struct Event event) {
-	char time[sizeof("0000-00-00 00:00:00")];
-	strftime(time, sizeof(time), "%F %T", gmtime(&event.time));
+static const char *timestamp(time_t time) {
+	static char stamp[sizeof("0000-00-00 00:00:00")];
+	strftime(stamp, sizeof(stamp), "%F %T", gmtime(&time));
+	return stamp;
+}
 
+static enum kcgi_err eventTime(struct khtmlreq *html, struct Event event) {
 	char *base = NULL;
 	if (event.network && event.context) {
 		base = khttp_urlpart(
 			NULL, NULL, Pages[Events],
 			Keys[Network].name, event.network,
 			Keys[Context].name, event.context,
-			Keys[After].name, time,
+			Keys[After].name, timestamp(event.time - eventsOverlap),
 			NULL
 		);
 		if (!base) err(EX_OSERR, "khttp_urlpart");
@@ -201,8 +204,12 @@ static enum kcgi_err eventTime(struct khtmlreq *html, struct Event event) {
 	enum kcgi_err error = 0
 		|| khtml_attr(html, KELEM_TD, KATTR_CLASS, "time", KATTR__MAX)
 		|| khtml_attr(html, KELEM_A, KATTR_HREF, href, KATTR__MAX)
-		|| khtml_attr(html, KELEM_TIME, KATTR_DATETIME, time, KATTR__MAX)
-		|| khtml_puts(html, time)
+		|| khtml_attr(
+			html, KELEM_TIME,
+			KATTR_DATETIME, timestamp(event.time),
+			KATTR__MAX
+		)
+		|| khtml_puts(html, timestamp(event.time))
 		|| khtml_closeelem(html, 3);
 
 	free(href);