# $Id: modern.cf,v 1.1 2002/07/05 by Harald Weinreich # # Definitions for '{nph-}search.cgi' configuration. # # A hash (#) in the first column denotes a comment and is not processed # even inside a definition. Hashes not in the first column are left as-is. # # Variable substitution occurs on these definitions. If you want # a dollar-sign ($) to occur in the output, escape it with backslash (\). # Other metacharacters (quotes, asterisks, etc) probably don't need to be # escaped. Printf-like special characters are allowed: \n \t \r etc. # # The ending newline is chopped off from each definiton. So # # # abcxyz # # # becomes "abcxyz". You may have blank lines in between the beginning # and ending tags, or use the newline character \n. # # # CGI defaults. # # In this section you can give default values for any attribute that would # normally be passed in from the CGI query form. The following attributes # are currently available: # # brokerqueryconfig : Name of a broker specific configuration file # lifetime : Maximum lifetime of a query (see also section) # caseflag : Whether the query is casesensitive ["on" or "off"] # wordflag : Match on word boundaries ["on" or "off"] # opaqflag : Show matched lines ["on" or "off"] # descflag : Return object description ["on" or "off"] # noregexflag : Don't do regular expressions ["on" or "off"] # maxresultflag : Maximum number of results to return # maxobjflag : Maximum number of objects to return # maxlineflag : Maximum number of matched lines # errors : Number of spelling errors # broker : Name of broker # host : Name of broker host # attributes : Space sperated list of attributes to return # sort : Sort options ["by-rank"] # These defaults mimic the values on the provided query-glimpse-modern.html form. caseflag : on wordflag : on errorflag : 0 opaqueflag : on descflag : on maxobjflag : 500 maxlineflag : 30 maxresultflag : 3000 perpageflag : 25 sort : by-rank # 'GLOBAL' VARIABLES: are defined globally within the {nph-}search.cgi program, # but not necessarily set at all times. # # $query the user query string # $html_query the user query string, special HTML characters escaped # $bquery the query string sent to the broker # $host the broker hostname # $port the broker port # $hp_url the URL of the broker query (home) page # $maxresult the maximum number of matched lines the broker will return # $nobjects a running count of the number of objects returned # $nopaquelines a running count of the number of opaque (matched) lines # # definitions here can be output in other definitions. Each definition # here is placed into the %CFG associative array. For example, # to print out the Timeout defined below, write $CFG{'Timeout'}. # # The URL to the Harvest Project home page. # http://harvest.sourceforge.net/ # The amount of time to wait for the broker results. # Can use aritmetic # here also, eg: 5*60 # # We use a conservative 5 minutes here. # 300 # InitFunction can be some perl code which gets eval'd before they # query is sent. Use this for any special hackings. # $cs_urlX = $csumflag ? 'Y' : undef; # The MIME content type of the query results. Should be "text/html" # if we are going to return HTML tags. # text/html ############################################################################## # RESULT SECTION # # The output of '{nph-}search.cgi' consists of the following tags: # # ResultHeader # CreateNavBars # ResultSetBegin # ( Errors from 'broker' ) # foreach object { # PrintObject # } # ResultSetEnd # EndBrokerResults # ( TruncateWarning ) # ResultTrailer # # ############################################################################## # First output for the HTML containing the results. Should probably include # tag and the user query. # <ResultHeader> <HEAD> <TITLE>Search Results for: $html_query

Search Results for: $html_query


