From 5956e421952721dfea0eff838f74a5d4f13b5e94 Mon Sep 17 00:00:00 2001 From: "C. McEnroe" Date: Fri, 11 Jun 2021 16:09:27 -0400 Subject: Generalize index.{atom,html} to search pages --- atom.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'atom.c') diff --git a/atom.c b/atom.c index 14f9d54..a58f71c 100644 --- a/atom.c +++ b/atom.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -162,26 +163,43 @@ int atomThreadClose(FILE *file) { return templateRender(file, Q(), NULL, NULL); } -int atomIndexOpen(FILE *file) { +static char *atomSearchURL(const char *name, const char *type) { + struct Variable vars[] = { + { "name", name }, + { "type", type }, + {0}, + }; + return templateString("/" PATH_SEARCH, vars, escapeURL); +} + +int atomSearchOpen(FILE *file, const char *name) { + char *atom = atomSearchURL(name, "atom"); + char *html = atomSearchURL(name, "html"); const char *template = XML_DECL Q( bubger - [base]/ - [title] + [base][atom] + [+name][name] - [-][title] [updated] - - + + ); struct Variable vars[] = { { "generator", GENERATOR_URL }, + { "name", (strcmp(name, "index") ? name : NULL) }, { "title", baseTitle }, { "updated", iso8601(time(NULL)).s }, { "base", baseURL }, + { "atom", atom }, + { "html", html }, {0}, }; - return templateRender(file, template, vars, escapeXML); + int error = templateRender(file, template, vars, escapeXML); + free(atom); + free(html); + return error; } -int atomIndexClose(FILE *file) { +int atomSearchClose(FILE *file) { return templateRender(file, Q(), NULL, NULL); } -- cgit 1.4.1