From 3ca8ba8b466028cc5d653b960abd9b2126031fef Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 26 Apr 2020 18:00:30 -0400 Subject: Add mailto address for the archive --- archive.c | 5 ++++- archive.h | 1 + atom.c | 3 ++- bubger.1 | 7 ++++++- html.c | 12 +++++++----- 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]> - [base] + mailto:[addr] [title] [updated] @@ -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 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(), 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) {

[subject]

- [from] + [from]
); 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(
), NULL, NULL); - free(mailto); + free(reply); free(fragment); return error; } @@ -438,6 +438,7 @@ int htmlIndexOpen(FILE *file) { @@ -446,6 +447,7 @@ int htmlIndexOpen(FILE *file) { ); struct Variable vars[] = { { "title", baseTitle }, + { "addr", baseAddress }, {0}, }; return templateRender(file, template, vars, escapeXML); -- cgit 1.4.1