about summary refs log tree commit diff
path: root/html.c
diff options
context:
space:
mode:
Diffstat (limited to 'html.c')
-rw-r--r--html.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/html.c b/html.c
index f8f8539..5eb2f29 100644
--- a/html.c
+++ b/html.c
@@ -512,31 +512,46 @@ int htmlThreadClose(FILE *file) {
 		|| htmlFooter(file);
 }
 
-int htmlIndexHead(FILE *file) {
+static char *htmlSearchURL(const char *name, const char *type) {
+	struct Variable vars[] = {
+		{ "name", name },
+		{ "type", type },
+		{0},
+	};
+	return templateString(PATH_SEARCH, vars, escapeURL);
+}
+
+int htmlSearchHead(FILE *file, const char *name) {
+	char *atom = htmlSearchURL(name, "atom");
 	const char *template = Q(
 		<!DOCTYPE html>
 		<meta charset="utf-8">
 		<meta name="generator" content="[generator]">
-		<title>[title]</title>
-		<link rel="alternate" type="application/atom+xml" href="index.atom">
+		<title>[+name][name] - [-][title]</title>
+		<link rel="alternate" type="application/atom+xml" href="[atom]">
 		<meta name="viewport" content="width=device-width, initial-scale=1.0">
 	);
 	struct Variable vars[] = {
 		{ "generator", GENERATOR_URL },
+		{ "name", (strcmp(name, "index") ? name : NULL) },
 		{ "title", baseTitle },
+		{ "atom", atom },
 		{0},
 	};
-	return 0
+	int error = 0
 		|| templateRender(file, template, vars, escapeXML)
 		|| htmlStylesheet(file);
+	free(atom);
+	return error;
 }
 
-int htmlIndexOpen(FILE *file) {
+int htmlSearchOpen(FILE *file, const char *name) {
+	char *atom = htmlSearchURL(name, "atom");
 	const char *template = Q(
 		<header class="index">
-			<h1>[title]</h1>
+			<h1>[+name][name] - [-][title]</h1>
 			<nav>
-				<a href="index.atom">follow</a>
+				<a href="[atom]">follow</a>
 				[+subscribe]
 				<a href="[subscribe]">subscribe</a>
 				[-]
@@ -549,15 +564,19 @@ int htmlIndexOpen(FILE *file) {
 			<ol>
 	);
 	struct Variable vars[] = {
+		{ "name", (strcmp(name, "index") ? name : NULL) },
 		{ "title", baseTitle },
+		{ "atom", atom },
 		{ "subscribe", baseSubscribe },
 		{ "mailto", baseMailto },
 		{0},
 	};
-	return templateRender(file, template, vars, escapeXML);
+	int error = templateRender(file, template, vars, escapeXML);
+	free(atom);
+	return error;
 }
 
-static char *htmlIndexURL(const struct Envelope *envelope) {
+static char *htmlSearchThreadURL(const struct Envelope *envelope) {
 	struct Variable vars[] = {
 		{ "messageID", envelope->messageID },
 		{ "type", "html" },
@@ -566,10 +585,10 @@ static char *htmlIndexURL(const struct Envelope *envelope) {
 	return templateString(PATH_THREAD, vars, escapeURL);
 }
 
-int htmlIndexThread(
+int htmlSearchThread(
 	FILE *file, const struct Envelope *envelope, struct List thread
 ) {
-	char *url = htmlIndexURL(envelope);
+	char *url = htmlSearchThreadURL(envelope);
 	const char *template = Q(
 		<li>
 			<h2 class="Subject"><a href="[url]">[subject]</a></h2>
@@ -594,7 +613,7 @@ int htmlIndexThread(
 	return error;
 }
 
-int htmlIndexClose(FILE *file) {
+int htmlSearchClose(FILE *file) {
 	return 0
 		|| templateRender(file, Q(</ol></main>), NULL, NULL)
 		|| htmlFooter(file);