#!/usr/bin/perl $swish = '/usr/bin/swish-e'; $index = '/home/default/htdocs/column/data/column.index'; $basepath = '/home/default/htdocs/column/'; $thisscript = 'index.cgi'; $maxnum = '100'; $start = '1'; $next = $start + $maxnum; require ('lib.pl'); &get_data; if ($FORM{'start'} =~ /\w/) { $start = $FORM{'start'}; } $startplus = $start; if ($FORM{'fetch'} =~ /\w/) { &fetch_record; } if ($FORM{'parse'} =~ /\w/) { &print_preface; &print_data_summary; &print_form; print "
\n"; $temp = `xsltproc peer.xslt $FORM{'parse'}`; #foreach (@temp) { print $temp; #} &print_footer; exit; } if ($FORM{'query'} =~ /\w/) { if ($FORM{'field'} =~ /full/) { $query = "text=(".$FORM{'query'}.")"; } else { if ($FORM{'field'} =~ /title|issn|document_type/) { $query = $FORM{'field'}."=".$FORM{'query'}; } else { $query = "title=(".$FORM{'query'}.") or date=(".$FORM{'query'}.") or description=(".$FORM{'query'}.") "; # $query = $FORM{'query'}; } } } else { &print_preface; &print_data_summary; &print_form; &print_footer; exit; } &print_preface; if ($query =~ /\w/) { open(SWISH, "$swish -w \"$query\" -m $maxnum -b $start -x \"::::<description>::<date>\n\" -f $index |"); #$testtwo = `$swish -w $query -x "<swishdocpath>::<title>::<creator>\n" -f $index`; while (<SWISH>) { # First, check to see if search produced an error chop; if ($_ eq "err: no results") {&search_error("There were no items that matched your search request: $query. Please try again.");} if ($_ eq "err: could not open index file") {&search_error("Could not open the index file $index.");} if ($_ eq "err: no search words specified") {&search_error("Please enter at least one search word.");} if ($_ eq "err: a word is too common") {&search_error("One of your search terms is too common, please try again.");} if ($_ =~ /^\#\sNumber/) { ($trash, $numhits) = split(/\: /, $_); } if ($_ !~ /^#|^\./) { $count++; $path = $title = $description = $date = ''; # # IF WANT TO DISPLAY MORE THAN THE FIELDS BELOW, MUST CHANGE THE # harvest.conf FILE AND REINDEX TO ADD THE REQUIRED PROPERTIES # ($path, $title, $description, $date) = split(/::/, $_); # ($first, $second, $third) = split(/\//, $path); # $pathtwo = $first."/".$second; # $source = $names{$pathtwo}; ($shortpath, $stuff) = split(/\//, $path); ($file, $stuff) = split(/\./, $stuff); $fetchfile = "data/".$file.".txt"; push(@results, "<li value=\"$startplus\"><span class=\"title\"><a href=\"?fetch=$path\">$title</a></span> — $date — $description</span></li>\n"); ++$startplus; } } &print_results; print "</ol>\n\n"; } else { &print_form; } &print_footer; sub print_form { print <<END; <form method="get" action="$thisscript"> Search <select name="field"> <option value="full">Full Text</option> <option value="">Any Field</option> <option value="title">Title</option> <option value="date">Date</option> <option value="description">Description</option> </select> for <input type="text" name="query" size="20" /> <input type="submit" value="Go!" /> </form> END } sub print_preface { print "Content-type: text/html\n\n"; print <<END; <html> <head> <title>Library Journal "Digital Libraries" Columns 1997-2007, Roy Tennant
roytennant.com :: Digital Libraries Columns

 

Library Journal "Digital Libraries" Columns 1997-2007, Roy Tennant

Please note: these columns are an archive of my Library Journal column from 1997-2007. They have not been altered in content, so please keep in mind some of this content will be out of date.

END } sub print_results { $segments = $numhits/$maxnum; print "

Your search for $FORM{'query'} found $numhits items. You may also search again.

\n
    \n"; $starthits = 1; $hitscount = 1; if ($numhits > $maxnum) { while ($hitscount <= $segments) { print "[ $starthits - $next ] - \n"; ++$hitscount; $starthits = $next; $next = $next + $maxnum; } print "[ $starthits - $numhits ]\n
    \n"; } foreach $hit (@results) { print $hit; } } sub print_footer { print < END } sub search_error { $error_message = $_[0]; print "

    $error_message

    \n"; &print_form; &print_footer; exit; } sub fetch_record { $recordpath = $basepath.$FORM{'fetch'}; &print_preface; @temp = `xsltproc column.xslt $recordpath`; foreach(@temp) { print; } &print_footer; exit; } sub print_data_summary { $line = `grep "files indexed" report`; ($something, $nothing) = split(/\s/, $line); print <You are searching almost 100 "Digital Libraries" columns written by Roy Tennant for Library Journal from November 1997 to November 2007. You may also browse them all, although not yet in date order.

    END }