diff options
Diffstat (limited to '')
-rw-r--r-- | html.c | 43 |
1 files 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(<li><address class="[class]">[name]</address></li>), + vars, + escapeXML + ); + } else if (addr.mailbox) { + return templateRender( + file, + TEMPLATE(<li><address class="[class] group">[mailbox]<ul>), + vars, + escapeXML + ); + } else { + return templateRender( + file, + TEMPLATE(</ul></address></li>), + 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(<li><address class="[class]">[name]</address></li>), - vars, - escapeXML - ); + error = htmlAddress(file, class, list.addrs[i]); if (error) return error; } return templateRender(file, TEMPLATE(</ul>), vars, escapeXML); |