summary refs log tree commit diff
path: root/events.c
diff options
context:
space:
mode:
Diffstat (limited to 'events.c')
-rw-r--r--events.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/events.c b/events.c
index 932f535..7f56081 100644
--- a/events.c
+++ b/events.c
@@ -36,6 +36,7 @@ static const char *timestamp(time_t time) {
 
 static enum kcgi_err
 dateForm(struct khtmlreq *html, struct kreq *req, const char *current) {
+	if (req->fieldmap[Export]) return KCGI_OK;
 	struct tm tm = {0};
 	if (!strptime(current, "%F", &tm)) {
 		tm = *gmtime(&(time_t) { time(NULL) });
@@ -66,6 +67,7 @@ dateForm(struct khtmlreq *html, struct kreq *req, const char *current) {
 
 static enum kcgi_err
 displayForm(struct khtmlreq *html, struct kreq *req, bool tidy) {
+	if (req->fieldmap[Export]) return KCGI_OK;
 	return 0
 		|| khtml_attr(
 			html, KELEM_FORM,
@@ -203,7 +205,7 @@ enum kcgi_err eventsPage(struct kreq *req) {
 	struct khtmlreq html;
 	error = error
 		|| khtml_open(&html, req, 0)
-		|| htmlHead(&html, context)
+		|| htmlHead(&html, req, context)
 		|| htmlNav(&html, req)
 		|| khtml_elem(&html, KELEM_DIV)
 		|| dateForm(&html, req, time)
@@ -257,7 +259,7 @@ enum kcgi_err eventsPage(struct kreq *req) {
 		event.target = sqlite3_column_text(events, i++);
 		event.message = sqlite3_column_text(events, i++);
 
-		if (!rows) {
+		if (!rows && !req->fieldmap[Export]) {
 			char *href = NULL;
 			char *page = pageURL(
 				network, context, Before, event.time + eventsOverlap, tidy
@@ -291,7 +293,7 @@ enum kcgi_err eventsPage(struct kreq *req) {
 	}
 	if (result != SQLITE_DONE) errx(EX_SOFTWARE, "%s", sqlite3_errmsg(db));
 
-	if (rows && (rows == eventsLimit || req->fieldmap[Before])) {
+	if ((rows == eventsLimit || req->fieldmap[Before]) && !req->fieldmap[Export]) {
 		char *href = pageURL(
 			network, context, After, prevTime - eventsOverlap, tidy
 		);
@@ -313,5 +315,5 @@ enum kcgi_err eventsPage(struct kreq *req) {
 		if (error) return error;
 	}
 
-	return htmlFooter(&html) || khtml_close(&html);
+	return htmlFooter(&html, req) || khtml_close(&html);
 }