# Final HTML section for the output. Should probably contain a pointer # to the broker home-page ($hp_url) and a pointer to the Harvest # home page. # #---------------------------------------------------------------------- # JMM - 20011020 # We close the HTML page #---------------------------------------------------------------------,
$rNavigationBar Powered by harvest
#---------------------------------------------------------------------'
#---------------------------------------------------------------------- # JMM 20011020 # Calculations to obtain $rResultsBar and $rNavigationBar # We use them in #---------------------------------------------------------------------, if ($rTotHtmlFiles > 0) { $rCurrentPage = (!$current_page) ? 1 : $current_page; $rPrevPage = ""; if ($rCurrentPage > 1) { $rPrevPage = $rCurrentPage - 1 ; $rPrevPage = "\n\n<< Prev ·"; } $rNextPage = ""; if ($rCurrentPage < $rTotHtmlFiles) { $rNextPage = $rCurrentPage + 1; $rNextPage = "\n· Next >>"; } $rIniP = $rCurrentPage - $rNavPart; $rIniP = 1 if ($rIniP < 1); $rEndP = $rCurrentPage + $rNavPart; $rEndP = $rTotHtmlFiles if ($rEndP >= $rTotHtmlFiles); $rPag10s = ""; for ($rI = $rIniP; $rI < $rCurrentPage; $rI++) { $rPag10s .= "\n$rI "; } $rPag10s .= "\n[$rCurrentPage] "; for ($rI = $rCurrentPage+1; $rI <= $rEndP; $rI++) { $rPag10s .= "\n$rI "; } $rResultsBar = "
$totnumber objects - Page: $rCurrentPage/$rTotHtmlFiles", $rResultsBar .= " - New Search"; $rNavigationBar = "\n\n"; $rNavigationBar .= "$rPrevPage $rPag10s $rNextPage" if ($rTotHtmlFiles > 1); } else { $rResultsBar = " - New Search"; }
#---------------------------------------------------------------------' # Output just before beginning the loop over objects returned by the # broker. # #---------------------------------------------------------------------- # JMM - 20011020 # We put a navigation bar #---------------------------------------------------------------------, #
\n

Search for: $html_query $rResultsBar
$rNavigationBar


#---------------------------------------------------------------------' # output just after ending the loop over objects returned by the broker #
\n # EndBrokerResults is printed when the broker results end normally. # $msg
\n
# FailBrokerResults is printed when the broker results end in error # \n$msg
\n
# PER-OBJECT DEFINITIONS # # NOTES: In order for us to just use "$opaque" and have it print all the # matched lines properly, we must be in
 mode.
#
#        Rather than just putting $cs_url in a HREF, we break it up and
#        stick the components around the 'DisplayObject' CGI program
#        which formats the SOIF into nice-looking HTML.
#
# VARIABLES:
#
#    $url	Object url: http://www.cia.gov:3333/Spies/KGB/secret.html
#    $A		URL Access: http
#    $H		URL Host  : www.cia.gov:3333
#    $P		URL Path  : /Spies/KGB/secret.html
#    $D		URL Dir   : /Spies/KGB/
#    $F		URL File  : secret.html
#    $cs_url	URL to the SOIF object in the broker databse
#    $cs_[ahp]	elements of $cs_url as above with $url
#    $desc	Description attribute of the matched object
#    $opaque	A matched line (or all matched lines in obj-at-a-time mode)
#    $usermsg	A user message
#    $attributes Requested attributes


$objectnum $description $objectType  $objectSize #---------------------------------------------------------------------- # JMM - 20011020 # We print "+info" to access detailed metadata and the balls # identifying the weight #---------------------------------------------------------------------, +info
$rWeightBalls #---------------------------------------------------------------------'
$attributes
matches: $opaque...
indexing data
$url

