TitleSrch - a CGI script to search for HTML titles or do grep searches
This package consists of two perl scripts and two customizable HTML
docs (a coversheet and a response). The first script, mklist,
produces a file consisting of title/URL pairs (or for grep searches
title/URL/filepath). This file can be edited or entirely built by
hand if you desire. The CGI script, srch.cgi, searches the title
field of all lines in this file and returns a response HTML document
in which it inserts an unordered list of all URLs matching the query
when it encounters a line containing only the special token $MATCHES.
Also the token $QUERY in the HTML response is replaced by the search
term. If the list file has three fields per line, the last being the
path to the file, then a grep search of the file is done instead of
looking for matches only in the title.
Here are the steps to get srch.cgi running.
1. Edit the mklist script entering your hostname and data root
directory. Then produce a list file with this script. This is a
file each line of which looks like
TitleURL\n (for title searches)
TitleURLpath2file\n (for grep searches)
By default mklist produces (on standard output) a list file for title
searches in the directory (relative to the data root) which is its
first argument. If it is given the -r option it will recursively do
all subdirectories of that directory. If a directory is not given
the root is used. To find the title it checks the first 5 lines of
every text file looking for or . The beginning and
ending title tags should be on the same line.
Examples: "mklist > mylist" -> list for all files in root dir
"mklist -r > mylist -> list for all files in root and its subdirs
"mklist -r /dir/dir2 > mylist" -> list for all files in
root/dir/dir2 and its subdirectories
If you use the "-g" option it produces the three field file which indicates
to srch.cgi to do a complete grep search of the files rather than just
search the titles.
2. Install the "mylist" file you made in step 1 in some directory on
your server along with the mylist.cover and mylist.response files.
You will probably want to edit these two files to customize your
information. There is nothing magic about the name "mylist", but if
the listfile is named "foo" the cover and response files must be named
"foo.cover" and "foo.response" and must be in the same directory.
3. Install srch.cgi in your cgi-bin. The URL pointing to this script
should then be
where "/path2/mylist" is whatever your server will translate to the
correct path to the mylist file and place in the CGI environment
John Franks Dept of Math. Northwestern University