From f3662faba6eee9f5136ebbd2b326d10c648ca7ac Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Mon, 1 Mar 2021 22:12:18 -0500 Subject: Generate properly populated reply Cc lists --- archive.c | 1 - atom.c | 3 +-- bubger.1 | 10 ++++++---- html.c | 34 ++++++++++++++++++++++++++++++---- 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( bubger - mailto:[mailto] + [base]/ [title] [updated] @@ -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] subscribe [-] + [+mailto] write + [-]
-- cgit 1.4.1