summary refs log tree commit diff
path: root/html.c
diff options
context:
space:
mode:
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;
+}