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
Diffstat (limited to '')
-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);
/td> 2020-05-21Expand and clarify documentationJune McEnroe 2020-05-21Execute PAGER with the SHELLJune McEnroe 2020-05-21Automatically perform database migrations in litterboxJune McEnroe 2020-05-20Don't install rc scripts on other platformsJune McEnroe 2020-05-20Rewrite build and install like pounce 1.3June McEnroe 2020-05-20Update email addressesJune McEnroe 2020-04-23Call updateConsumer from handleError 1.2p1June McEnroe 2020-04-20Use . as ${LDLIBS.$@} separatorJune McEnroe 2020-04-05Error on invalid ISUPPORT values 1.2June McEnroe 2020-04-05Only set RCS on FreeBSDJune McEnroe 2020-04-05Log bans and unbansJune McEnroe 2020-04-05Parse mode types from ISUPPORTJune McEnroe 2020-04-05Add unscoop matchers for ban/unban eventsJune McEnroe 2020-04-05Check unscoop regexps with make testJune McEnroe 2020-04-05Add unscoop -n flag for checking regexpsJune McEnroe 2020-04-05Add Ban and Unban event typesJune McEnroe 2020-04-02Update styleJune McEnroe 2020-03-31Update unscoop catgirl matchersJune McEnroe 2020-03-31Fix writing verbose to stderrJune McEnroe 2020-03-02Include <>/-/* around nicks in scoop coloring 1.1June McEnroe 2020-03-02Replace .mk files with configure scriptJune McEnroe 2020-02-28Implement the causal.agency/consumer capabilityJune McEnroe 2020-02-22Include <>/-/* around nicks in coloringJune McEnroe 2020-02-22Use (almost) the full range of IRC colors for nicksJune McEnroe