source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mdocml: Have a whatis/apropos mode, with the default (hitting enter
@ 2011-12-07 13:00 kristaps
  0 siblings, 0 replies; only message in thread
From: kristaps @ 2011-12-07 13:00 UTC (permalink / raw)
  To: source

Log Message:
-----------
Have a whatis/apropos mode, with the default (hitting enter within the
expression text) be whatis.  This is a much nicer default than apropos, 
which can be scary.  While here, fix the cat.css location (erroneously
put in the response page instead of the catman page) and add bits for
a default style-sheet.

Modified Files:
--------------
    mdocml:
        Makefile
        cgi.c
        man.cgi.7

Revision Data
-------------
Index: man.cgi.7
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/man.cgi.7,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lman.cgi.7 -Lman.cgi.7 -u -p -r1.3 -r1.4
--- man.cgi.7
+++ man.cgi.7
@@ -39,11 +39,22 @@ The absolute path of the
 cache directory.
 .El
 .Sh FILES
-The configuration file
-.Pa etc/catman.conf
-must exist within the cache directory.
-This is built by
-.Xr catman 8 .
+.Bl -tag -width Ds
+.It Pa etc/catman.conf
+Built by
+.Xr catman 8
+and must exist under the configuration directory root.
+.It Pa man.css
+Must be visible in the server document root, used for styling source
+manual page output.
+.It Pa catman.css
+Must be visible in the server document root, used for styling
+pre-formatted manual page output.
+.It Pa man.cgi.css
+Must be visible in the server document root, used for general styling of
+.Nm
+search and error pages.
+.El
 .Sh SEE ALSO
 .Xr mandoc 3 ,
 .Xr catman 8 ,
Index: cgi.c
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/cgi.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -Lcgi.c -Lcgi.c -u -p -r1.11 -r1.12
--- cgi.c
+++ cgi.c
@@ -297,6 +297,8 @@ resp_begin_html(int code, const char *ms
 	     " <HEAD>"						"\n"
 	     "   <META HTTP-EQUIV=\"Content-Type\" "		"\n"
 	     "         CONTENT=\"text/html; charset=utf-8\">"	"\n"
+	     "  <LINK REL=\"stylesheet\" HREF=\"/man.cgi.css\""	"\n"
+	     "        TYPE=\"text/css\" media=\"all\">"		"\n"
 	     "  <TITLE>System Manpage Reference</TITLE>"	"\n"
 	     " </HEAD>"						"\n"
 	     " <BODY>"						"\n"
@@ -330,21 +332,27 @@ resp_searchform(const struct req *req)
 	printf("<FORM ACTION=\"");
 	html_print(progname);
 	printf("/search.html\" METHOD=\"get\">\n");
-	puts(" <FIELDSET>\n"
-	     "  <INPUT TYPE=\"submit\" VALUE=\"Search:\">");
-	printf("  Terms: <INPUT TYPE=\"text\" "
-			"SIZE=\"60\" NAME=\"expr\" VALUE=\"");
+	puts("<FIELDSET>\n"
+	     "<INPUT TYPE=\"submit\" NAME=\"op\" "
+	      "VALUE=\"Whatis\"> or \n"
+	     "<INPUT TYPE=\"submit\" NAME=\"op\" "
+	      "VALUE=\"apropos\"> for manuals satisfying \n"
+	     "<INPUT TYPE=\"text\" SIZE=\"40\" "
+	      "NAME=\"expr\" VALUE=\"");
 	html_print(expr);
-	puts("\">");
-	printf("  Section: <INPUT TYPE=\"text\" "
-			"SIZE=\"4\" NAME=\"sec\" VALUE=\"");
+	puts("\">, section "
+	     "<INPUT TYPE=\"text\" "
+	      "SIZE=\"4\" NAME=\"sec\" VALUE=\"");
 	html_print(sec);
-	puts("\">");
-	printf("  Arch: <INPUT TYPE=\"text\" "
-			"SIZE=\"8\" NAME=\"arch\" VALUE=\"");
+	puts("\">, arch "
+	     "<INPUT TYPE=\"text\" "
+	      "SIZE=\"8\" NAME=\"arch\" VALUE=\"");
 	html_print(arch);
-	puts("\">");
-	puts(" </FIELDSET>\n</FORM>\n<!-- End search form. //-->");
+	puts("\">.\n"
+	     "<INPUT TYPE=\"reset\" VALUE=\"Reset\">\n"
+	     "</FIELDSET>\n"
+	     "</FORM>\n"
+	     "<!-- End search form. //-->");
 }
 
 static void
@@ -361,12 +369,12 @@ resp_error400(void)
 {
 
 	resp_begin_html(400, "Query Malformed");
-	puts("<H1>Malformed Query</H1>\n"
-	     "<P>\n"
-	     "  The query your entered was malformed.\n"
-	     "  Try again from the\n"
-	     "  <A HREF=\"/index.html\">main page</A>\n"
-	     "</P>");
+	printf("<H1>Malformed Query</H1>\n"
+	       "<P>\n"
+	       "  The query your entered was malformed.\n"
+	       "  Try again from the\n"
+	       "  <A HREF=\"%s/index.html\">main page</A>\n"
+	       "</P>", progname);
 	resp_end_html();
 }
 
@@ -380,11 +388,11 @@ resp_error404(const char *page)
 	     "  The page you're looking for, ");
 	printf("  <B>");
 	html_print(page);
