package OutputTool;
use strict;
1;
# This package provides functions to output search results from Webglimpse
# Any replacement Output object must implement all of the following functions
# and provide the fields defined in _initialize
sub new {
my $class = shift;
my $self = {};
bless $self, $class;
$self->_initialize();
return $self;
}
# Set any static fields we will need later
sub _initialize {
my $self = shift;
$self->{end_file_marker} = "\n";
}
sub makeInitialOutput {
my $self = shift;
my($pquery, $title, $QS_file, $QS_lines) = @_;
my($initial_output) = '';
$initial_output .= "
Result for query \"$pquery\"\n";
$initial_output .= "\n";
$initial_output .= "";
$initial_output .= "Results for query \"$pquery\"
\n";
$initial_output .= "on: $title
\n";
if ($QS_file) {
$initial_output .= "Search on neighborhood of $title\n";
$initial_output .= "\n";
} else {
$initial_output .= "Search on entire archive\n";
$initial_output .= "
\n";
}
if($QS_lines){
$initial_output .= "File name (modification date), and list of matched lines (preceded by line numbers)
\n";
}else{
$initial_output .= "File name (modification date), and list of matched lines
\n";
}
return $initial_output;
}
sub limitMaxLines {
my $self = shift;
my($maxlines) = @_;
return "
Limit of $maxlines matched lines per file exceeded...\n";
}
sub limitMaxFiles {
my $self = shift;
my($maxfiles) = @_;
print $self->{end_file_marker};
print "Limit of $maxfiles files exceeded. Check the search options.
\n";
}
sub makeEndHits {
my $self = shift;
return "
";
}
sub makeLinkOutput {
my $self = shift;
my($link, $title, $date) = @_;
my $retstring = "
";
$retstring .= $title.", $date
\n";
return $retstring;
}
sub makeStartFileDesc {
my $self = shift;
my($metadesc) = @_;
my $retstring;
if ($metadesc eq '') {
$retstring = "\n\n";
} else {
$retstring = " $metadesc
\n
\n";
}
return $retstring;
}
sub makeJumpToLine {
my $self = shift;
my($linkto, $line, $string) = @_;
my $retstring = "- \n" .
"line $line:$string\n";
return $retstring;
}
sub makeLine {
my $self = shift;
my($string) = @_;
return "
- $string\n";
}
sub makeFinalOutput {
my $self = shift;
my($QS_query, $lcount, $fcount) = @_;
my $retstring = "
" ;
$retstring .= "Summary for query \"".$QS_query."\":
\n" ;
$retstring .= "WebGlimpse\n";
$retstring .= "search found ".$lcount." matches in ".$fcount." files
\n" ;
$retstring .= "(Some matches may be to HTML tags which may not be shown.)\n";
$retstring .= "\n";
return $retstring;
}