diff options
author | June McEnroe <june@causal.agency> | 2020-11-30 01:36:15 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2020-11-30 01:36:15 -0500 |
commit | 216dfe62291ff6e2f1d3211a0d1175b2eace4a20 (patch) | |
tree | 36c29c09a26c95511b97f148c00f7839895e1fa7 | |
parent | Stop being so weird about HTML (diff) | |
download | bubger-216dfe62291ff6e2f1d3211a0d1175b2eace4a20.tar.gz bubger-216dfe62291ff6e2f1d3211a0d1175b2eace4a20.zip |
Move reply link to message nav
-rw-r--r-- | html.c | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/html.c b/html.c index 4269871..95afe4d 100644 --- a/html.c +++ b/html.c @@ -147,31 +147,37 @@ htmlNavItem(FILE *file, const char *name, const char *base, const char *url) { return templateRender(file, template, vars, escapeXML); } +static int htmlParent(FILE *file, const struct Envelope *envelope) { + if (!envelope->inReplyTo) return 0; + char *fragment = htmlFragment(envelope->inReplyTo); + int error = htmlNavItem(file, "parent", "", fragment); + free(fragment); + return error; +} + int htmlMessageNav(FILE *file, const struct Envelope *envelope) { char *mbox = htmlMbox(envelope->messageID); + char *reply = htmlReply(envelope); int error = 0 || templateRender(file, Q(<nav><ul>), NULL, NULL) - || htmlNavItem(file, "download", "", mbox); - if (error) return error; + || htmlParent(file, envelope) + || htmlNavItem(file, "download", "", mbox) + || htmlNavItem(file, "reply", "", reply) + || templateRender(file, Q(</ul></nav>), NULL, NULL); free(mbox); - if (envelope->inReplyTo) { - char *fragment = htmlFragment(envelope->inReplyTo); - error = htmlNavItem(file, "parent", "", fragment); - free(fragment); - if (error) return error; - } - return templateRender(file, Q(</ul></nav>), NULL, NULL); + free(reply); + return error; } int htmlMessageOpen(FILE *file, const struct Envelope *envelope) { char *fragment = htmlFragment(envelope->messageID); - char *reply = htmlReply(envelope); + char *mailto = htmlMailto(envelope->from); const char *template = Q( <article class="message" id="[messageID]"> <header> <h2 class="Subject"><a href="[fragment]">[subject]</a></h2> <div class="From"> - From: <a href="[reply]">[from]</a> + From: <a href="[mailto]">[from]</a> <time datetime="[utc]">[date]</time> </div> ); @@ -179,7 +185,7 @@ int htmlMessageOpen(FILE *file, const struct Envelope *envelope) { { "messageID", envelope->messageID }, { "fragment", fragment }, { "subject", envelope->subject }, - { "reply", reply }, + { "mailto", mailto }, { "from", addressName(envelope->from) }, { "utc", iso8601(envelope->time).s }, { "date", envelope->date }, @@ -192,7 +198,7 @@ int htmlMessageOpen(FILE *file, const struct Envelope *envelope) { || htmlMessageNav(file, envelope) || templateRender(file, Q(</header>), NULL, NULL); free(fragment); - free(reply); + free(mailto); return error; } |