-	puts("</B>,\n"
-	     "  could not be found.\n"
-	     "  Try searching from the\n"
-	     "  <A HREF=\"/index.html\">main page</A>\n"
-	     "</P>");
+	printf("</B>,\n"
+	       "  could not be found.\n"
+	       "  Try searching from the\n"
+	       "  <A HREF=\"%s/index.html\">main page</A>\n"
+	       "</P>", progname);
 	resp_end_html();
 }
 
@@ -423,21 +431,7 @@ resp_search(struct res *r, size_t sz, vo
 		return;
 	}
 
-	resp_begin_http(200, NULL);
-	puts("<!DOCTYPE HTML PUBLIC "				"\n"
-	     " \"-//W3C//DTD HTML 4.01//EN\""			"\n"
-	     " \"http://www.w3.org/TR/html4/strict.dtd\">"	"\n"
-	     "<HTML>"						"\n"
-	     " <HEAD>"						"\n"
-	     "  <META HTTP-EQUIV=\"Content-Type\" "		"\n"
-	     "        CONTENT=\"text/html; charset=utf-8\">"	"\n"
-	     "  <LINK REL=\"stylesheet\" HREF=\"/catman.css\""	"\n"
-	     "        TYPE=\"text/css\" media=\"all\">"		"\n"
-	     "  <TITLE>System Manpage Reference</TITLE>"	"\n"
-	     " </HEAD>"						"\n"
-	     " <BODY>"						"\n"
-	     "<!-- Begin page content. //-->");
-
+	resp_begin_html(200, NULL);
 	resp_searchform((const struct req *)arg);
 
 	if (0 == sz)
@@ -484,7 +478,20 @@ catman(const char *file)
 		return;
 	}
 
-	resp_begin_html(200, NULL);
+	resp_begin_http(200, NULL);
+	puts("<!DOCTYPE HTML PUBLIC "				"\n"
+	     " \"-//W3C//DTD HTML 4.01//EN\""			"\n"
+	     " \"http://www.w3.org/TR/html4/strict.dtd\">"	"\n"
+	     "<HTML>"						"\n"
+	     " <HEAD>"						"\n"
+	     "  <META HTTP-EQUIV=\"Content-Type\" "		"\n"
+	     "        CONTENT=\"text/html; charset=utf-8\">"	"\n"
+	     "  <LINK REL=\"stylesheet\" HREF=\"/catman.css\""	"\n"
+	     "        TYPE=\"text/css\" media=\"all\">"		"\n"
+	     "  <TITLE>System Manpage Reference</TITLE>"	"\n"
+	     " </HEAD>"						"\n"
+	     " <BODY>"						"\n"
+	     "<!-- Begin page content. //-->");
 
 	puts("<PRE>");
 	while (NULL != (p = fgetln(f, &len))) {
@@ -721,7 +728,7 @@ static void
 pg_search(const struct manpaths *ps, const struct req *req, char *path)
 {
 	size_t		  tt;
-	int		  i, sz, rc;
+	int		  i, sz, rc, whatis;
 	const char	 *ep, *start;
 	char		**cp;
 	struct opts	  opt;
@@ -731,6 +738,7 @@ pg_search(const struct manpaths *ps, con
 	cp = NULL;
 	ep = NULL;
 	sz = 0;
+	whatis = 0;
 
 	memset(&opt, 0, sizeof(struct opts));
 
@@ -741,6 +749,9 @@ pg_search(const struct manpaths *ps, con
 			opt.cat = req->fields[i].val;
 		else if (0 == strcmp(req->fields[i].key, "arch"))
 			opt.arch = req->fields[i].val;
+		else if (0 == strcmp(req->fields[i].key, "op"))
+			whatis = 0 == strcasecmp
+				(req->fields[i].val, "whatis");
 
 	/*
 	 * Poor man's tokenisation.
@@ -770,7 +781,10 @@ pg_search(const struct manpaths *ps, con
 	 * The resp_search() function is called with the results.
 	 */
 
-	if (NULL != (expr = exprcomp(sz, cp, &tt)))
+	expr = whatis ? termcomp(sz, cp, &tt) :
+		        exprcomp(sz, cp, &tt);
+
+	if (NULL != expr)
 		rc = apropos_search
 			(ps->sz, ps->paths, &opt,
 			 expr, tt, (void *)req, resp_search);
Index: Makefile
===================================================================
RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/mdocml/Makefile,v
retrieving revision 1.387
retrieving revision 1.388
diff -LMakefile -LMakefile -u -p -r1.387 -r1.388
--- Makefile
+++ Makefile
@@ -453,6 +453,7 @@ installcgi: all
 	mkdir -p $(DESTDIR)$(HTDOCDIR)
 	$(INSTALL_PROGRAM) man.cgi $(DESTDIR)$(CGIBINDIR)
 	$(INSTALL_DATA) example.style.css $(DESTDIR)$(HTDOCDIR)/man.css
+	$(INSTALL_DATA) man.cgi.css $(DESTDIR)$(HTDOCDIR)
 
 installwww: www
 	mkdir -p $(PREFIX)/snapshots
--
 To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-12-07 13:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-07 13:00 mdocml: Have a whatis/apropos mode, with the default (hitting enter kristaps

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).