htdig: PATCH: combine header & footer in one file


Gilles Detillieux (grdetil@scrc.umanitoba.ca)
Thu, 7 Jan 1999 16:00:40 -0600 (CST)


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 <grdetil@scrc.umanitoba.ca>

        * 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 @@
     <hr>
     <dl>
       <dt>
+ <strong><a name="search_results_prototype">
+ search_results_prototype</a></strong>
+ </dt>
+ <dd>
+ <dl>
+ <dt>
+ <em>type:</em>
+ </dt>
+ <dd>
+ string
+ </dd>
+ <dt>
+ <em>used by:</em>
+ </dt>
+ <dd>
+ <a href="htsearch.html" target="_top">htsearch</a>
+ </dd>
+ <dt>
+ <em>default:</em>
+ </dt>
+ <dd>
+ <em>&lt;empty&gt;</em>
+ </dd>
+ <dt>
+ <em>description:</em>
+ </dt>
+ <dd>
+ This specifies a filename to be output at the start and
+ end of search results. This file replaces the <a href=
+ "#search_results_header">search_results_header</a> and
+ <a href="#search_results_footer">search_results_footer</a>
+ files, with the contents of both in one file, and uses the
+ pseudo-variable <strong>$(HTSEARCH_RESULTS)</strong> 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 <a href=
+ "#search_results_header">search_results_header</a> and
+ <a href="#search_results_footer">search_results_footer</a>
+ files.<br>
+ Note that this file will <strong>NOT</strong> be output
+ if no matches were found. In this case the <a href=
+ "#nothing_found_file">nothing_found_file</a> attribute
+ is used instead.
+ </dd>
+ <dt>
+ <em>example:</em>
+ </dt>
+ <dd>
+ search_results_prototype:
+ ${common_dir}/prototype.html
+ </dd>
+ </dl>
+ </dd>
+ </dl>
+ <hr>
+ <dl>
+ <dt>
         <strong><a name="server_aliases">server_aliases</a></strong>
       </dt>
       <dd>
--- 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</a><br>
      <img src="dot.gif" alt="*"> <a target="body" href=
+ "attrs.html#search_results_prototype">
+ search_results_prototype</a><br>
+ <img src="dot.gif" alt="*"> <a target="body" href=
     "attrs.html#server_aliases">server_aliases</a><br>
      <img src="dot.gif" alt="*"> <a target="body" href=
     "attrs.html#server_max_docs">server_max_docs</a><br>
--- 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</a><br>
      <img src="dot.gif" alt="*"> <a target="body" href=
+ "attrs.html#search_results_prototype">
+ search_results_prototype</a><br>
+ <img src="dot.gif" alt="*"> <a target="body" href=
     "attrs.html#star_blank">star_blank</a><br>
      <img src="dot.gif" alt="*"> <a target="body" href=
     "attrs.html#star_image">star_image</a><br>
--- 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 @@
+<html><head><title>Search results for '$(WORDS)'</title></head>
+<body bgcolor="#eef7ff">
+<h2><img src="@IMAGEDIR@/htdig.gif">
+Search results for '$(LOGICAL_WORDS)'</h2>
+<hr noshade size=4>
+<form method="get" action="$(CGI)">
+<font size=-1>
+<input type=hidden name=config value=$(CONFIG)>
+<input type=hidden name=restrict value="$(RESTRICT)">
+<input type=hidden name=exclude value="$(EXCLUDE)">
+Match: $(METHOD)
+Format: $(FORMAT)
+<br>
+Refine search:
+<input type="text" size="30" name="words" value="$(WORDS)">
+<input type="submit" value="Search">
+</select>
+</font>
+</form>
+<hr noshade size=1>
+<b>Documents $(FIRSTDISPLAYED) - $(LASTDISPLAYED) of $(MATCHES) matches.
+More <img src="@IMAGEDIR@/star.gif" alt="*">'s indicate a better match.
+</b>
+<hr noshade size=1>
+$(HTSEARCH_RESULTS)
+$(PAGEHEADER)
+$(PREVPAGE) $(PAGELIST) $(NEXTPAGE)
+<hr noshade size=4>
+<a href="http://www.htdig.org">
+<img src="@IMAGEDIR@/htdig.gif" border=0>ht://Dig $(VERSION)</a>
+</body></html>

-- 
Gilles R. Detillieux              E-mail: <grdetil@scrc.umanitoba.ca>
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.



This archive was generated by hypermail 2.0b3 on Sun Jan 10 1999 - 16:36:30 PST