about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--archive.c5
-rw-r--r--archive.h1
-rw-r--r--atom.c3
-rw-r--r--bubger.17
-rw-r--r--html.c12
5 files changed, 20 insertions, 8 deletions
diff --git a/archive.c b/archive.c
index 7aa6028..6a3f612 100644
--- a/archive.c
+++ b/archive.c
@@ -31,6 +31,7 @@
 
 const char *baseURL = "";
 const char *baseTitle;
+const char *baseAddress;
 
 static uint32_t uidRead(const char *path) {
 	FILE *file = fopen(path, "r");
@@ -65,7 +66,7 @@ int main(int argc, char *argv[]) {
 	const char *algo = "REFERENCES";
 	const char *search = "ALL";
 
-	for (int opt; 0 < (opt = getopt(argc, argv, "C:a:h:p:s:t:u:vw:"));) {
+	for (int opt; 0 < (opt = getopt(argc, argv, "C:a:h:m:p:s:t:u:vw:"));) {
 		switch (opt) {
 			break; case 'C': {
 				int error = chdir(optarg);
@@ -73,6 +74,7 @@ int main(int argc, char *argv[]) {
 			}
 			break; case 'a': algo = optarg;
 			break; case 'h': concatHead = optarg;
+			break; case 'm': baseAddress = optarg;
 			break; case 'p': port = optarg;
 			break; case 's': search = optarg;
 			break; case 't': baseTitle = optarg;
@@ -88,6 +90,7 @@ int main(int argc, char *argv[]) {
 	if (!host) errx(EX_USAGE, "host required");
 	if (!user) errx(EX_USAGE, "user required");
 	if (!baseTitle) baseTitle = mailbox;
+	if (!baseAddress) baseAddress = user;
 
 	char *pass = NULL;
 	if (passPath) {
diff --git a/archive.h b/archive.h
index 9a0de12..8cb20fe 100644
--- a/archive.h
+++ b/archive.h
@@ -190,6 +190,7 @@ int mboxBody(FILE *file, const char *body);
 
 extern const char *baseURL;
 extern const char *baseTitle;
+extern const char *baseAddress;
 
 int atomEntryOpen(FILE *file, const struct Envelope *envelope);
 int atomContent(FILE *file, const char *content);
diff --git a/atom.c b/atom.c
index 85393c9..ea58c49 100644
--- a/atom.c
+++ b/atom.c
@@ -158,7 +158,7 @@ int atomIndexOpen(FILE *file) {
 	const char *template = TEMPLATE(
 		<[q]xml version="1.0" encoding="utf-8"[q]>
 		<feed xmlns="http://www.w3.org/2005/Atom">
-		<id>[base]</id>
+		<id>mailto:[addr]</id>
 		<title>[title]</title>
 		<updated>[updated]</updated>
 		<link rel="self" href="[base]/index.atom"/>
@@ -169,6 +169,7 @@ int atomIndexOpen(FILE *file) {
 	strftime(updated, sizeof(updated), "%FT%TZ", gmtime(&now));
 	struct Variable vars[] = {
 		{ "q", "?" },
+		{ "addr", baseAddress },
 		{ "base", (baseURL ? baseURL : "") },
 		{ "title", baseTitle },
 		{ "updated", updated },
diff --git a/bubger.1 b/bubger.1
index ed402a1..9d3d729 100644
--- a/bubger.1
+++ b/bubger.1
@@ -1,4 +1,4 @@
-.Dd April 17, 2020
+.Dd April 26, 2020
 .Dt BUBGER 1
 .Os
 .
@@ -12,6 +12,7 @@
 .Op Fl C Ar path
 .Op Fl a Ar algo
 .Op Fl h Ar head
+.Op Fl m Ar addr
 .Op Fl p Ar port
 .Op Fl s Ar search
 .Op Fl t Ar title
@@ -52,6 +53,10 @@ to the
 .Sy <head>
 element of HTML pages.
 .
+.It Fl m Ar addr
+Set the mailto address for the archive.
+The default address is the username.
+.
 .It Fl p Ar port
 Connect to IMAP on
 .Ar port .
diff --git a/html.c b/html.c
index 5146a34..5acbdf2 100644
--- a/html.c
+++ b/html.c
@@ -69,7 +69,7 @@ htmlAddressList(FILE *file, const char *class, struct AddressList list) {
 	return templateRender(file, TEMPLATE(</ul>), NULL, NULL);
 }
 
-static char *htmlMailto(const struct Envelope *envelope) {
+static char *htmlReply(const struct Envelope *envelope) {
 	const char *template = {
 		"mailto:[mailbox]@[host]"
 		"?subject=[re][subject]"
@@ -142,19 +142,19 @@ int htmlMessageOpen(FILE *file, const struct Envelope *envelope) {
 		<header>
 			<h2 class="subject"><a href="[fragment]">[subject]</a></h2>
 			<address class="from">
-				<a href="[mailto]">[from]</a>
+				<a href="[reply]">[from]</a>
 			</address>
 			<time datetime="[utc]">[date]</time>
 	);
 	char *fragment = htmlFragment(envelope->messageID);
-	char *mailto = htmlMailto(envelope);
+	char *reply = htmlReply(envelope);
 	char utc[sizeof("0000-00-00T00:00:00Z")];
 	strftime(utc, sizeof(utc), "%FT%TZ", gmtime(&envelope->time));
 	struct Variable vars[] = {
 		{ "messageID", envelope->messageID },
 		{ "fragment", fragment },
 		{ "subject", envelope->subject },
-		{ "mailto", mailto },
+		{ "reply", reply },
 		{ "from", addressName(envelope->from) },
 		{ "utc", utc },
 		{ "date", envelope->date },
@@ -166,7 +166,7 @@ int htmlMessageOpen(FILE *file, const struct Envelope *envelope) {
 		|| htmlAddressList(file, "cc", envelope->cc)
 		|| htmlMessageNav(file, envelope)
 		|| templateRender(file, TEMPLATE(</header>), NULL, NULL);
-	free(mailto);
+	free(reply);
 	free(fragment);
 	return error;
 }
@@ -438,6 +438,7 @@ int htmlIndexOpen(FILE *file) {
 			<nav>
 				<ul>
 					<li><a href="index.atom">follow</a></li>
+					<li><a href="mailto:[addr]">write</a></li>
 				</ul>
 			</nav>
 		</header>
@@ -446,6 +447,7 @@ int htmlIndexOpen(FILE *file) {
 	);
 	struct Variable vars[] = {
 		{ "title", baseTitle },
+		{ "addr", baseAddress },
 		{0},
 	};
 	return templateRender(file, template, vars, escapeXML);