From grdetil@scrc.umanitoba.ca Thu Jan 7 14:15:32 1999 Date: Thu, 7 Jan 1999 16:00:40 -0600 (CST) From: Gilles Detillieux To: htdig@sdsu.edu Cc: Gilles Detillieux Subject: htdig: PATCH: combine header & footer in one file Hi. I was following the discussion from a day or two ago about why the header and footer files were separate. While I understand the reasoning, I thought a combined file would be easy enough to implement, and really handy to have. So, after a bit of hacking, I came up with this patch. You'll first need to install the "hdrbug" patch I just posted earlier this afternoon, or the first section of the patch to Display.cc below won't work (I don't think "patch" will recognize it). The feature isn't enabled by default. To use it, you'll need to manually install installdir/prototype.html in your common directory, fix up the @IMAGEDIR@ stuff, and add this line to htdig.conf: search_results_prototype: ${common_dir}/prototype.html Please let me know if there are any problems with this. I didn't fix Makefile.in to automatically install prototype.html, but this may be worth doing if the patch is included in the next release. Thu Jan 7 15:57:10 1999 Gilles Detillieux * added search_results_prototype attribute to htsearch --- htdig-3.1.0b4/htcommon/defaults.cc.proto Thu Jan 7 13:08:46 1999 +++ htdig-3.1.0b4/htcommon/defaults.cc Thu Jan 7 14:49:57 1999 @@ -178,6 +178,7 @@ {"search_algorithm", "exact:1"}, {"search_results_footer", "${common_dir}/footer.html"}, {"search_results_header", "${common_dir}/header.html"}, + {"search_results_prototype", ""}, {"server_aliases", ""}, {"server_wait_time", "0"}, {"server_max_docs", "-1"}, --- htdig-3.1.0b4/htdoc/attrs.html.proto Wed Jan 6 14:22:04 1999 +++ htdig-3.1.0b4/htdoc/attrs.html Thu Jan 7 15:52:45 1999 @@ -3771,6 +3771,66 @@
+ + search_results_prototype +
+
+
+
+ type: +
+
+ string +
+
+ used by: +
+
+ htsearch +
+
+ default: +
+
+ <empty> +
+
+ description: +
+
+ This specifies a filename to be output at the start and + end of search results. This file replaces the search_results_header and + search_results_footer + files, with the contents of both in one file, and uses the + pseudo-variable $(HTSEARCH_RESULTS) as a + separator for the header and footer sections. + If the filename is not specified, the file is unreadable, + or the pseudo-variable above is not found, htsearch reverts + to the separate header and footer files instead. + While outputting the prototype, + some variables will be expanded, just as for the search_results_header and + search_results_footer + files.
+ Note that this file will NOT be output + if no matches were found. In this case the nothing_found_file attribute + is used instead. +
+
+ example: +
+
+ search_results_prototype: + ${common_dir}/prototype.html +
+
+
+
+
+
+
server_aliases
--- htdig-3.1.0b4/htdoc/cf_byname.html.proto Wed Jan 6 14:36:47 1999 +++ htdig-3.1.0b4/htdoc/cf_byname.html Thu Jan 7 15:15:20 1999 @@ -213,6 +213,9 @@ "attrs.html#search_results_header"> search_results_header
* + search_results_prototype
+ * server_aliases
* server_max_docs
--- htdig-3.1.0b4/htdoc/cf_byprog.html.proto Wed Jan 6 14:44:21 1999 +++ htdig-3.1.0b4/htdoc/cf_byprog.html Thu Jan 7 15:16:09 1999 @@ -243,6 +243,9 @@ "attrs.html#search_results_header"> search_results_header
* + search_results_prototype
+ * star_blank
* star_image
--- htdig-3.1.0b4/htsearch/Display.cc.proto Thu Jan 7 12:30:52 1999 +++ htdig-3.1.0b4/htsearch/Display.cc Thu Jan 7 14:40:18 1999 @@ -196,7 +196,38 @@ maxScore = match->getScore(); cout << "Content-type: text/html\r\n\r\n"; - displayHeader(); + String proto = config["search_results_prototype"]; + String *prototype = 0; + char *header = 0, *footer = 0; + if (proto.length()) + { + prototype = readFile(proto.get()); + if (prototype && prototype->length()) + { + char proto_sepr[] = "HTSEARCH_RESULTS"; + char *p = strstr(prototype->get(), proto_sepr); + if (p) + { + if (p[-1] == '$') + { + footer = p + strlen(proto_sepr); + header = prototype->get(); + p[-1] = '\0'; + } + else if (p[-1] == '(' && p[-2] == '$' && + p[strlen(proto_sepr)] == ')') + { + footer = p + strlen(proto_sepr) + 1; + header = prototype->get(); + p[-2] = '\0'; + } + } + } + } + if (header) + expandVariables(header); + else + displayHeader(); // // Display the window of matches requested. @@ -228,8 +259,13 @@ { expandVariables(currentTemplate->getEndTemplate()); } - displayFooter(); + if (footer) + expandVariables(footer); + else + displayFooter(); + if (prototype) + delete prototype; delete matches; } --- htdig-3.1.0b4/installdir/prototype.html.proto Thu Jan 7 14:53:06 1999 +++ htdig-3.1.0b4/installdir/prototype.html Thu Jan 7 14:52:51 1999 @@ -0,0 +1,31 @@ +Search results for '$(WORDS)' + +

+Search results for '$(LOGICAL_WORDS)'

+
+
+ + + + +Match: $(METHOD) +Format: $(FORMAT) +
+Refine search: + + + +
+
+
+Documents $(FIRSTDISPLAYED) - $(LASTDISPLAYED) of $(MATCHES) matches. +More *'s indicate a better match. + +
+$(HTSEARCH_RESULTS) +$(PAGEHEADER) +$(PREVPAGE) $(PAGELIST) $(NEXTPAGE) +
+ +ht://Dig $(VERSION) + -- Gilles R. Detillieux E-mail: Spinal Cord Research Centre WWW: http://www.scrc.umanitoba.ca/~grdetil Dept. Physiology, U. of Manitoba Phone: (204)789-3766 Winnipeg, MB R3E 3J7 (Canada) Fax: (204)789-3930 ---------------------------------------------------------------------- To unsubscribe from the htdig mailing list, send a message to htdig-request@sdsu.edu containing the single word "unsubscribe" in the body of the message.