summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--archive.c1
-rw-r--r--atom.c3
-rw-r--r--bubger.110
-rw-r--r--html.c34
4 files changed, 37 insertions, 11 deletions
diff --git a/archive.c b/archive.c
index 86f0687..bdf51aa 100644
--- a/archive.c
+++ b/archive.c
@@ -126,7 +126,6 @@ int main(int argc, char *argv[]) {
 		host++;
 	}
 	if (!baseTitle) baseTitle = mailbox;
-	if (!baseMailto) baseMailto = user;
 
 	char *pass = NULL;
 	if (passPath) {
diff --git a/atom.c b/atom.c
index 16215df..14f9d54 100644
--- a/atom.c
+++ b/atom.c
@@ -166,7 +166,7 @@ int atomIndexOpen(FILE *file) {
 	const char *template = XML_DECL Q(
 		<feed xmlns="http://www.w3.org/2005/Atom">
 		<generator uri="[generator]">bubger</generator>
-		<id>mailto:[mailto]</id>
+		<id>[base]/</id>
 		<title>[title]</title>
 		<updated>[updated]</updated>
 		<link rel="self" href="[base]/index.atom"/>
@@ -174,7 +174,6 @@ int atomIndexOpen(FILE *file) {
 	);
 	struct Variable vars[] = {
 		{ "generator", GENERATOR_URL },
-		{ "mailto", baseMailto },
 		{ "title", baseTitle },
 		{ "updated", iso8601(time(NULL)).s },
 		{ "base", baseURL },
diff --git a/bubger.1 b/bubger.1
index 6b6e1e2..794303c 100644
--- a/bubger.1
+++ b/bubger.1
@@ -1,4 +1,4 @@
-.Dd December 10, 2020
+.Dd March  1, 2021
 .Dt BUBGER 1
 .Os
 .
@@ -82,9 +82,11 @@ rendered archive
 has been updated.
 .
 .It Fl m Ar addr
-Set the mailto and reply Cc address for the archive.
-The default address is
-.Ar user .
+Add a
+.Dq write
+mailto link of
+.Ar addr
+to the index page navigation.
 .
 .It Fl p Ar port
 Connect to IMAP on
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">