about summary refs log tree commit diff
path: root/html.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-04-12 21:56:44 -0400
committerJune McEnroe <june@causal.agency>2020-04-12 21:56:44 -0400
commit27ce93d8778ccf68c8b436454213e6f6fe826a38 (patch)
treeddb766133be35390ad3cce7d6e25c608afe74de1 /html.c
parentRefactor exportData some (diff)
downloadbubger-27ce93d8778ccf68c8b436454213e6f6fe826a38.tar.gz
bubger-27ce93d8778ccf68c8b436454213e6f6fe826a38.zip
Concatenate HTML threads
Diffstat (limited to 'html.c')
-rw-r--r--html.c59
1 files changed, 58 insertions, 1 deletions
diff --git a/html.c b/html.c
index de64ed8..e92ab0a 100644
--- a/html.c
+++ b/html.c
@@ -79,6 +79,7 @@ int htmlMessageHead(FILE *file, const struct Envelope *envelope) {
 		{ "re", (strncmp(envelope->subject, "Re: ", 4) ? "Re: " : "") },
 		{ "subject", envelope->subject },
 		{ "messageID", envelope->messageID },
+		{ "pathID", pathMangle(envelope->messageID) },
 		{0},
 	};
 	char *fragment = templateURL("#[messageID]", urlVars);
@@ -86,7 +87,7 @@ int htmlMessageHead(FILE *file, const struct Envelope *envelope) {
 		"mailto:[mailbox]@[host]?subject=[re][subject]&In-Reply-To=[messageID]",
 		urlVars
 	);
-	char *mbox = templateURL("../message/[messageID].mbox", urlVars);
+	char *mbox = templateURL("../message/[pathID].mbox", urlVars);
 
 	char date[256];
 	char utc[sizeof("0000-00-00T00:00:00Z")];
@@ -127,3 +128,59 @@ int htmlMessageTail(FILE *file) {
 	int n = fprintf(file, "</details>\n");
 	return (n < 0 ? n : 0);
 }
+
+int htmlThreadHead(FILE *file, const struct Envelope *envelope) {
+	struct Variable urlVars[] = {
+		{ "pathID", pathMangle(envelope->messageID) },
+		{0},
+	};
+	char *path = templateURL("[pathID]", urlVars);
+
+	struct Variable vars[] = {
+		{ "subject", envelope->subject },
+		{ "path", path },
+		{0},
+	};
+	const char *Head = TEMPLATE(
+		<!DOCTYPE html>
+		<meta charset="utf-8">
+		<title>[subject]</title>
+		<link rel="alternate" type="application/atom+xml" href="[path].atom">
+		<link rel="alternate" type="application/mbox" href="[path].mbox">
+		<style>
+		address { display: inline; }
+		section.thread section.thread:not(:first-child) {
+			border-left: 1px solid gray;
+			padding-left: 2ch;
+		}
+		</style>
+	);
+	int error = templateRender(file, Head, vars, escapeXML);
+	free(path);
+	return error;
+}
+
+int htmlThreadHeader(FILE *file, const struct Envelope *envelope) {
+	struct Variable vars[] = {
+		{ "subject", envelope->subject },
+		{0},
+	};
+	const char *Header = TEMPLATE(
+		<h1>[subject]</h1>
+	);
+	return templateRender(file, Header, vars, escapeXML);
+}
+
+int htmlThreadOpen(FILE *file) {
+	int n = fprintf(file, TEMPLATE(<section class="thread">));
+	return (n < 0 ? n : 0);
+}
+
+int htmlThreadClose(FILE *file) {
+	int n = fprintf(file, TEMPLATE(</section>));
+	return (n < 0 ? n : 0);
+}
+
+int htmlThreadTail(FILE *file) {
+	return 0;
+}