diff options
author | June McEnroe <june@causal.agency> | 2020-04-10 10:57:10 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-04-10 10:57:10 -0400 |
commit | 6f1fc87b39335b4f60d2368413c6da7e732a0d97 (patch) | |
tree | b9c836c20c8901f83e3353cae267114c019fa7a4 /atom.c | |
parent | Rearrange HTML templating code (diff) | |
download | bubger-6f1fc87b39335b4f60d2368413c6da7e732a0d97.tar.gz bubger-6f1fc87b39335b4f60d2368413c6da7e732a0d97.zip |
Rearrange Atom templating code
Diffstat (limited to '')
-rw-r--r-- | atom.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/atom.c b/atom.c index 8991ca7..6692acc 100644 --- a/atom.c +++ b/atom.c @@ -22,40 +22,35 @@ #include "archive.h" -static const char *Envelope = TEMPLATE( - <entry> - <title>[subject]</title> - <author> - <name>[from.name]</name> - <email>[from.mailbox]@[from.host]</email> - </author> - <updated>[date]</updated> - <id>[id]</id> -); - int atomEnvelope(FILE *file, const struct Envelope *envelope) { - const char *from = envelope->from.name; - if (!from) from = envelope->from.mailbox; - - char date[sizeof("0000-00-00T00:00:00Z")]; - strftime(date, sizeof(date), "%FT%TZ", gmtime(&envelope->utc)); - struct Variable idVars[] = { { "messageID", envelope->messageID }, {0}, }; char *id = templateURL("mailto:?In-Reply-To=[messageID]", idVars); + char date[sizeof("0000-00-00T00:00:00Z")]; + strftime(date, sizeof(date), "%FT%TZ", gmtime(&envelope->utc)); struct Variable vars[] = { { "subject", envelope->subject }, - { "from.name", from }, + { "from.name", addressName(envelope->from) }, { "from.mailbox", envelope->from.mailbox }, { "from.host", envelope->from.host }, { "date", date }, { "id", id }, {0}, }; - int error = templateRender(file, Envelope, vars, escapeXML); + const char *Entry = TEMPLATE( + <entry> + <title>[subject]</title> + <author> + <name>[from.name]</name> + <email>[from.mailbox]@[from.host]</email> + </author> + <updated>[date]</updated> + <id>[id]</id> + ); + int error = templateRender(file, Entry, vars, escapeXML); free(id); return error; } |