From 953ac12a76a2bc0fb6f004d22182466b79def16b Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 29 Nov 2020 23:33:40 -0500 Subject: Stop being so weird about HTML --- default.html | 45 ++-------- html.c | 263 ++++++++++++++++++++++++++++++----------------------------- 2 files changed, 143 insertions(+), 165 deletions(-) diff --git a/default.html b/default.html index 36736a6..7300f7c 100644 --- a/default.html +++ b/default.html @@ -12,11 +12,9 @@ body { nav ul { padding: 0; list-style-type: none; - display: flex; - flex-wrap: wrap; } nav ul li { - margin-right: 1.5ch; + display: inline; } main.index ol { @@ -30,15 +28,12 @@ main.index h2 { font-size: 1em; margin: 0; } -main.index data.replies, main.index time { +main.index time, main.index data.replies { display: block; } main.index data.replies[value="0"] { display: none; } -main.index data.replies::before { - content: '+'; -} article.message header { background-color: gainsboro; @@ -55,41 +50,14 @@ article.message header nav ul { margin: 0; } -address { - display: inline; - font-style: inherit; -} -ul.recipient { +ul.address { margin: 0; padding: 0; list-style-type: none; - display: flex; - flex-wrap: wrap; -} -ul.recipient li:not(:last-child)::after { - content: ', '; - margin-right: 1ch; -} -ul.recipient li.group > address::after { - content: ': '; -} -ul.recipient li.group::after { - content: '; '; - margin-right: 1ch; -} -address.from::before { - content: 'From: '; -} -address.from { - margin-right: 1ch; -} -ul.to::before { - content: 'To: '; - margin-right: 1ch; + display: inline; } -ul.cc::before { - content: 'Cc: '; - margin-right: 1ch; +ul.address li { + display: inline; } pre { @@ -133,6 +101,7 @@ details.subthread summary { footer { margin: 1em 0; + font-size: x-small; text-align: center; color: gray; } diff --git a/html.c b/html.c index d55e5bf..4269871 100644 --- a/html.c +++ b/html.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -36,46 +37,64 @@ #include "archive.h" -static int htmlAddress(FILE *file, const char *class, struct Address addr) { +static char *htmlMailto(struct Address addr) { + struct Variable vars[] = { + { "mailbox", addr.mailbox }, + { "host", addr.host }, + {0}, + }; + return templateString("mailto:[mailbox]@[host]", vars, escapeURL); +} + +static int htmlAddress(FILE *file, struct Address addr, bool last) { + char *mailto = htmlMailto(addr); const char *template; if (addr.host) { - template = Q(
  • [name]
  • ); + template = Q( +
  • [name][,]
  • + ); } else if (addr.mailbox) { - template = (const char *) { - Q(
  • ) - Q(
    [mailbox]
    ) - Q(
      ) - }; + template = Q( +
    • [mailbox]: +
        + ); } else { - template = (const char *) { - Q(
      ) - Q(
    • ) - }; + template = Q( +
    ; +
  • + ); } struct Variable vars[] = { - { "class", class }, + { "mailto", mailto }, { "name", addressName(addr) }, { "mailbox", addr.mailbox }, + { ",", (last ? "" : ", ") }, {0}, }; - return templateRender(file, template, vars, escapeXML); + int error = templateRender(file, template, vars, escapeXML); + free(mailto); + return error; } static int -htmlAddressList(FILE *file, const char *class, struct AddressList list) { +htmlAddressList(FILE *file, const char *name, struct AddressList list) { if (!list.len) return 0; - const char *template = Q(
      ); + const char *template = Q( +
      + [name]: +
        + ); struct Variable vars[] = { - { "class", class }, + { "name", name }, {0}, }; int error = templateRender(file, template, vars, escapeXML); if (error) return error; for (size_t i = 0; i < list.len; ++i) { - error = htmlAddress(file, class, list.addrs[i]); + error = htmlAddress(file, list.addrs[i], i == list.len - 1); if (error) return error; } - return templateRender(file, Q(
      ), NULL, NULL); + return templateRender(file, Q(
    ), NULL, NULL); } static char *htmlReply(const struct Envelope *envelope) { @@ -118,7 +137,7 @@ static char *htmlMbox(const char *messageID) { static int htmlNavItem(FILE *file, const char *name, const char *base, const char *url) { - const char *template = Q(
  • [name]
  • ); + const char *template = Q(
  • [name]
  • ); struct Variable vars[] = { { "name", name }, { "base", base }, @@ -129,57 +148,51 @@ htmlNavItem(FILE *file, const char *name, const char *base, const char *url) { } int htmlMessageNav(FILE *file, const struct Envelope *envelope) { - int error = templateRender(file, Q(