summary refs log tree commit diff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--html.c34
1 files changed, 30 insertions, 4 deletions
diff --git a/html.c b/html.c
index fe96a37..77438a0 100644
--- a/html.c
+++ b/html.c
@@ -107,17 +107,35 @@ static char *htmlMbox(const char *messageID) {
 	return templateString("../" PATH_MESSAGE, vars, escapeURL);
 }
 
+static int htmlReplyCc(FILE *file, bool first, struct AddressList list) {
+	for (size_t i = 0; i < list.len; ++i) {
+		const char *template = "[,][mailbox]@[host]";
+		struct Variable vars[] = {
+			{ "mailbox", list.addrs[i].mailbox },
+			{ "host", list.addrs[i].host },
+			{ ",", (!first || i ? "," : "") },
+			{0},
+		};
+		int error = templateRender(file, template, vars, escapeURL);
+		if (error) return error;
+	}
+	return 0;
+}
+
 static char *htmlReply(const struct Envelope *envelope) {
+	char *buf;
+	size_t len;
+	FILE *file = open_memstream(&buf, &len);
+	if (!file) err(EX_OSERR, "open_memstream");
 	const char *template = {
 		"mailto:[mailbox]@[host]"
-		"?cc=[cc]"
-		"&subject=[re][subject]"
+		"?subject=[re][subject]"
 		"&In-Reply-To=[<][messageID][>]"
+		"&cc="
 	};
 	struct Variable vars[] = {
 		{ "mailbox", envelope->replyTo.mailbox },
 		{ "host", envelope->replyTo.host },
-		{ "cc", baseMailto },
 		{ "re", (strncmp(envelope->subject, "Re: ", 4) ? "Re: " : "") },
 		{ "subject", envelope->subject },
 		{ "messageID", envelope->messageID },
@@ -125,7 +143,13 @@ static char *htmlReply(const struct Envelope *envelope) {
 		{ ">", ">" },
 		{0},
 	};
-	return templateString(template, vars, escapeURL);
+	int error = 0
+		|| templateRender(file, template, vars, escapeURL)
+		|| htmlReplyCc(file, true, envelope->to)
+		|| htmlReplyCc(file, false, envelope->cc)
+		|| fclose(file);
+	if (error) err(EX_OSERR, "open_memstream");
+	return buf;
 }
 
 int htmlMessageNav(FILE *file, const struct Envelope *envelope) {
@@ -528,7 +552,9 @@ int htmlIndexOpen(FILE *file) {
 				[+subscribe]
 				<a href="[subscribe]">subscribe</a>
 				[-]
+				[+mailto]
 				<a href="mailto:[mailto]">write</a>
+				[-]
 			</nav>
 		</header>
 		<main class="index">
lass='logmsg'> Otherwise a :: rule includes one of the ':'s in the tag name. 2021-01-19Prefer tag matches not preceded by [[:alnum:]]June McEnroe Otherwise the "id" in "void" matches for "void id". 2021-01-19Escape \ and / in mtags search patternsJune McEnroe 2021-01-20Use mtags in source-filterJune McEnroe 2021-01-19Add mtags to generate tags for make and mdocJune McEnroe 2021-01-19Map tags to IDs using only [[:alnum:]-._]June McEnroe 2021-01-19Don't use a pager if reading standard inputJune McEnroe 2021-01-19Support BSD make syntax and match *.amJune McEnroe These don't really go together, but... 2021-01-19Match tab following escaped newline in make assignmentsJune McEnroe Otherwise it ends up going into Shell state. 2021-01-18Allow matching lexers using first input lineJune McEnroe