From b36973dbb430c6ed29dbbd7184a1c5a202c3cd49 Mon Sep 17 00:00:00 2001 From: Kristaps Dzonsons Date: Thu, 15 Dec 2011 12:05:19 +0000 Subject: Some presentation polish in man.cgi: - include search bar above result page (I relent: it's annoying to follow three links then press back three times to get a search page); - make man.cgi.css into man-cgi.css so Apache isn't confused by two handlers (css, cgi); - finally consolidate example.style.css to be under the div.mandoc css selector; - put catman pages under div.catman; - put search bar under div#mancgi; - reflect this properly in the bundled CSS files. --- cgi.c | 70 ++++++++++++++++++++++++++++++++++--------------------------------- 1 file changed, 36 insertions(+), 34 deletions(-) (limited to 'cgi.c') diff --git a/cgi.c b/cgi.c index c203c671..6ab340bb 100644 --- a/cgi.c +++ b/cgi.c @@ -1,4 +1,4 @@ -/* $Id: cgi.c,v 1.31 2011/12/14 13:36:59 kristaps Exp $ */ +/* $Id: cgi.c,v 1.32 2011/12/15 12:05:19 kristaps Exp $ */ /* * Copyright (c) 2011 Kristaps Dzonsons * @@ -80,9 +80,9 @@ struct req { }; static int atou(const char *, unsigned *); -static void catman(const char *); +static void catman(const struct req *, const char *); static int cmp(const void *, const void *); -static void format(const char *); +static void format(const struct req *, const char *); static void html_print(const char *); static void html_putchar(char); static int http_decode(char *); @@ -346,12 +346,14 @@ resp_begin_html(int code, const char *msg) "\n" "\n" - "\n" + "\n" "System Manpage Reference\n" "\n" "\n" - "\n", css); + "\n", css, css); } static void @@ -368,7 +370,8 @@ resp_searchform(const struct req *req) int i; puts(""); - printf("
\n" + printf("
\n" + "\n" "
\n" "Search Parameters\n" "\n" "
\n" - ""); + "\n" + "
"); puts(""); } @@ -549,7 +553,7 @@ pg_index(const struct req *req, char *path) } static void -catman(const char *file) +catman(const struct req *req, const char *file) { FILE *f; size_t len; @@ -562,21 +566,10 @@ catman(const char *file) return; } - resp_begin_http(200, NULL); - printf("\n" - "\n" - "\n" - "\n" - "\n" - "System Manpage Reference\n" - "\n" - "\n" - "\n" - "
\n", css);
+	resp_begin_html(200, NULL);
+	resp_searchform(req);
+	puts("
\n" + "
");
 
 	while (NULL != (p = fgetln(f, &len))) {
 		bold = italic = 0;
@@ -688,6 +681,7 @@ catman(const char *file)
 	}
 
 	puts("
\n" + "
\n" "\n" ""); @@ -695,7 +689,7 @@ catman(const char *file) } static void -format(const char *file) +format(const struct req *req, const char *file) { struct mparse *mp; int fd; @@ -719,22 +713,30 @@ format(const char *file) return; } - snprintf(opts, sizeof(opts), "style=%s/man.css," + snprintf(opts, sizeof(opts), "fragment," "man=%s/search.html?sec=%%S&expr=%%N," /*"includes=/cgi-bin/man.cgi/usr/include/%%I"*/, - css, progname); + progname); mparse_result(mp, &mdoc, &man); + if (NULL == man && NULL == mdoc) { + resp_baddb(); + mparse_free(mp); + return; + } + + resp_begin_html(200, NULL); + resp_searchform(req); + vp = html_alloc(opts); - if (NULL != mdoc) { - resp_begin_http(200, NULL); + if (NULL != mdoc) html_mdoc(vp, mdoc); - } else if (NULL != man) { - resp_begin_http(200, NULL); + else html_man(vp, man); - } else - resp_baddb(); + + puts("\n" + ""); html_free(vp); mparse_free(mp); @@ -829,9 +831,9 @@ pg_show(const struct req *req, char *path) resp_baddb(); else { if (0 == strcmp(cp, "cat")) - catman(fn + 1); + catman(req, fn + 1); else - format(fn + 1); + format(req, fn + 1); } out: if (idx) -- cgit v1.2.3