From 0939007c9361b99ebf0cc52a57f71e136c657556 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Sun, 12 Apr 2020 19:43:59 -0400 Subject: Handle address groups in HTML rendering --- html.c | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/html.c b/html.c index ac1411d..de64ed8 100644 --- a/html.c +++ b/html.c @@ -23,6 +23,37 @@ #include "archive.h" +static int htmlAddress(FILE *file, const char *class, struct Address addr) { + struct Variable vars[] = { + { "class", class }, + { "name", addressName(addr) }, + { "mailbox", addr.mailbox }, + {0}, + }; + if (addr.host) { + return templateRender( + file, + TEMPLATE(
  • [name]
  • ), + vars, + escapeXML + ); + } else if (addr.mailbox) { + return templateRender( + file, + TEMPLATE(
  • [mailbox]
      ), + vars, + escapeXML + ); + } else { + return templateRender( + file, + TEMPLATE(
  • ), + vars, + escapeXML + ); + } +} + static int htmlAddressList(FILE *file, const char *class, struct AddressList list) { if (!list.len) return 0; @@ -35,17 +66,7 @@ htmlAddressList(FILE *file, const char *class, struct AddressList list) { ); if (error) return error; for (size_t i = 0; i < list.len; ++i) { - struct Variable vars[] = { - { "class", class }, - { "name", addressName(list.addrs[i]) }, - {0}, - }; - error = templateRender( - file, - TEMPLATE(
  • [name]
  • ), - vars, - escapeXML - ); + error = htmlAddress(file, class, list.addrs[i]); if (error) return error; } return templateRender(file, TEMPLATE(), vars, escapeXML); -- cgit 1.4.1