# This definition is eval'd for each opaque (matched) line retruned by # the broker. It is intended to be used to remove SOIF attributes # and the 'Matched line' string from the output. See the perl(1) manual # page or book for information on building Perl regular expressions. # # Add this to have URLs in mached lines be links # # s/([a-z]*:\/\/\S*)/\1<\/A>/; # #1. Completely remove lines with @FILE s/^(.*)\@FILE(.*)$/ /; #2. Remove "Matched line #" s/^(.*)\# (.*)$/$2/; #3. Remove "{12}:" etc. s/^(.*)\}:(.*)$/$2/; #4. Remove leading and trailing whitespaces s/^\s+//; s/\s+$//; #5. Limit length to 10 words per matched line. s/^(((\s*)(\S*)){10}).*$/$1/; #6. show 4 matched lines, set maximum length and avoid double matched lines. if ($opaquePerObjectCount>4 || length($_)>120 || $lastOpaqueObject eq $_ ) { $_ = ""; #no output } else { $lastOpaqueObject=$_; $opaquePerObjectCount++; s/(.*)/... $1/; #OK, add dots. } #highlight search words. @worte=split(/ +/,$query); for ($i=0; $i<=$#worte; $i++) { s/(\b$worte[$i]\b)/$1<\/font>/ig if !($worte[$i] =~ /AND|OR|NOT|\(|\)/); } # PerObjectFunction is eval'd before every object is printed out. # #---------------------------------------------------------------------- # JMM - 20012020 # We create the HTML code to print the balls #---------------------------------------------------------------------, $rWeightBalls = ""; if ($rGreaterWeight > 1) { $nWeight = int($rWeight * 5 /$rGreaterWeight); $rWeightBalls = "
" if ($nWeight>0); for ($idxWeight=1; $idxWeight <= $nWeight; $idxWeight++) { $rWeightBalls .= "\"*\" "; } $rWeightBalls = ''.$rWeightBalls.''; } #---------------------------------------------------------------------' $opaquePerObjectCount = 1; $objectType=""; $objectSize=""; $lastOpaqueObject = ""; $description = "File:  $F"; $description = $desc if (length($desc) > 5); #highlight search words. @worte=split(/ +/,$query); for ($i=0; $i<=$#worte; $i++) { $description =~ s/(\b$worte[$i]\b)/$1<\/b>/ig if !($worte[$i] =~ /AND|OR|NOT|\(|\)/); }
# PerAttributeFunction is eval'd before the Attributes are printed out. # Remove all empty lines $val =~ s/^(\s*)//mg; # insert commas to separate headings $val =~ s/\n(.)/, $1/mg; # If more than 120 Characters, display only the first 120 plus "..." $val =~ s/^((.|\n){120})(.|\n)*/$1.../; # Now prepare the object's type and size to display at the description. if ($att eq "type") { $objectType = "[".$val."]" if !($val =~ /HTML|HTTP-Query/); $att=""; } elsif ($att eq "file-size") { $val = int($val/1024); $objectSize = $val." KByte" if ($val > 150); # more than 150 KByte $val = int($val/10.24); $objectSize = ($val/100)." MByte" if ($val > 100); # more than one meg $att=""; } else { #highlight search words. @worte=split(/ +/,$query); for ($i=0; $i<=$#worte; $i++) { $val =~ s/(\b$worte[$i]\b)/$1<\/font>/ig if !($worte[$i] =~ /AND|OR|NOT|\(|\)/); } } # Format Requested Attributes. Before this is eval'd, $att and $val # should be set. # $att: $val
# ====================================================================== # ERROR, STATUS and WARNING functions # ====================================================================== # The message printed to the browser and logged to the HTTP server log # when the processes is killed. If the Timeout time is reached, the # process dies from SIGALRM. The short name of the offending signal # is placed in $sig. # Killed by SIG$sig...\n # How to format the object number. Use a printf format specification # to left/right justify, or whatever. Do not include quotes around # the format string. # %2d. # A warning message printed only when the broker might have truncated # the result set. Only printed if the number of matched lines equals # the 'maxresultflag' value of the query.html form. #

WARNING: The result set was truncated at $nopaquelines matched lines.

\n # A warning message printed only when the broker returned 0 results. #

Your query either did not match any information in this Broker, or you may have specified a query that is not supported by this Broker's search subsystem. Please refer to the help on formulating queries for further assistance.

\n # Error Message returned if there is no query string sent. # No query information to decode. Please enter a search word.\n # Message returned if the broker sends back a # 111 - Broker is too heavily loaded # reply. #

Sorry, the search broker at $host, port $port is currently too heavily loaded to process your request.

Please try again later.

# Message returned if the broker sends back a # 111 - PARSE ERROR # reply. #

Sorry, your query does not have the proper syntax:

    $html_query

Please refer to the help in formulating queries for details on the proper syntax.

Common syntax mistakes include:

  • Not using quotes around phrases or regular expressions.
    For example, the phrase: resource discovery should be "resource discovery". The regular expression: res.* disc.* should be "res.* disc.*". Note that a single dot (``.'') in a keyword needs quotes (e.g. "3.0").
  • Missing punctuation.
    Structured queries need a colon and optional parentheses. For example, Type:PostScript or, (Type : PostScript)
\n