From 6347c3305092ae574fa7d9b0f444247a509abb3b Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Thu, 30 Apr 2020 17:48:47 -0400 Subject: Add -S for subscribe link These base* variables are badly named... --- archive.c | 4 +++- archive.h | 1 + bubger.1 | 7 ++++++- html.c | 68 +++++++++++++++++++++++++++++++++++++-------------------------- 4 files changed, 50 insertions(+), 30 deletions(-) diff --git a/archive.c b/archive.c index ca2914f..d6cc74c 100644 --- a/archive.c +++ b/archive.c @@ -32,6 +32,7 @@ const char *baseURL = ""; const char *baseTitle; const char *baseAddress; +const char *baseSubscribe; static uint32_t uidRead(const char *path) { FILE *file = fopen(path, "r"); @@ -75,12 +76,13 @@ 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:m:p:qs:t:u:vw:"));) { + for (int opt; 0 < (opt = getopt(argc, argv, "C:S:a:h:m:p:qs:t:u:vw:"));) { switch (opt) { break; case 'C': { int error = chdir(optarg); if (error) err(EX_NOINPUT, "%s", optarg); } + break; case 'S': baseSubscribe = optarg; break; case 'a': algo = optarg; break; case 'h': concatHead = optarg; break; case 'm': baseAddress = optarg; diff --git a/archive.h b/archive.h index 8d55328..5b7b134 100644 --- a/archive.h +++ b/archive.h @@ -183,6 +183,7 @@ char *templateURL(const char *template, const struct Variable vars[]); extern const char *baseURL; extern const char *baseTitle; extern const char *baseAddress; +extern const char *baseSubscribe; #define MBOX_HEADERS \ "Date Subject From Sender Reply-To To Cc Bcc " \ diff --git a/bubger.1 b/bubger.1 index b626f6c..230adf1 100644 --- a/bubger.1 +++ b/bubger.1 @@ -1,4 +1,4 @@ -.Dd April 26, 2020 +.Dd April 30, 2020 .Dt BUBGER 1 .Os . @@ -10,6 +10,7 @@ .Nm .Op Fl qv .Op Fl C Ar path +.Op Fl S Ar url .Op Fl a Ar algo .Op Fl h Ar head .Op Fl m Ar addr @@ -38,6 +39,10 @@ Change directory to .Ar path before reading and writing files. . +.It Fl S Ar url +Add a subscribe link +to the index page navigation. +. .It Fl a Ar algo Set the threading algorithm to one of .Sy ORDEREDSUBJECT diff --git a/html.c b/html.c index 3cc740c..24cdf1a 100644 --- a/html.c +++ b/html.c @@ -109,31 +109,31 @@ static char *htmlMbox(const char *messageID) { return templateURL("../" PATH_MESSAGE, vars); } +static int +htmlNavItem(FILE *file, const char *name, const char *base, const char *url) { + const char *template = TEMPLATE( +
  • [name]
  • + ); + struct Variable vars[] = { + { "name", name }, + { "base", base }, + { "url", url }, + {0}, + }; + return templateRender(file, template, vars, escapeXML); +} + int htmlMessageNav(FILE *file, const struct Envelope *envelope) { int error = templateRender(file, TEMPLATE(), NULL, NULL); @@ -505,26 +505,38 @@ int htmlIndexHead(FILE *file) { return templateRender(file, template, vars, escapeXML); } +static int htmlIndexNav(FILE *file) { + int error = 0 + || templateRender(file, TEMPLATE(), NULL, NULL); +} + int htmlIndexOpen(FILE *file) { - const char *template = TEMPLATE( + const char *head = TEMPLATE(

    [title]

    - -
    -
    -
      ); struct Variable vars[] = { { "title", baseTitle }, - { "addr", baseAddress }, {0}, }; - return templateRender(file, template, vars, escapeXML); + const char *tail = TEMPLATE( + +
      +
        + ); + return 0 + || templateRender(file, head, vars, escapeXML) + || htmlIndexNav(file) + || templateRender(file, tail, NULL, NULL); } static char *htmlIndexURL(const struct Envelope *envelope) { -- cgit 1.4.1