summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--html.c32
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;
 }