namazu-users-en
[Top] [All Lists]

Support for {idxname} in namazu.cgi

2000-10-25 10:57:37

I recently setup namazu for searching MHonArc mail archives at my
current place of employment.  One thing I wish the namazu.cgi program
would support in its templates is "{idxname}": expands to the name of
the index.

My goal was to preserve the context of a given archive for the
search pages (even when they selected the help link) so the user
does not have to select an archive via select list each time.

A work-around was to use JavaScript to get what I want.  IMO, I
do not like this since the client must have javascript support and
have it enabled.  To give you an example of what was done, here is
part of my NMZ.head file:

    ...
    <script>
    function getArgs() {
      var args = new Object();
      if (location.search.length <= 1) return args;
      var pairs = location.search.substring(1).split("&");
      for (var i=0; i < pairs.length; ++i) {
        var pos = pairs[i].indexOf('=');
        if (pos < 0) {
          args[pairs[i]] = "";
          continue;
        }
        args[pairs[i].substring(0,pos)] = unescape(pairs[i].substring(pos+1));
      }
      return args;
    }
    var queryArgs = getArgs();
    var idxname = queryArgs["idxname"];
    </script>
    </head>
    <body lang="en">
    <script>
    document.writeln("<h1><a href=\"/archives/" + idxname +"/\">" +
                     idxname + " archive</a> search</h1>");
    </script>
    <form method="get" action="{cgi}">
    <p><strong>Search String:</strong> 
    <input type="text" name="query" size="40">
    <input type="submit" name="submit" value="Search!">
    <script>
    document.writeln("<input type=\"hidden\" name=\"idxname\" value=\"" + 
                     idxname + "\">");
    document.writeln("<a href=\"{cgi}?idxname=" + idxname +
                     "\">[How to search]</a><br>");
    </script>
    ...

In sum, the page extracts the idxname from the query string itself and
then uses document.writeln() calls to output the HTML that I want to
include the idxname in.  The nice thing about the final result is that
when the results page is displayed or users goto the "How to search"
link, they automatically stay within the context of the mail archive
they were reading.

The use of javascript can be avoided if {idxname} was supported by the
CGI program directly.

--ewh

----
             Earl Hood              | University of California: Irvine
      ehood(_at_)medusa(_dot_)acs(_dot_)uci(_dot_)edu      |      Electronic 
Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME


<Prev in Thread] Current Thread [Next in Thread>