| 1 | #!/usr/local/bin/perl -w | ||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||
| 3 | # AutoSearch | ||||||||||||||||||||||||||||||||
| 4 | # Copyright (c) 1996-1997 University of Southern California. | ||||||||||||||||||||||||||||||||
| 5 | # All rights reserved. | ||||||||||||||||||||||||||||||||
| 6 | # $Id: AutoSearch,v 1.2 2010-12-02 23:46:30 Martin Exp $ | ||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||
| 8 | # Complete copyright notice follows below. | ||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||
| 12 | AutoSearch -- a web-search tracking application | ||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | AutoSearch [--stats] [--verbose] -n "Query Name" -s "query string" --engine engine [--mail you@where.com] [--options "opt=val"]... [--filter "filter"] [--host host] [--port port] [--userid bbunny --password c4rr0t5] [--ignore_channels KABC,KCBS,KNBC] qid | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | AutoSearch --VERSION | ||||||||||||||||||||||||||||||||
| 19 | AutoSearch --help | ||||||||||||||||||||||||||||||||
| 20 | AutoSearch --man | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 1 | ▶ | use Data::Dumper; # for debugging | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | use Date::Manip; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 26 | 1 | ▶ | use File::Copy; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 27 | 1 | ▶ | use Getopt::Long qw( :config no_ignore_case ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 28 | # use LWP::Debug qw(+ ); # -conns); | ||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 30 | 1 | ▶ | use POSIX qw(strftime); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | use WWW::Search; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | use vars qw( $VERSION ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 36 | 1 | $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%03d" x $#r, @r }; | |||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||
| 38 | 1 | ▶ | use constant DEBUG_EMAIL => 0; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||
| 40 | 1 | my $TESTONLY = 0; | |||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | sub print_version | ||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
print_version: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 44 | 1 | print STDERR "$0 version $VERSION; WWW::Search version $WWW::Search::VERSION\n"; | |||||||||||||||||||||||||||||||
| 45 | } # print_version | ||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||
| 47 | 1 | my (%opts,@query_list,$query_name,$query_string,$search_engine,$query_options,$url_filter); | |||||||||||||||||||||||||||||||
| 48 | # Default options: | ||||||||||||||||||||||||||||||||
| 49 | 1 | $opts{'m'} = ''; | |||||||||||||||||||||||||||||||
| 50 | 1 | $opts{'cleanup'} = 0; | |||||||||||||||||||||||||||||||
| 51 | 1 | $opts{'cmdline'} = 0; | |||||||||||||||||||||||||||||||
| 52 | 1 | $opts{'emailfrom'} = ''; | |||||||||||||||||||||||||||||||
| 53 | 1 | $opts{'v'} = 0; | |||||||||||||||||||||||||||||||
| 54 | 1 | $opts{'help'} = 0; | |||||||||||||||||||||||||||||||
| 55 | 1 | $opts{'man'} = 0; | |||||||||||||||||||||||||||||||
| 56 | 1 | $opts{'stats'} = 0; | |||||||||||||||||||||||||||||||
| 57 | 1 | $opts{'debug'} = 0; | |||||||||||||||||||||||||||||||
| 58 | 1 | $opts{'listnewurls'} = 0; | |||||||||||||||||||||||||||||||
| 59 | 1 | $opts{'ignore_channels'} = (); | |||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | &GetOptions(\%opts, qw(n|qn|queryname=s s|qs|querystring=s e|engine=s m|mail=s emailfrom=s host=s p|port=s o|options=s@ f|uf|urlfilter=s listnewurls stats userid=s password=s ignore_channels=s@ cleanup=i cmdline v|verbose help man V|VERSION debug), | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 61 | 'http_proxy=s', | ||||||||||||||||||||||||||||||||
| 62 | 'http_proxy_user=s', | ||||||||||||||||||||||||||||||||
| 63 | 'http_proxy_pwd=s', | ||||||||||||||||||||||||||||||||
| 64 | ) or pod2usage(2); | ||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | if ($opts{'V'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 66 | { | ||||||||||||||||||||||||||||||||
| 67 | 1 | &print_version(); | |||||||||||||||||||||||||||||||
| 68 | 1 | exit 0; | |||||||||||||||||||||||||||||||
| 69 | } # if | ||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | &pod2usage(1) if ($opts{'help'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 71 | &pod2usage( | ||||||||||||||||||||||||||||||||
| 72 | -verbose => 2, | ||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | ) if ($opts{'man'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | &pod2usage( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 75 | -verbose => 0, | ||||||||||||||||||||||||||||||||
| 76 | -exitval => 1, | ||||||||||||||||||||||||||||||||
| 77 | -message => 'missing argument "qid"', | ||||||||||||||||||||||||||||||||
| 78 | ) if ($#ARGV == -1); | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | 0 | my $s_dbg = $opts{'stats'}; | |||||||||||||||||||||||||||||||
| 81 | 0 | my $v_dbg = $opts{'v'}; | |||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | my $d_dbg = $opts{'debug'} || $v_dbg; | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts{'debug'} || $v_dbg
MC/DC0%0/2
$opts{'debug'} || $v_dbg
$opts{'debug'}
$v_dbg
Truth table0%0/3
A || B
A= $opts{'debug'}B= $v_dbg
| |||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | if ($v_dbg) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 84 | { | ||||||||||||||||||||||||||||||||
| 85 | 0 | print STDERR "v option: defined\n"; | |||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | print STDERR "stats option: ", ! $opts{'stats'} ? 'not ' : '', "defined\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | print STDERR "debug option: ", ! $opts{'debug'} ? 'not ' : '', "defined\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 88 | } # if | ||||||||||||||||||||||||||||||||
| 89 | sub module_loaded | ||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
module_loaded: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 91 | 0 | my $sModule = shift; | |||||||||||||||||||||||||||||||
| 92 | 0 | eval "use $sModule"; | |||||||||||||||||||||||||||||||
| 93 | 0 | return ($@ eq ''); | |||||||||||||||||||||||||||||||
| 94 | } # module_loaded | ||||||||||||||||||||||||||||||||
| 95 | 0 | ▶ | if ($opts{'m'} ne '') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | { | ||||||||||||||||||||||||||||||||
| 97 | MODULE: | ||||||||||||||||||||||||||||||||
| 98 | 0 | foreach my $sMod (qw( Email::MIME Email::MIME::Creator Email::Send Email::Send::Sendmail Email::Send::Qmail Email::Send::SMTP )) | |||||||||||||||||||||||||||||||
| 99 | { | ||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | if (! &module_loaded($sMod)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 101 | { | ||||||||||||||||||||||||||||||||
| 102 | 0 | print STDERR " --- can not load $sMod module: ==$@==\n"; | |||||||||||||||||||||||||||||||
| 103 | 0 | $opts{'m'} = ''; | |||||||||||||||||||||||||||||||
| 104 | 0 | last MODULE; | |||||||||||||||||||||||||||||||
| 105 | } # if | ||||||||||||||||||||||||||||||||
| 106 | else | ||||||||||||||||||||||||||||||||
| 107 | { | ||||||||||||||||||||||||||||||||
| 108 | # print STDERR " + loaded $sMod\n"; | ||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | } # foreach MODULE | ||||||||||||||||||||||||||||||||
| 111 | } # if | ||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | print STDERR "will send email summary to: ", $opts{'m'}, "\n" if ($v_dbg && ($opts{'m'} ne '')); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$v_dbg and $opts{"m"} ne ""
MC/DC0%0/2
$v_dbg and $opts{"m"} ne ""
$v_dbg
$opts{"m"} ne ""
Truth table0%0/3
A and B
A= $v_dbgB= $opts{"m"} ne ""
| |||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | # if we want a list of args: | ||||||||||||||||||||||||||||||||
| 115 | #@query_list = split(/[,\s]+/, $opts{'n'},2) if defined($opts{'n'}); | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $query_name = $opts{'n'} || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'n'} || ''
MC/DC0%0/1
$opts{'n'} || ''
$opts{'n'}
Truth table0%0/2
A
A= $opts{'n'}
| |||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | $query_string = $opts{'s'} || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'s'} || ''
MC/DC0%0/1
$opts{'s'} || ''
$opts{'s'}
Truth table0%0/2
A
A= $opts{'s'}
| |||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | $search_engine = $opts{'e'} || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$opts{'e'} || ''
MC/DC0%0/1
$opts{'e'} || ''
$opts{'e'}
Truth table0%0/2
A
A= $opts{'e'}
| |||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if (defined($opts{'o'})) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 121 | { | ||||||||||||||||||||||||||||||||
| 122 | 0 | $query_options = {}; | |||||||||||||||||||||||||||||||
| 123 | 0 | foreach my $sPair (@{$opts{'o'}}) | |||||||||||||||||||||||||||||||
| 124 | { | ||||||||||||||||||||||||||||||||
| 125 | 0 | my ($key, $value) = $sPair =~ m/^([^=]+)=(.*)$/; | |||||||||||||||||||||||||||||||
| 126 | 0 | &add_to_hash($key, &WWW::Search::escape_query($value), $query_options); | |||||||||||||||||||||||||||||||
| 127 | } # foreach | ||||||||||||||||||||||||||||||||
| 128 | } # if | ||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | $url_filter = $opts{'f'} if defined($opts{'f'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 130 | 0 | my($local_filter) = 0; # shall we exclude our own old pages? (1=y,0=n) | |||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | #print STDERR "n = \"$opts{'n'}\"\n" if defined($opts{'n'}); | ||||||||||||||||||||||||||||||||
| 133 | #print STDERR "s = \"$opts{'s'}\"\n" if defined($opts{'s'}); | ||||||||||||||||||||||||||||||||
| 134 | #print STDERR "e = \"$opts{'e'}\"\n" if defined($opts{'e'}); | ||||||||||||||||||||||||||||||||
| 135 | #print STDERR "o = \"$opts{'o'}\"\n" if defined($opts{'o'}); | ||||||||||||||||||||||||||||||||
| 136 | #print STDERR "f = \"$opts{'f'}\"\n" if defined($opts{'f'}); | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | ##print STDERR "query_list = \"$query_list[0]\" \"$query_list[1]\"\n"; | ||||||||||||||||||||||||||||||||
| 139 | #print STDERR "query_name = \"$query_name\"\n"; | ||||||||||||||||||||||||||||||||
| 140 | #print STDERR "query_string = \"$query_string\"\n"; | ||||||||||||||||||||||||||||||||
| 141 | #print STDERR "search_engine = \"$search_engine\"\n"; | ||||||||||||||||||||||||||||||||
| 142 | #print STDERR "url_filter = \"$url_filter\"\n" if defined($opts{'f'}); | ||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||
| 144 | 0 | &main(join(" ", @ARGV)); | |||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 0 | exit 0; | |||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||
| 148 | ######## | ||||||||||||||||||||||||||||||||
| 149 | # subs # | ||||||||||||||||||||||||||||||||
| 150 | ######## | ||||||||||||||||||||||||||||||||
| 151 | # | ||||||||||||||||||||||||||||||||
| 152 | # all the subroutine documentation has been disabled -- oh for a ifdef | ||||||||||||||||||||||||||||||||
| 153 | # someday -- put all the subs in another file & tech documentation | ||||||||||||||||||||||||||||||||
| 154 | # from there, man page from main file. wls :) 10/18/96 :( | ||||||||||||||||||||||||||||||||
| 155 | # | ||||||||||||||||||||||||||||||||
| 156 | #=head1 SUBROUTINES | ||||||||||||||||||||||||||||||||
| 157 | # | ||||||||||||||||||||||||||||||||
| 158 | #=cut | ||||||||||||||||||||||||||||||||
| 159 | # | ||||||||||||||||||||||||||||||||
| 160 | # Files expected first_date.html and first_index.html in the | ||||||||||||||||||||||||||||||||
| 161 | # 'home' directory. These are used to build the initial | ||||||||||||||||||||||||||||||||
| 162 | # search files. | ||||||||||||||||||||||||||||||||
| 163 | # | ||||||||||||||||||||||||||||||||
| 164 | # To start a new search: specify a query name (-qn) and | ||||||||||||||||||||||||||||||||
| 165 | # query string (-qs) (and more). If either are not provided, AS will | ||||||||||||||||||||||||||||||||
| 166 | # ask the user (STDIN) for the name and/or the string as necessary. | ||||||||||||||||||||||||||||||||
| 167 | # The string "AutoSearch WEB Searching" is replaced by the query name | ||||||||||||||||||||||||||||||||
| 168 | # and the string "ask user" is replaced by the query string. | ||||||||||||||||||||||||||||||||
| 169 | # | ||||||||||||||||||||||||||||||||
| 170 | # AS 1.x accepts the basic query sub-directory identifier | ||||||||||||||||||||||||||||||||
| 171 | # and looks to see if qid/date.html exists. If this file | ||||||||||||||||||||||||||||||||
| 172 | # file does not exist, AS looks for a file first_date.html | ||||||||||||||||||||||||||||||||
| 173 | # If the default file in the parent directory is missing, AS | ||||||||||||||||||||||||||||||||
| 174 | # creates a default-default file named qid/date.html. | ||||||||||||||||||||||||||||||||
| 175 | # In any case the directory 'qid' is created. | ||||||||||||||||||||||||||||||||
| 176 | # A second file first_index.html is used to create the initial | ||||||||||||||||||||||||||||||||
| 177 | # qid/index.html file in a like fashon. | ||||||||||||||||||||||||||||||||
| 178 | # | ||||||||||||||||||||||||||||||||
| 179 | # (LATER: ADD SEARCH ENGINE(S)) | ||||||||||||||||||||||||||||||||
| 180 | # There are three important items which must be defined for any | ||||||||||||||||||||||||||||||||
| 181 | # search that AS will process. First the query-subdirectory | ||||||||||||||||||||||||||||||||
| 182 | # identifier (qid). This is the handle to this query. | ||||||||||||||||||||||||||||||||
| 183 | # Once a query session is established; only the qid need be | ||||||||||||||||||||||||||||||||
| 184 | # specified on the command line. | ||||||||||||||||||||||||||||||||
| 185 | # Second is the 'pretty name' that you will assign to this | ||||||||||||||||||||||||||||||||
| 186 | # Query. This is used at the top of the screens to help | ||||||||||||||||||||||||||||||||
| 187 | # the user identify what the searche topic is. Third | ||||||||||||||||||||||||||||||||
| 188 | # is the actual search string. This is passed directly to | ||||||||||||||||||||||||||||||||
| 189 | # search processor, and the search engine. | ||||||||||||||||||||||||||||||||
| 190 | # | ||||||||||||||||||||||||||||||||
| 191 | # File date.html is used to define the format of the pages which are | ||||||||||||||||||||||||||||||||
| 192 | # created each time (weekly) AutoSearch.pl is run. Major sections of | ||||||||||||||||||||||||||||||||
| 193 | # the file are identified with html comments. The search string is | ||||||||||||||||||||||||||||||||
| 194 | # embedded in this file too. One method of creating a new search is | ||||||||||||||||||||||||||||||||
| 195 | # to create the new directory manually and create a file named | ||||||||||||||||||||||||||||||||
| 196 | # date.html in the sub-directory. However; this requires you to | ||||||||||||||||||||||||||||||||
| 197 | # understand the tags and build a file which is compatible with AS. | ||||||||||||||||||||||||||||||||
| 198 | # | ||||||||||||||||||||||||||||||||
| 199 | # A second method is to manually copy first_date.html to qid/date.html | ||||||||||||||||||||||||||||||||
| 200 | # and edit it. This is the John method to introduce a new search. It | ||||||||||||||||||||||||||||||||
| 201 | # is cumbersome and not-automated-ish. | ||||||||||||||||||||||||||||||||
| 202 | # | ||||||||||||||||||||||||||||||||
| 203 | # A third approach involves using command line arguments to specify | ||||||||||||||||||||||||||||||||
| 204 | # the query name and string. This is the wls method. One variation | ||||||||||||||||||||||||||||||||
| 205 | # on the wls method is the "ask user" method. In this approach, AS | ||||||||||||||||||||||||||||||||
| 206 | # will ask the user for the required items. In both of these methods | ||||||||||||||||||||||||||||||||
| 207 | # the necessary files will be created. | ||||||||||||||||||||||||||||||||
| 208 | # | ||||||||||||||||||||||||||||||||
| 209 | # Once the initial search has been made and the files created, then | ||||||||||||||||||||||||||||||||
| 210 | # the simple command "AutoSearch qid" will update the search files and | ||||||||||||||||||||||||||||||||
| 211 | # pages. | ||||||||||||||||||||||||||||||||
| 212 | # | ||||||||||||||||||||||||||||||||
| 213 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 214 | # | ||||||||||||||||||||||||||||||||
| 215 | #main - start of actual work. | ||||||||||||||||||||||||||||||||
| 216 | # | ||||||||||||||||||||||||||||||||
| 217 | # | ||||||||||||||||||||||||||||||||
| 218 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 219 | # | ||||||||||||||||||||||||||||||||
| 220 | #Submit a search and build output files. | ||||||||||||||||||||||||||||||||
| 221 | # | ||||||||||||||||||||||||||||||||
| 222 | #=cut | ||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||
| 224 | # submit a search and optionally build output file(s). | ||||||||||||||||||||||||||||||||
| 225 | # | ||||||||||||||||||||||||||||||||
| 226 | sub main | ||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
main: not called CC=137 SCAR=98.5
| |||||||||||||||||||||||||||||||||
| 228 | 0 | my ($query_dir) = @_; | |||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my $dbg_search = $d_dbg || 0; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$d_dbg || 0
MC/DC0%0/1
$d_dbg || 0
$d_dbg
Truth table0%0/2
A
A= $d_dbg
| |||||||||||||||||||||||||||||||||
| 230 | 0 | my $v_dbg = $v_dbg; # shall we be verbose?? | |||||||||||||||||||||||||||||||
| 231 | 0 | my $sEmail = ''; | |||||||||||||||||||||||||||||||
| 232 | 0 | my $url_filter_count = 0; | |||||||||||||||||||||||||||||||
| 233 | # get the date. | ||||||||||||||||||||||||||||||||
| 234 | 0 | my $now = &time_now; | |||||||||||||||||||||||||||||||
| 235 | 0 | my $today = &time_today; | |||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | print STDERR "Now = ", $now if $v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 237 | 0 | ▶ | print STDERR ", Today = ", $today, "\n" if $v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 238 | # Build query directory string: | ||||||||||||||||||||||||||||||||
| 239 | 0 | my $qid = $query_dir; | |||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | die ("qid is a required argument.") unless ($qid); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | die ("qid is a required argument.") unless ($qid =~ m!\S!); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | print STDERR "query directory: $qid\n" if $v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 243 | # Do we have the necessary infrastructure? We require two files: 1) | ||||||||||||||||||||||||||||||||
| 244 | # the summary of searches and 2) weekly updates. Look for | ||||||||||||||||||||||||||||||||
| 245 | # index.html, or default first_index.html, or make one from scratch. | ||||||||||||||||||||||||||||||||
| 246 | # index.html contains the previous search results. (aka old summary) | ||||||||||||||||||||||||||||||||
| 247 | 0 | &check_index_file($qid); # make qid/index.html | |||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | $v_dbg && print STDERR " + found/created $qid/index.html\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | if ($opts{'cmdline'}) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||
| 251 | # Show the original cmdline and exit: | ||||||||||||||||||||||||||||||||
| 252 | 0 | my %hssOptions = ( | |||||||||||||||||||||||||||||||
| 253 | Query => '--querystring', | ||||||||||||||||||||||||||||||||
| 254 | QueryName => '--queryname', | ||||||||||||||||||||||||||||||||
| 255 | SearchEngine => '--engine', | ||||||||||||||||||||||||||||||||
| 256 | URLFilter => '--filter', | ||||||||||||||||||||||||||||||||
| 257 | QueryOptions => '--option', | ||||||||||||||||||||||||||||||||
| 258 | # IgnoreChannels => '--ignore_channels', | ||||||||||||||||||||||||||||||||
| 259 | ); | ||||||||||||||||||||||||||||||||
| 260 | 0 | my $sFile = qq{$qid/index.html}; | |||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | open(INDEX, $sFile) or die " --- can not open $sFile for read: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 262 | # Slurp entire file: | ||||||||||||||||||||||||||||||||
| 263 | 0 | local $/ = undef; | |||||||||||||||||||||||||||||||
| 264 | 0 | my $sHTML = <INDEX>; | |||||||||||||||||||||||||||||||
| 265 | 0 | ▶ | close(INDEX) or warn " --- can not close $sFile after reading: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 266 | 0 | my $sCmdline = qq{$0 $qid }; | |||||||||||||||||||||||||||||||
| 267 | # Special case: look for QueryName inside <h1> tags: | ||||||||||||||||||||||||||||||||
| 268 | 0 | $sHTML =~ s#<h1>(.+?)</h1>#<!--QueryName\{$1}/QueryName-->#; | |||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | while (my ($sTag, $sArg) = each %hssOptions) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 270 | { | ||||||||||||||||||||||||||||||||
| 271 | 0 | ▶ | while ($sHTML =~ m#<!--$sTag\{(.*?)}/$sTag-->#g) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 272 | { | ||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | my $sValue = $1 || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$1 || ''
MC/DC0%0/1
$1 || ''
$1
Truth table0%0/2
A
A= $1
| |||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | $sCmdline .= qq{$sArg "$sValue" } if ($sValue ne ''); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 275 | } # while | ||||||||||||||||||||||||||||||||
| 276 | } # while | ||||||||||||||||||||||||||||||||
| 277 | 0 | print STDERR "\n$sCmdline\n"; | |||||||||||||||||||||||||||||||
| 278 | 0 | return; | |||||||||||||||||||||||||||||||
| 279 | } # if --cmdline | ||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||
| 281 | 0 | my $iCleanup = $opts{'cleanup'}; | |||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if (0 < $iCleanup) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 283 | { | ||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | print STDERR " + doing cleanup $iCleanup in ==$qid==\n" if $opts{debug}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 285 | # We don't care what the timezone is, we only deal with days: | ||||||||||||||||||||||||||||||||
| 286 | 0 | &Date_Init('TZ=US/Eastern'); | |||||||||||||||||||||||||||||||
| 287 | 0 | my $dateCutoff = &DateCalc('today', " - $iCleanup days"); | |||||||||||||||||||||||||||||||
| 288 | 0 | my $sCutoff = &UnixDate($dateCutoff, '%Y%m%d'); | |||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | print STDERR " + cutoff date is ==$sCutoff==\n" if $opts{debug}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 290 | 0 | ▶ | opendir(DIR, $qid) or die(" --- can not read directory $qid: $!"); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 291 | CLEANUP_FILE: | ||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | while (my $sFile = readdir(DIR)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 293 | { | ||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | next CLEANUP_FILE if $sFile eq '.'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | next CLEANUP_FILE if $sFile eq '..'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | print STDERR " + found file ==$sFile==\n" if $opts{debug}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ($sFile lt $sCutoff) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 298 | { | ||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | print STDERR " + unlink ==$sFile==\n" if $opts{debug}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 300 | 0 | ▶ | unlink qq{$qid/$sFile} or warn $!; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 301 | } # if file is old | ||||||||||||||||||||||||||||||||
| 302 | } # while | ||||||||||||||||||||||||||||||||
| 303 | 0 | closedir DIR; | |||||||||||||||||||||||||||||||
| 304 | # Now delete old lines from index.html: | ||||||||||||||||||||||||||||||||
| 305 | 0 | my $sFile = qq{$qid/index.html}; | |||||||||||||||||||||||||||||||
| 306 | 0 | my $sFileNew = qq{$sFile.new}; | |||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | open(INDEX, $sFile) or die " --- can not open $sFile for read: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | open(NEW, '>'. $sFileNew) or die " --- can not open $sFileNew for write: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 309 | 0 | local $/ = "\n"; | |||||||||||||||||||||||||||||||
| 310 | CLEANUP_LINE: | ||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | while (my $sLine = <INDEX>) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 312 | { | ||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | if ($sLine =~ m!search on ([A-Za-z]+ \d+, \d+)!) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 314 | { | ||||||||||||||||||||||||||||||||
| 315 | # This line contains a date. | ||||||||||||||||||||||||||||||||
| 316 | 0 | my $date = &ParseDate($1); | |||||||||||||||||||||||||||||||
| 317 | 0 | my $iCmp = &Date_Cmp($date, $dateCutoff); | |||||||||||||||||||||||||||||||
| 318 | 0 | ▶ | if ($iCmp < 0) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 319 | { | ||||||||||||||||||||||||||||||||
| 320 | # This line's date is before the cutoff. | ||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | print STDERR " + delete line $sLine" if $opts{debug}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 322 | 0 | next CLEANUP_LINE; | |||||||||||||||||||||||||||||||
| 323 | } # if | ||||||||||||||||||||||||||||||||
| 324 | } # if | ||||||||||||||||||||||||||||||||
| 325 | 0 | print NEW $sLine; | |||||||||||||||||||||||||||||||
| 326 | } # while | ||||||||||||||||||||||||||||||||
| 327 | 0 | close INDEX; | |||||||||||||||||||||||||||||||
| 328 | 0 | close NEW; | |||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | copy($sFileNew, $sFile) or die " --- can not copy $sFileNew to $sFile: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 330 | 0 | unlink $sFileNew; # No big deal if this fails | |||||||||||||||||||||||||||||||
| 331 | # All done: | ||||||||||||||||||||||||||||||||
| 332 | 0 | return; | |||||||||||||||||||||||||||||||
| 333 | } # if --cleanup | ||||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | $qid .= '/' unless substr($qid,-1,1) eq '/'; # we MUST have a / | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 336 | # Read index.html and break into fields. | ||||||||||||||||||||||||||||||||
| 337 | 0 | my ($SummaryTop, $SummaryQuery, | |||||||||||||||||||||||||||||||
| 338 | $SummarySearchEngine, $SummaryURLFilter, | ||||||||||||||||||||||||||||||||
| 339 | $SummaryHeading, $SummaryTemplate, $Summary, | ||||||||||||||||||||||||||||||||
| 340 | $WeeklyHeading, $WeeklyTemplate, $Weekly, | ||||||||||||||||||||||||||||||||
| 341 | $SummaryBottom, @SummaryQueryOptions) = &get_summary_parts($qid); | ||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | $v_dbg && print STDERR " + got summary parts...\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 343 | # Split the old summary into a list. (later sort it) | ||||||||||||||||||||||||||||||||
| 344 | 0 | my ($url, $description, $title); | |||||||||||||||||||||||||||||||
| 345 | 0 | my (@old_summary_url,@old_summary_title); | |||||||||||||||||||||||||||||||
| 346 | 0 | my @old_summary = split(/\n/,$Summary); | |||||||||||||||||||||||||||||||
| 347 | 0 | my ($line); | |||||||||||||||||||||||||||||||
| 348 | 0 | my ($i, $n, $j, $m); | |||||||||||||||||||||||||||||||
| 349 | # Break each hyperlink into its url and title. | ||||||||||||||||||||||||||||||||
| 350 | 0 | for my $i (0..$#old_summary) | |||||||||||||||||||||||||||||||
| 351 | { | ||||||||||||||||||||||||||||||||
| 352 | # $old_summary -> $url & $title | ||||||||||||||||||||||||||||||||
| 353 | 0 | $line = $old_summary[$i]; | |||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | if ($line =~ m#<a href="(.*)">(.*)</a><br>#i) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 355 | { | ||||||||||||||||||||||||||||||||
| 356 | 0 | $url = $1; | |||||||||||||||||||||||||||||||
| 357 | 0 | $title = $2; | |||||||||||||||||||||||||||||||
| 358 | 0 | push (@old_summary_url,$url); | |||||||||||||||||||||||||||||||
| 359 | 0 | push (@old_summary_title,$title); | |||||||||||||||||||||||||||||||
| 360 | } # if | ||||||||||||||||||||||||||||||||
| 361 | } # for | ||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||
| 363 | # For each item in weekly list: | ||||||||||||||||||||||||||||||||
| 364 | # If it is in old summary list remove it, else leave it. | ||||||||||||||||||||||||||||||||
| 365 | # Hint: note alphabetical order to reduce searching. | ||||||||||||||||||||||||||||||||
| 366 | # Append weekly list to summary list. Sort it. | ||||||||||||||||||||||||||||||||
| 367 | # Use summary list to build a new summary. | ||||||||||||||||||||||||||||||||
| 368 | # Output first half of the NEW index.html page. (summary) | ||||||||||||||||||||||||||||||||
| 369 | # Append either "no new results" (if zero unique left in weekly list) | ||||||||||||||||||||||||||||||||
| 370 | # or the date to weekly results list. | ||||||||||||||||||||||||||||||||
| 371 | # Output second half of NEW index.html page. (weekly results) | ||||||||||||||||||||||||||||||||
| 372 | # | ||||||||||||||||||||||||||||||||
| 373 | # If non-zero, use weekly list to build weekly file. | ||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||
| 375 | # These are the input params to autosearch: | ||||||||||||||||||||||||||||||||
| 376 | # 1) qid, 2) query name, 3) query string, 4) search engine, | ||||||||||||||||||||||||||||||||
| 377 | # 5) query options, and 6) url filter RE. | ||||||||||||||||||||||||||||||||
| 378 | # Dispose of input params as follows: | ||||||||||||||||||||||||||||||||
| 379 | # Insert the Query Name into 'Top' for index.html & date.html, | ||||||||||||||||||||||||||||||||
| 380 | # Insert the Query String, Search Engine, and URL Filter into | ||||||||||||||||||||||||||||||||
| 381 | # the 'HTML fields' from index.html | ||||||||||||||||||||||||||||||||
| 382 | # Precedence of input: Query Name (pretty name) and Query String (search engine) | ||||||||||||||||||||||||||||||||
| 383 | # Search Engine (AltaVista), Search Options (## need example ##), | ||||||||||||||||||||||||||||||||
| 384 | # URL Filter (to suppress display and tracking of particular URLs) | ||||||||||||||||||||||||||||||||
| 385 | # 1) from existing file or default files (files already in place), or | ||||||||||||||||||||||||||||||||
| 386 | # 2) from user. | ||||||||||||||||||||||||||||||||
| 387 | # (either a) command line or b) "ask user" (or error if we don't dare)) | ||||||||||||||||||||||||||||||||
| 388 | 0 | my ($QueryName, $QueryString, $SearchEngine, $URLFilter); | |||||||||||||||||||||||||||||||
| 389 | 0 | $QueryName = $query_name; | |||||||||||||||||||||||||||||||
| 390 | # did we get a Query Name/String/Engine/Options/Filter from existing files? | ||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if ($SummaryTop =~ m/AutoSearch WEB Searching/i) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 392 | { | ||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | if ($query_name eq '') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 394 | { | ||||||||||||||||||||||||||||||||
| 395 | # We did not get --queryname from command line | ||||||||||||||||||||||||||||||||
| 396 | 0 | $QueryName = &read_query("Please enter a Query Name:"); | |||||||||||||||||||||||||||||||
| 397 | } # if | ||||||||||||||||||||||||||||||||
| 398 | 0 | $SummaryTop =~ s/AutoSearch WEB Searching/$QueryName/i; | |||||||||||||||||||||||||||||||
| 399 | } # if | ||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | print STDERR "Query Name is \"$QueryName\"\n" if $v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if ($SummaryQuery =~ m/ask user/i) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 403 | { | ||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if ($query_string ne '') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 405 | { | ||||||||||||||||||||||||||||||||
| 406 | # We did get --querystring from command line | ||||||||||||||||||||||||||||||||
| 407 | 0 | $QueryString = $query_string; | |||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||
| 409 | else | ||||||||||||||||||||||||||||||||
| 410 | { | ||||||||||||||||||||||||||||||||
| 411 | # We did NOT get --querystring, ask the user: | ||||||||||||||||||||||||||||||||
| 412 | 0 | $QueryString = &read_query("Please enter a Query String:"); | |||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||
| 414 | 0 | $SummaryQuery =~ s/ask user/$QueryString/i; | |||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | print STDERR "Query String is \"$QueryString\"\n" if $v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 416 | } # if | ||||||||||||||||||||||||||||||||
| 417 | 0 | my $sTitle = "<Title> Search results for $SummaryQuery as of $now </Title>\n"; | |||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||
| 419 | # This is not a required field. | ||||||||||||||||||||||||||||||||
| 420 | # This MUST BE 'ask user' to get AutoSearch to ask. | ||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if ($SummarySearchEngine =~ m/ask user/i) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 422 | { | ||||||||||||||||||||||||||||||||
| 423 | 0 | ▶ | if ($search_engine ne '') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 424 | { | ||||||||||||||||||||||||||||||||
| 425 | # We DID get --engine on command line: | ||||||||||||||||||||||||||||||||
| 426 | 0 | $SearchEngine = $search_engine; | |||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||
| 428 | else | ||||||||||||||||||||||||||||||||
| 429 | { | ||||||||||||||||||||||||||||||||
| 430 | # We did NOT get --engine, ask user: | ||||||||||||||||||||||||||||||||
| 431 | 0 | $SearchEngine = &read_query("Please enter a Search Engine:"); | |||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||
| 433 | 0 | $SummarySearchEngine =~ s/ask user/$SearchEngine/i; | |||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||
| 435 | else | ||||||||||||||||||||||||||||||||
| 436 | { | ||||||||||||||||||||||||||||||||
| 437 | # don't ask; try command line: | ||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | if ($search_engine ne '') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 439 | { | ||||||||||||||||||||||||||||||||
| 440 | # We DID get --engine on command line: | ||||||||||||||||||||||||||||||||
| 441 | 0 | $SearchEngine = $search_engine; | |||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||
| 443 | else | ||||||||||||||||||||||||||||||||
| 444 | { | ||||||||||||||||||||||||||||||||
| 445 | # No --engine on command line, no Search Engine in index file. | ||||||||||||||||||||||||||||||||
| 446 | # Use whatever was in the first_index.html file | ||||||||||||||||||||||||||||||||
| 447 | 0 | $SearchEngine = $SummarySearchEngine; | |||||||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||||||
| 449 | 0 | $SummarySearchEngine = $SearchEngine; | |||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | print STDERR "Search Engine is \"$SearchEngine\"\n" if $v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||
| 453 | # This is not a required field. | ||||||||||||||||||||||||||||||||
| 454 | # This MUST BE 'ask user' to get AutoSearch to ask. | ||||||||||||||||||||||||||||||||
| 455 | # | ||||||||||||||||||||||||||||||||
| 456 | # print $SummaryQueryOptions[0], " v. ask user\n"; | ||||||||||||||||||||||||||||||||
| 457 | 0 | ▶ | if ($SummaryQueryOptions[0] =~ m/ask user/i) { # either ask or use command line | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 458 | # print $SummaryQueryOptions[0], " is ask user\n"; | ||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | if (defined($opts{'o'})) { # from command line ? | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 460 | # print STDERR "defined.\n"; | ||||||||||||||||||||||||||||||||
| 461 | # use $query_options | ||||||||||||||||||||||||||||||||
| 462 | } else { # no, ask 'em | ||||||||||||||||||||||||||||||||
| 463 | # print STDERR "not defined.\n"; | ||||||||||||||||||||||||||||||||
| 464 | 0 | @SummaryQueryOptions = &read_query_list("Please enter Query Options:"); | |||||||||||||||||||||||||||||||
| 465 | 0 | $query_options = {}; | |||||||||||||||||||||||||||||||
| 466 | 0 | foreach (@SummaryQueryOptions) { | |||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | next if m/^$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 468 | 0 | my($key, $value) = m/^([^=]+)=(.*)$/; | |||||||||||||||||||||||||||||||
| 469 | # print STDERR "option:$_ is $key=$value\n"; | ||||||||||||||||||||||||||||||||
| 470 | 0 | &add_to_hash($key, &WWW::Search::escape_query($value), $query_options); | |||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||
| 473 | } else { # or use what came from index.html file | ||||||||||||||||||||||||||||||||
| 474 | 0 | $query_options = {}; | |||||||||||||||||||||||||||||||
| 475 | 0 | foreach (@SummaryQueryOptions) { | |||||||||||||||||||||||||||||||
| 476 | 0 | ▶ | next if m/^$/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 477 | 0 | my($key, $value) = m/^([^=]+)=(.*)$/; | |||||||||||||||||||||||||||||||
| 478 | # print STDERR "option:$_ is $key=$value\n"; | ||||||||||||||||||||||||||||||||
| 479 | 0 | &add_to_hash($key, &WWW::Search::escape_query($value), $query_options); | |||||||||||||||||||||||||||||||
| 480 | } | ||||||||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||
| 483 | # this is not a required field. | ||||||||||||||||||||||||||||||||
| 484 | # this MUST BE ask user to get AutoSearch to ask. | ||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | if ($SummaryURLFilter =~ m/ask user/i) { # no, shall we ask the user | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if (defined($url_filter)) { # from command line ? | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 487 | 0 | $URLFilter = $url_filter; | |||||||||||||||||||||||||||||||
| 488 | } else { # no, ask 'em | ||||||||||||||||||||||||||||||||
| 489 | 0 | $URLFilter = &read_query("Please enter a URL Filter:"); | |||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||
| 491 | 0 | $SummaryURLFilter =~ s/ask user/$URLFilter/i; | |||||||||||||||||||||||||||||||
| 492 | } else { # don't ask; try command line | ||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | if (defined($url_filter)) { # from command line ? | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 494 | 0 | $URLFilter = $url_filter; # yes | |||||||||||||||||||||||||||||||
| 495 | } else { # if no comamnd line, no filter!! | ||||||||||||||||||||||||||||||||
| 496 | 0 | $URLFilter = $SummaryURLFilter; # use whatever was in the first_index.html file | |||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||
| 498 | 0 | $SummaryURLFilter = $URLFilter; | |||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||
| 500 | 0 | ▶ | if ($s_dbg) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 501 | { | ||||||||||||||||||||||||||||||||
| 502 | 0 | print STDERR qq{Query is : "$SummaryQuery"}; | |||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | print STDERR qq{ with "@SummaryQueryOptions"} if ($#SummaryQueryOptions); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 504 | 0 | print STDERR "\n"; | |||||||||||||||||||||||||||||||
| 505 | } # if | ||||||||||||||||||||||||||||||||
| 506 | 0 | ▶ | print STDERR "URL Filter is \"$URLFilter\"\n" if $v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 507 | # | ||||||||||||||||||||||||||||||||
| 508 | # now locate the weekly format file. | ||||||||||||||||||||||||||||||||
| 509 | # 1) qid/date.html, or 2) first_date.html, or 3) create one. | ||||||||||||||||||||||||||||||||
| 510 | 0 | &check_date_file($qid,$QueryName,$QueryString); #make qid/date.html | |||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||
| 512 | # read date.html and break into fields. | ||||||||||||||||||||||||||||||||
| 513 | # make the search results into a list of urls, title, & descr). | ||||||||||||||||||||||||||||||||
| 514 | # (later sort it) | ||||||||||||||||||||||||||||||||
| 515 | # note: Top & Bottom CAN BE different from index.html. | ||||||||||||||||||||||||||||||||
| 516 | 0 | my($WeeklyTop, | |||||||||||||||||||||||||||||||
| 517 | $AppendedHeading,$AppendedTemplate,$Appended, | ||||||||||||||||||||||||||||||||
| 518 | $SuspendedHeading,$SuspendedTemplate,$Suspended, | ||||||||||||||||||||||||||||||||
| 519 | $WeeklyBottom) | ||||||||||||||||||||||||||||||||
| 520 | = &get_weekly_parts($qid); | ||||||||||||||||||||||||||||||||
| 521 | # insert queryname into html Top from date.html | ||||||||||||||||||||||||||||||||
| 522 | # usually this is not set up, because when we created the file we didn't | ||||||||||||||||||||||||||||||||
| 523 | # have the data. Do we have the Query Name? | ||||||||||||||||||||||||||||||||
| 524 | 0 | $WeeklyTop =~ s/>AutoSearch WEB Searching</$QueryName/; | |||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | $v_dbg && print STDERR " + got weekly parts...\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||
| 527 | 0 | my $hits = 0; # actual no. of hits. | |||||||||||||||||||||||||||||||
| 528 | 0 | my $saved = 0; # actual no. saved. | |||||||||||||||||||||||||||||||
| 529 | 0 | my $search; | |||||||||||||||||||||||||||||||
| 530 | # Search AltaVista, or whatever the user has specified. | ||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | if($SummarySearchEngine) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 532 | 0 | $search = new WWW::Search($SummarySearchEngine); | |||||||||||||||||||||||||||||||
| 533 | } else { | ||||||||||||||||||||||||||||||||
| 534 | 0 | $search = new WWW::Search(undef()); # must be undef to get default. | |||||||||||||||||||||||||||||||
| 535 | } | ||||||||||||||||||||||||||||||||
| 536 | 0 | ▶ | $search->{_host} = $opts{'h'} if defined($opts{'h'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | $search->{_port} = $opts{'p'} if defined($opts{'p'}); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | if (defined($opts{'http_proxy'}) && ($opts{'http_proxy'} ne '')) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
defined $opts{"http_proxy"} and $opts{"http_proxy"} ne ""
MC/DC0%0/2
defined $opts{"http_proxy"} and $opts{"http_proxy"} ne ""
defined $opts{"http_proxy"}
$opts{"http_proxy"} ne ""
Truth table0%0/3
A and B
A= defined $opts{"http_proxy"}B= $opts{"http_proxy"} ne ""
| |||||||||||||||||||||||||||||||||
| 539 | { | ||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | print STDERR qq{ + applying http_proxy }, Dumper(\$opts{http_proxy}) if $opts{'debug'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 541 | 0 | $search->http_proxy(['http', ] => $opts{'http_proxy'}); | |||||||||||||||||||||||||||||||
| 542 | 0 | ▶ | if (defined($opts{'http_proxy_user'}) && ($opts{'http_proxy_user'} ne '')) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $opts{"http_proxy_user"} and $opts{"http_proxy_user"} ne ""
MC/DC0%0/2
defined $opts{"http_proxy_user"} and $opts{"http_proxy_user"} ne ""
defined $opts{"http_proxy_user"}
$opts{"http_proxy_user"} ne ""
Truth table0%0/3
A and B
A= defined $opts{"http_proxy_user"}B= $opts{"http_proxy_user"} ne ""
| |||||||||||||||||||||||||||||||||
| 543 | { | ||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | print STDERR qq{ + applying $opts{http_proxy_user}...\n} if $opts{'debug'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 545 | 0 | $search->http_proxy_user($opts{'http_proxy_user'}); | |||||||||||||||||||||||||||||||
| 546 | 0 | $search->http_proxy_pwd($opts{'http_proxy_pwd'}); | |||||||||||||||||||||||||||||||
| 547 | } # if | ||||||||||||||||||||||||||||||||
| 548 | } # if | ||||||||||||||||||||||||||||||||
| 549 | elsif ($opts{'env_proxy'}) | ||||||||||||||||||||||||||||||||
| 550 | { | ||||||||||||||||||||||||||||||||
| 551 | 0 | $search->env_proxy($opts{'env_proxy'}); | |||||||||||||||||||||||||||||||
| 552 | } | ||||||||||||||||||||||||||||||||
| 553 | elsif (0) | ||||||||||||||||||||||||||||||||
| 554 | { | ||||||||||||||||||||||||||||||||
| 555 | # This is the OLD code: | ||||||||||||||||||||||||||||||||
| 556 | $search->http_proxy($ENV{'HTTP_PROXY'}) if ($ENV{'HTTP_PROXY'}); | ||||||||||||||||||||||||||||||||
| 557 | $search->http_proxy($ENV{'http_proxy'}) if ($ENV{'http_proxy'}); | ||||||||||||||||||||||||||||||||
| 558 | } # if | ||||||||||||||||||||||||||||||||
| 559 | # submit search w/options. | ||||||||||||||||||||||||||||||||
| 560 | 0 | $search->native_query(WWW::Search::escape_query($SummaryQuery), $query_options); | |||||||||||||||||||||||||||||||
| 561 | 0 | $search->login($opts{'userid'}, $opts{'password'}); | |||||||||||||||||||||||||||||||
| 562 | # Process the --ignore_channels argument(s): | ||||||||||||||||||||||||||||||||
| 563 | 0 | my @asChannel; | |||||||||||||||||||||||||||||||
| 564 | 0 | foreach my $sChannel (@{$opts{'ignore_channels'}}) | |||||||||||||||||||||||||||||||
| 565 | { | ||||||||||||||||||||||||||||||||
| 566 | 0 | push @asChannel, split(/,/, $sChannel); | |||||||||||||||||||||||||||||||
| 567 | } # foreach | ||||||||||||||||||||||||||||||||
| 568 | 0 | ▶ | if ($search->can('ignore_channels') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$search->can("ignore_channels") and scalar @asChannel
MC/DC0%0/1
$search->can("ignore_channels") and scalar @asChannel
$search->can("ignore_channels")
Truth table0%0/2
A
A= $search->can("ignore_channels")
| |||||||||||||||||||||||||||||||||
| 569 | && | ||||||||||||||||||||||||||||||||
| 570 | scalar(@asChannel) | ||||||||||||||||||||||||||||||||
| 571 | ) | ||||||||||||||||||||||||||||||||
| 572 | { | ||||||||||||||||||||||||||||||||
| 573 | 0 | $search->ignore_channels(@asChannel); | |||||||||||||||||||||||||||||||
| 574 | } # if | ||||||||||||||||||||||||||||||||
| 575 | # examine search results | ||||||||||||||||||||||||||||||||
| 576 | 0 | my($next_result); | |||||||||||||||||||||||||||||||
| 577 | 0 | my(@new_weekly_url,@new_weekly_title,@new_weekly_description); | |||||||||||||||||||||||||||||||
| 578 | 0 | my @aoResult; # Parallel array to new_weekly_url | |||||||||||||||||||||||||||||||
| 579 | 0 | my(@weekly_url,@weekly_title); | |||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||
| 581 | # care to see the old summary list? | ||||||||||||||||||||||||||||||||
| 582 | # print STDERR "old summary:\n"; | ||||||||||||||||||||||||||||||||
| 583 | # foreach $line (@old_summary_url) { | ||||||||||||||||||||||||||||||||
| 584 | # print STDERR "$line\n"; | ||||||||||||||||||||||||||||||||
| 585 | # } | ||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||
| 587 | # how many hits? | ||||||||||||||||||||||||||||||||
| 588 | # convert latest search results to a list of urls (descriptions & titles) | ||||||||||||||||||||||||||||||||
| 589 | # filtered by $SummaryURLFilter called new_weekly_* | ||||||||||||||||||||||||||||||||
| 590 | NEXT_URL: | ||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | while ($next_result = $search->next_result()) { # page-by-page | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 592 | 0 | $url = $next_result->url; | |||||||||||||||||||||||||||||||
| 593 | 0 | $hits++; # how many were returned? | |||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | if ($local_filter) { # exclude old pages from prev. version? | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 595 | # let's not display references to our own pages. | ||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | next if $url =~ m,www\.isi\.edu/div7/ib/(.+)/(\d+)\.html$,o; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 597 | # let's not display references to our old pages. | ||||||||||||||||||||||||||||||||
| 598 | 0 | ▶ | next if $url =~ m,www\.isi\.edu/div7/ib/jog,o; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||
| 600 | # let the user filter out URLs. | ||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | if ( ($SummaryURLFilter) && ($url =~ m,$SummaryURLFilter,oi) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$SummaryURLFilter and $url =~ /$SummaryURLFilter/io
MC/DC0%0/2
$SummaryURLFilter and $url =~ /$SummaryURLFilter/io
$SummaryURLFilter
$url =~ /$SummaryURLFilter/io
Truth table0%0/3
A and B
A= $SummaryURLFilterB= $url =~ /$SummaryURLFilter/io
| |||||||||||||||||||||||||||||||||
| 602 | # print STDERR "filter out $url \n with filter: $SummaryURLFilter\n"; | ||||||||||||||||||||||||||||||||
| 603 | 0 | $url_filter_count++; | |||||||||||||||||||||||||||||||
| 604 | 0 | next; | |||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||
| 606 | 0 | $saved++; # how many were saved? | |||||||||||||||||||||||||||||||
| 607 | 0 | push(@weekly_url,$url); # the complete set of hits | |||||||||||||||||||||||||||||||
| 608 | 0 | $title = $next_result->title; | |||||||||||||||||||||||||||||||
| 609 | 0 | push(@weekly_title,$title); | |||||||||||||||||||||||||||||||
| 610 | # Was it in the old summary? If so, don't save it. | ||||||||||||||||||||||||||||||||
| 611 | # If not, it is a new search results for this week. | ||||||||||||||||||||||||||||||||
| 612 | 0 | foreach $line (@old_summary_url) | |||||||||||||||||||||||||||||||
| 613 | { | ||||||||||||||||||||||||||||||||
| 614 | # See if this url is in the summary; skip this url if it's in | ||||||||||||||||||||||||||||||||
| 615 | # the summary: | ||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | next NEXT_URL if ($url eq $line); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 617 | } # foreach | ||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | print STDERR "url:$url ** new result **\n" if $dbg_search; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | print "$url\n" if $opts{'listnewurls'}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 620 | 0 | $description = $next_result->description; | |||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | print STDERR "description: ", $description, "\n" if $dbg_search; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | print STDERR "title: ", $title, "\n" if $dbg_search; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 623 | 0 | push(@new_weekly_url,$url); # the newest set of hits (added) | |||||||||||||||||||||||||||||||
| 624 | 0 | push(@new_weekly_description,$description); | |||||||||||||||||||||||||||||||
| 625 | 0 | push(@new_weekly_title,$title); | |||||||||||||||||||||||||||||||
| 626 | 0 | push @aoResult, $next_result; | |||||||||||||||||||||||||||||||
| 627 | } # while NEXT_URL | ||||||||||||||||||||||||||||||||
| 628 | # Report errors, if any: | ||||||||||||||||||||||||||||||||
| 629 | 0 | my $response = $search->response(); | |||||||||||||||||||||||||||||||
| 630 | 0 | ▶ | if ($response->is_success) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 631 | { | ||||||||||||||||||||||||||||||||
| 632 | 0 | ▶ | if ($hits == 0) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 633 | { | ||||||||||||||||||||||||||||||||
| 634 | 0 | ▶ | print STDERR "Warning: Empty results set.\n" if ($v_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 635 | } # if no hits | ||||||||||||||||||||||||||||||||
| 636 | } # if HTTP success | ||||||||||||||||||||||||||||||||
| 637 | else | ||||||||||||||||||||||||||||||||
| 638 | { | ||||||||||||||||||||||||||||||||
| 639 | 0 | my $sMsg = "Error: " . http_error_as_nice_string($response); | |||||||||||||||||||||||||||||||
| 640 | 0 | print STDERR "$sMsg\n"; | |||||||||||||||||||||||||||||||
| 641 | 0 | $sEmail .= "$sMsg\n"; | |||||||||||||||||||||||||||||||
| 642 | } # else HTTP error | ||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||
| 644 | # Only save the ones that don't show up in the current query list. | ||||||||||||||||||||||||||||||||
| 645 | # Those we shall call suspended_* | ||||||||||||||||||||||||||||||||
| 646 | 0 | my (@suspended_url,@suspended_title); | |||||||||||||||||||||||||||||||
| 647 | # We must use a for loop, to get the urls to match their descr & | ||||||||||||||||||||||||||||||||
| 648 | # title. | ||||||||||||||||||||||||||||||||
| 649 | OLD_URL: | ||||||||||||||||||||||||||||||||
| 650 | 0 | for my $i (0..$#old_summary_url) | |||||||||||||||||||||||||||||||
| 651 | { | ||||||||||||||||||||||||||||||||
| 652 | 0 | $url = $old_summary_url[$i]; | |||||||||||||||||||||||||||||||
| 653 | 0 | for my $j (0..$#weekly_url) | |||||||||||||||||||||||||||||||
| 654 | { | ||||||||||||||||||||||||||||||||
| 655 | 0 | $line = $weekly_url[$j]; | |||||||||||||||||||||||||||||||
| 656 | # if we match the weekly (active search) hits, skip it. | ||||||||||||||||||||||||||||||||
| 657 | 0 | ▶ | next OLD_URL if $url eq $line; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 658 | } # for $j | ||||||||||||||||||||||||||||||||
| 659 | 0 | ▶ | printf STDERR "suspend: [%02d]%s\n",$i,$url if $dbg_search; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 660 | # not found? save it, it's been suspended | ||||||||||||||||||||||||||||||||
| 661 | 0 | push(@suspended_url,$url); | |||||||||||||||||||||||||||||||
| 662 | 0 | $title = $old_summary_title[$i]; | |||||||||||||||||||||||||||||||
| 663 | 0 | push(@suspended_title,$title); | |||||||||||||||||||||||||||||||
| 664 | } # for $i | ||||||||||||||||||||||||||||||||
| 665 | # stats?? (to see 'em use -stats) | ||||||||||||||||||||||||||||||||
| 666 | 0 | ▶ | print STDERR "old summary count: ",$#old_summary_url + 1,"\n" if ($s_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 667 | 0 | ▶ | print STDERR "new raw hits : ",$hits,"\n" if ($s_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | print STDERR "urls filtered : ",$url_filter_count,", filter \"",$URLFilter,"\"\n" if ($s_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 669 | 0 | ▶ | print STDERR "not filtered : ",$saved,"\n" if ($s_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 670 | 0 | ▶ | print STDERR "results set count: ",$#new_weekly_url + 1,"\n" if ($s_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 671 | 0 | ▶ | print STDERR "suspended count : ",$#suspended_url + 1,"\n" if ($s_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | print STDERR "final count : ",$#weekly_url + 1,"\n" if ($s_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 673 | 0 | ▶ | my $changes = (($#new_weekly_url != -1) || ($#suspended_url != -1)); | ||||||||||||||||||||||||||||||
|
Condition0%0/3
$#new_weekly_url != -1 || $#suspended_url != -1
MC/DC0%0/2
$#new_weekly_url != -1 || $#suspended_url != -1
$#new_weekly_url != -1
$#suspended_url != -1
Truth table0%0/3
A || B
A= $#new_weekly_url != -1B= $#suspended_url != -1
| |||||||||||||||||||||||||||||||||
| 674 | # printf STDERR "changes is %d\n",$changes if ($v_dbg); | ||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||
| 676 | # For every search, AutoSearch (aka AS) will make a 'weekly' file. | ||||||||||||||||||||||||||||||||
| 677 | # Usually AutoSearch is run as a 'cron' job; but can be run manually. | ||||||||||||||||||||||||||||||||
| 678 | # AS will attempt to handle multiple (non-concurrent) runs per day. | ||||||||||||||||||||||||||||||||
| 679 | 0 | my $file = (&time_file_of_the_day_numeric).'.html'; | |||||||||||||||||||||||||||||||
| 680 | 0 | my $section; | |||||||||||||||||||||||||||||||
| 681 | my $junk; | ||||||||||||||||||||||||||||||||
| 682 | # to test this 'diff' code 1) rm -r qid/* 2) run AS -stats qid -qn -qs | ||||||||||||||||||||||||||||||||
| 683 | # 3) edit qid/index.html remove some, add some (new urls) | ||||||||||||||||||||||||||||||||
| 684 | # 4) run AS -stats qid; look at <today>.html | ||||||||||||||||||||||||||||||||
| 685 | # you will see 'deleted' (from above) as 'recently added' & | ||||||||||||||||||||||||||||||||
| 686 | # 'added' (from above) as 'recently suspended' | ||||||||||||||||||||||||||||||||
| 687 | # reason: the changes were forced in 'old summary', | ||||||||||||||||||||||||||||||||
| 688 | # usually (normal, non-testing cases) the changes will appear in new_weekly_* | ||||||||||||||||||||||||||||||||
| 689 | # now if this is a run that adds information (re) write the file. | ||||||||||||||||||||||||||||||||
| 690 | # | ||||||||||||||||||||||||||||||||
| 691 | # do we have a reason to care? New Results, Appensions, Suspensions??? | ||||||||||||||||||||||||||||||||
| 692 | 0 | my $iNewResultCount = 0; | |||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | if ($changes) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 694 | { | ||||||||||||||||||||||||||||||||
| 695 | # print STDERR "test file: $qid$file\n"; | ||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | if (-e $qid.$file) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 697 | { | ||||||||||||||||||||||||||||||||
| 698 | # File already exists; modify it. | ||||||||||||||||||||||||||||||||
| 699 | 0 | ▶ | print STDERR "modify existing weekly file.\n" if ($v_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 700 | # Copy in previous file from today: | ||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | open (PARTS,'<'.$qid.$file) || die "Can't open weekly input file.\nReason: $!\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 702 | 0 | my($part) = <PARTS>; | |||||||||||||||||||||||||||||||
| 703 | 0 | close (PARTS); | |||||||||||||||||||||||||||||||
| 704 | # print STDERR "Part:\"$part\"\n"; | ||||||||||||||||||||||||||||||||
| 705 | # break into parts to insert modifications | ||||||||||||||||||||||||||||||||
| 706 | 0 | my($part1,$part2) = split (/<!--\/Appended-->/,$part,2); | |||||||||||||||||||||||||||||||
| 707 | 0 | my($part3,$part4) = split (/<!--\/Suspended-->/,$part2,2); | |||||||||||||||||||||||||||||||
| 708 | # write back out w/ changes. | ||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | open (HTML,'>'.$qid.$file) || die "Can't open weekly output file.\nReason: $!\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 710 | 0 | print HTML $part1; | |||||||||||||||||||||||||||||||
| 711 | 0 | $n = $#new_weekly_url + 1; | |||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | if ($n) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 713 | 0 | print HTML "<!--more...-->\n"; | |||||||||||||||||||||||||||||||
| 714 | 0 | print HTML "<h4>Recently Added:</h4><p>\n"; | |||||||||||||||||||||||||||||||
| 715 | } | ||||||||||||||||||||||||||||||||
| 716 | # format each unique result. | ||||||||||||||||||||||||||||||||
| 717 | 0 | ▶ | for ($i=0; $i < $n; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 718 | 0 | $url = $new_weekly_url[$i]; | |||||||||||||||||||||||||||||||
| 719 | 0 | $title = $new_weekly_title[$i]; | |||||||||||||||||||||||||||||||
| 720 | 0 | $description = $new_weekly_description[$i]; | |||||||||||||||||||||||||||||||
| 721 | 0 | my $sHTMLlink = &make_link($AppendedTemplate, $url, $title, $description); | |||||||||||||||||||||||||||||||
| 722 | 0 | print HTML "$sHTMLlink\n"; | |||||||||||||||||||||||||||||||
| 723 | # print STDERR " DDD search is $search\n"; | ||||||||||||||||||||||||||||||||
| 724 | 0 | $sEmail .= q{<P>}. $search->result_as_HTML($aoResult[$i], '%Y-%m-%d %H:%M %Z'); | |||||||||||||||||||||||||||||||
| 725 | } # for | ||||||||||||||||||||||||||||||||
| 726 | 0 | print HTML "<!--/Appended-->"; # replace due to split | |||||||||||||||||||||||||||||||
| 727 | 0 | print HTML $part3; | |||||||||||||||||||||||||||||||
| 728 | 0 | $n = $#suspended_url + 1; | |||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | if ($n) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 730 | 0 | print HTML "<!--less...-->\n"; | |||||||||||||||||||||||||||||||
| 731 | 0 | print HTML "<h4>Recently Suspended:</h4><p>\n"; | |||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||
| 733 | # format each suspended result. | ||||||||||||||||||||||||||||||||
| 734 | 0 | ▶ | for ($i=0; $i < $n; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 735 | 0 | $url = $suspended_url[$i]; | |||||||||||||||||||||||||||||||
| 736 | 0 | $title = $suspended_title[$i]; | |||||||||||||||||||||||||||||||
| 737 | 0 | print HTML &make_link($SuspendedTemplate,$url,$title,""),"\n"; | |||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||
| 739 | 0 | print HTML "<!--/Suspended-->"; # replace due to split | |||||||||||||||||||||||||||||||
| 740 | 0 | print HTML $part4; | |||||||||||||||||||||||||||||||
| 741 | 0 | close (HTML); | |||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||
| 743 | else | ||||||||||||||||||||||||||||||||
| 744 | { # create the file | ||||||||||||||||||||||||||||||||
| 745 | # print STDERR "make new weekly file.\n" if ($v_dbg); | ||||||||||||||||||||||||||||||||
| 746 | 0 | ▶ | open (HTML,'>'.$qid.$file) || die "Can't open weekly output file.\nReason: $!\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 747 | 0 | print HTML $sTitle; | |||||||||||||||||||||||||||||||
| 748 | 0 | print HTML "<!-- created by AutoSearch.pl by wls -->\n"; | |||||||||||||||||||||||||||||||
| 749 | 0 | print HTML "<!--Top-->\n$WeeklyTop<!--/Top-->\n"; | |||||||||||||||||||||||||||||||
| 750 | 0 | DEBUG_EMAIL && print STDERR " + start creating email, new_weekly_url is ", Dumper(\@new_weekly_url); | |||||||||||||||||||||||||||||||
| 751 | # Output weekly search status: appended | ||||||||||||||||||||||||||||||||
| 752 | 0 | $iNewResultCount = $#new_weekly_url + 1; | |||||||||||||||||||||||||||||||
| 753 | # Always do the header: | ||||||||||||||||||||||||||||||||
| 754 | 0 | print HTML "<!--AppendedHeading\n$AppendedHeading/AppendedHeading-->\n"; | |||||||||||||||||||||||||||||||
| 755 | 0 | ▶ | print HTML &format_link($AppendedHeading,"DATE", $now) if $iNewResultCount; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 756 | 0 | print HTML "<!--AppendedTemplate\n$AppendedTemplate/AppendedTemplate-->\n"; | |||||||||||||||||||||||||||||||
| 757 | 0 | $section = "Appended"; # the section of the file/output. | |||||||||||||||||||||||||||||||
| 758 | 0 | print HTML "<!--$section-->\n"; | |||||||||||||||||||||||||||||||
| 759 | # Format each unique result: | ||||||||||||||||||||||||||||||||
| 760 | 0 | for my $i (0..$iNewResultCount-1) | |||||||||||||||||||||||||||||||
| 761 | { | ||||||||||||||||||||||||||||||||
| 762 | 0 | $url = $new_weekly_url[$i]; | |||||||||||||||||||||||||||||||
| 763 | 0 | $title = $new_weekly_title[$i]; | |||||||||||||||||||||||||||||||
| 764 | 0 | $description = $new_weekly_description[$i]; | |||||||||||||||||||||||||||||||
| 765 | 0 | my $sHTMLlink = &make_link($AppendedTemplate, $url, $title, $description); | |||||||||||||||||||||||||||||||
| 766 | 0 | print HTML "$sHTMLlink\n"; | |||||||||||||||||||||||||||||||
| 767 | 0 | $sEmail .= q{<P>}. $search->result_as_HTML($aoResult[$i], '%Y-%m-%d %H:%M %Z'); | |||||||||||||||||||||||||||||||
| 768 | } # for $i | ||||||||||||||||||||||||||||||||
| 769 | 0 | print HTML $Appended; | |||||||||||||||||||||||||||||||
| 770 | 0 | print HTML "<!--/$section-->\n\n"; | |||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||
| 772 | # output weekly search status: suspended | ||||||||||||||||||||||||||||||||
| 773 | 0 | $n = $#suspended_url + 1; | |||||||||||||||||||||||||||||||
| 774 | # always do the heading | ||||||||||||||||||||||||||||||||
| 775 | 0 | print HTML "<!--SuspendedHeading\n$SuspendedHeading/SuspendedHeading-->\n"; | |||||||||||||||||||||||||||||||
| 776 | 0 | ▶ | print HTML &format_link($SuspendedHeading,"DATE","$now") if $n; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 777 | 0 | print HTML "<!--SuspendedTemplate\n$SuspendedTemplate/SuspendedTemplate-->\n"; | |||||||||||||||||||||||||||||||
| 778 | 0 | $section = "Suspended"; # the section of the file/output. | |||||||||||||||||||||||||||||||
| 779 | 0 | print HTML "<!--$section-->\n"; | |||||||||||||||||||||||||||||||
| 780 | 0 | ▶ | for ($i=0; $i < $n; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 781 | 0 | $url = $suspended_url[$i]; | |||||||||||||||||||||||||||||||
| 782 | 0 | $title = $suspended_title[$i]; | |||||||||||||||||||||||||||||||
| 783 | 0 | print HTML &make_link($SuspendedTemplate,$url,$title,""),"\n"; | |||||||||||||||||||||||||||||||
| 784 | } # for $i | ||||||||||||||||||||||||||||||||
| 785 | 0 | print HTML $Suspended; | |||||||||||||||||||||||||||||||
| 786 | 0 | print HTML "<!--/$section-->\n\n"; | |||||||||||||||||||||||||||||||
| 787 | 0 | print HTML "<!--Bottom-->\n$WeeklyBottom<!--/Bottom-->\n"; | |||||||||||||||||||||||||||||||
| 788 | 0 | close (HTML); | |||||||||||||||||||||||||||||||
| 789 | } # else daily file doesn't exist | ||||||||||||||||||||||||||||||||
| 790 | } # if any new hits | ||||||||||||||||||||||||||||||||
| 791 | else | ||||||||||||||||||||||||||||||||
| 792 | { | ||||||||||||||||||||||||||||||||
| 793 | 0 | ▶ | print STDERR "no weekly changes required.\n" if ($v_dbg); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 794 | } | ||||||||||||||||||||||||||||||||
| 795 | 0 | ▶ | $QueryName = $SummaryQuery if ($QueryName eq ''); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 796 | # Now write the new index file. | ||||||||||||||||||||||||||||||||
| 797 | # Create the index.html output file: | ||||||||||||||||||||||||||||||||
| 798 | 0 | ▶ | open (HTML,'>'.$qid.'index.html') || die "Can't open summary output file.\nReason: $!\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 799 | 0 | print HTML "<Title> Summary of Search results for $SummaryQuery</Title>\n"; | |||||||||||||||||||||||||||||||
| 800 | 0 | print HTML "<!-- created by AutoSearch.pl by wls -->\n"; | |||||||||||||||||||||||||||||||
| 801 | 0 | print HTML "<!--Top-->\n$SummaryTop<!--/Top-->\n"; | |||||||||||||||||||||||||||||||
| 802 | 0 | print HTML "<!--Query{$SummaryQuery}/Query-->\n"; | |||||||||||||||||||||||||||||||
| 803 | 0 | print HTML "<!--QueryName{$QueryName}/QueryName-->\n"; | |||||||||||||||||||||||||||||||
| 804 | 0 | ▶ | print HTML "<!--SearchEngine{$SummarySearchEngine}/SearchEngine-->\n" if ($SummarySearchEngine); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | print HTML "<!--URLFilter{$SummaryURLFilter}/URLFilter-->\n" if ($SummaryURLFilter); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 806 | 0 | foreach my $key (keys (%{$query_options})) { | |||||||||||||||||||||||||||||||
| 807 | # print STDERR "option::$key=$query_options->{$key}\n"; | ||||||||||||||||||||||||||||||||
| 808 | 0 | print HTML "<!--QueryOptions{$key\=$query_options->{$key}\}QueryOptions-->\n"; | |||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||
| 810 | # output summary of updated unique findings | ||||||||||||||||||||||||||||||||
| 811 | 0 | print HTML "<!--SummaryHeading\n$SummaryHeading/SummaryHeading-->\n"; | |||||||||||||||||||||||||||||||
| 812 | 0 | print HTML &format_link($SummaryHeading, "DATE", $now); | |||||||||||||||||||||||||||||||
| 813 | 0 | print HTML "<!--SummaryTemplate\n$SummaryTemplate/SummaryTemplate-->\n"; | |||||||||||||||||||||||||||||||
| 814 | 0 | $section = "Summary"; # the section of the file/output. | |||||||||||||||||||||||||||||||
| 815 | 0 | print HTML "<!--$section-->\n"; | |||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | if ($#new_weekly_url < 0) { # it has't changed; just re-cycle it. | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 817 | 0 | print HTML $Summary; | |||||||||||||||||||||||||||||||
| 818 | } else { | ||||||||||||||||||||||||||||||||
| 819 | # format each unique result. | ||||||||||||||||||||||||||||||||
| 820 | # $description = ""; | ||||||||||||||||||||||||||||||||
| 821 | 0 | $n = $#weekly_url + 1; | |||||||||||||||||||||||||||||||
| 822 | 0 | ▶ | for ($i=0; $i < $n; $i++) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 823 | 0 | $url = $weekly_url[$i]; | |||||||||||||||||||||||||||||||
| 824 | 0 | $title = $weekly_title[$i]; | |||||||||||||||||||||||||||||||
| 825 | 0 | print HTML &make_link($SummaryTemplate,$url,$title,""),"\n"; | |||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||
| 828 | # Output daily results status (none or ptr to new file). | ||||||||||||||||||||||||||||||||
| 829 | 0 | print HTML "<!--/$section-->\n\n"; | |||||||||||||||||||||||||||||||
| 830 | 0 | print HTML "<!--WeeklyHeading\n$WeeklyHeading/WeeklyHeading-->\n"; | |||||||||||||||||||||||||||||||
| 831 | 0 | print HTML &format_link($WeeklyHeading,"DATE", $now); | |||||||||||||||||||||||||||||||
| 832 | 0 | print HTML "<!--WeeklyTemplate\n$WeeklyTemplate/WeeklyTemplate-->\n"; | |||||||||||||||||||||||||||||||
| 833 | 0 | $section = "Weekly"; # the section of the file/output. | |||||||||||||||||||||||||||||||
| 834 | 0 | print HTML "<!--$section-->\n"; | |||||||||||||||||||||||||||||||
| 835 | # report errors FIRST. | ||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | if ($hits == 0) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 837 | { | ||||||||||||||||||||||||||||||||
| 838 | 0 | my($response) = $search->response(); | |||||||||||||||||||||||||||||||
| 839 | 0 | ▶ | if ($response->is_success) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 840 | { # dbg message, normally we're quiet | ||||||||||||||||||||||||||||||||
| 841 | # print HTML "AutoSearch Warning: Empty Results Set. <br>\n"; | ||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||
| 843 | else | ||||||||||||||||||||||||||||||||
| 844 | { # SearchEngine error message: | ||||||||||||||||||||||||||||||||
| 845 | 0 | my $sMsg = "AutoSearch Error during search on $today: " . http_error_as_nice_string($response); | |||||||||||||||||||||||||||||||
| 846 | 0 | print HTML "$sMsg<br>\n"; | |||||||||||||||||||||||||||||||
| 847 | 0 | $sEmail .= "$sMsg\n"; | |||||||||||||||||||||||||||||||
| 848 | } | ||||||||||||||||||||||||||||||||
| 849 | } # if no hits | ||||||||||||||||||||||||||||||||
| 850 | # Let's use reverse chronological order. | ||||||||||||||||||||||||||||||||
| 851 | # Update the 'weekly' status: | ||||||||||||||||||||||||||||||||
| 852 | 0 | ▶ | if ($changes) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 853 | { # there were changes. | ||||||||||||||||||||||||||||||||
| 854 | # second run today? | ||||||||||||||||||||||||||||||||
| 855 | 0 | ▶ | if ($Weekly =~ m/^No unique results found for(.*)$today/i) | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 856 | { | ||||||||||||||||||||||||||||||||
| 857 | # print STDERR "change 'No' to 'Yes'\n"; | ||||||||||||||||||||||||||||||||
| 858 | # The first line SHOULD be today's, assume so. | ||||||||||||||||||||||||||||||||
| 859 | # Delete first line of $Weekly and write new link: | ||||||||||||||||||||||||||||||||
| 860 | 0 | ($junk, $Weekly) = split (/\n/,$Weekly,2); # split off first line | |||||||||||||||||||||||||||||||
| 861 | 0 | print HTML "Web search results for <a href=\"$file\">search on ",$today,"</a><br>\n"; | |||||||||||||||||||||||||||||||
| 862 | } | ||||||||||||||||||||||||||||||||
| 863 | elsif ($Weekly =~ m/^AutoSearch Error during search on $today/i) | ||||||||||||||||||||||||||||||||
| 864 | { | ||||||||||||||||||||||||||||||||
| 865 | # print STDERR "change 'Error' to 'Yes'\n"; | ||||||||||||||||||||||||||||||||
| 866 | # The first line SHOULD be today's, assume so. | ||||||||||||||||||||||||||||||||
| 867 | # Delete first line of $Weekly and write new link: | ||||||||||||||||||||||||||||||||
| 868 | 0 | ($junk, $Weekly) = split(/\n/, $Weekly, 2); # split off first line | |||||||||||||||||||||||||||||||
| 869 | 0 | print HTML "Web search results for <a href=\"$file\">search on ",$today,"</a><br>\n"; | |||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||
| 871 | elsif ($Weekly =~ m/^Web search results for(.*)$today/) | ||||||||||||||||||||||||||||||||
| 872 | { # yes we already have a link, leave it. | ||||||||||||||||||||||||||||||||
| 873 | # print STDERR "leave 'Yes'\n"; | ||||||||||||||||||||||||||||||||
| 874 | } | ||||||||||||||||||||||||||||||||
| 875 | else | ||||||||||||||||||||||||||||||||
| 876 | { # no link for today of any kind. add one. | ||||||||||||||||||||||||||||||||
| 877 | # print STDERR "insert 'Yes'\n"; | ||||||||||||||||||||||||||||||||
| 878 | 0 | print HTML "Web search results for <a href=\"$file\">search on ",$today,"</a><br>\n"; | |||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||
| 880 | } # there were any $changes | ||||||||||||||||||||||||||||||||
| 881 | else | ||||||||||||||||||||||||||||||||
| 882 | { | ||||||||||||||||||||||||||||||||
| 883 | # second run today? | ||||||||||||||||||||||||||||||||
| 884 | 0 | ▶ | if ($Weekly =~ m/^No unique results found for(.*)$today/i) | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 885 | { | ||||||||||||||||||||||||||||||||
| 886 | # print STDERR "leave 'No'\n"; | ||||||||||||||||||||||||||||||||
| 887 | } | ||||||||||||||||||||||||||||||||
| 888 | elsif ($Weekly =~ m/^AutoSearch Error during search on $today/i) | ||||||||||||||||||||||||||||||||
| 889 | { | ||||||||||||||||||||||||||||||||
| 890 | # print STDERR "change 'Error' to 'No'\n"; | ||||||||||||||||||||||||||||||||
| 891 | # The first line SHOULD be today's, assume so. | ||||||||||||||||||||||||||||||||
| 892 | # Delete first line of $Weekly and write new link: | ||||||||||||||||||||||||||||||||
| 893 | 0 | ($junk, $Weekly) = split(/\n/, $Weekly, 2); # split off first line | |||||||||||||||||||||||||||||||
| 894 | 0 | print HTML "No unique results found for search on ",$today,"<br>\n"; | |||||||||||||||||||||||||||||||
| 895 | } | ||||||||||||||||||||||||||||||||
| 896 | elsif ($Weekly =~ m/^Web search results for(.*)$today/) | ||||||||||||||||||||||||||||||||
| 897 | { # We found results earlier today, leave them. | ||||||||||||||||||||||||||||||||
| 898 | # print STDERR "leave 'Yes'\n"; | ||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||
| 900 | else | ||||||||||||||||||||||||||||||||
| 901 | { | ||||||||||||||||||||||||||||||||
| 902 | # print STDERR "insert 'No'\n"; | ||||||||||||||||||||||||||||||||
| 903 | 0 | print HTML "No unique results found for search on ",$today,"<br>\n"; | |||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||
| 905 | } # there were no $changes | ||||||||||||||||||||||||||||||||
| 906 | 0 | print HTML $Weekly; | |||||||||||||||||||||||||||||||
| 907 | 0 | print HTML "<!--/$section-->\n\n"; | |||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||
| 909 | 0 | print HTML "<!--Bottom-->\n$SummaryBottom<!--/Bottom-->\n"; | |||||||||||||||||||||||||||||||
| 910 | 0 | close (HTML); | |||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||
| 912 | # DEBUG_EMAIL && print STDERR " + opts{m} =$opts{m}=\n"; | ||||||||||||||||||||||||||||||||
| 913 | # DEBUG_EMAIL && print " + raw sEmail =====$sEmail=====\n"; | ||||||||||||||||||||||||||||||||
| 914 | 0 | ▶ | if (($opts{'m'} ne '') && ($sEmail ne '')) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opts{"m"} ne "" and $sEmail ne ""
MC/DC0%0/2
$opts{"m"} ne "" and $sEmail ne ""
$opts{"m"} ne ""
$sEmail ne ""
Truth table0%0/3
A and B
A= $opts{"m"} ne ""B= $sEmail ne ""
| |||||||||||||||||||||||||||||||||
| 915 | { | ||||||||||||||||||||||||||||||||
| 916 | 0 | $sEmail = <<"EMAILEND"; | |||||||||||||||||||||||||||||||
| 917 | <HTML> | ||||||||||||||||||||||||||||||||
| 918 | <HEAD>$sTitle</HEAD> | ||||||||||||||||||||||||||||||||
| 919 | <BODY> | ||||||||||||||||||||||||||||||||
| 920 | <h2>The following $iNewResultCount URLs are new matches for your $SummarySearchEngine query '$SummaryQuery':</h2> | ||||||||||||||||||||||||||||||||
| 921 | $sEmail | ||||||||||||||||||||||||||||||||
| 922 | </BODY></HTML> | ||||||||||||||||||||||||||||||||
| 923 | EMAILEND | ||||||||||||||||||||||||||||||||
| 924 | # DEBUG_EMAIL && print STDERR " + cooked sEmail =====$sEmail=====\n"; | ||||||||||||||||||||||||||||||||
| 925 | # DEBUG_EMAIL && exit 88; | ||||||||||||||||||||||||||||||||
| 926 | 0 | my $sSubject = "Results of AutoSearch query '$SummaryQuery'"; | |||||||||||||||||||||||||||||||
| 927 | 0 | my $sFrom = 'AutoSearch@localhost'; | |||||||||||||||||||||||||||||||
| 928 | 0 | ▶ | $sFrom = $opts{emailfrom} if ($opts{emailfrom} ne ''); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 929 | my $oMsg = Email::MIME->create( | ||||||||||||||||||||||||||||||||
| 930 | header => [ | ||||||||||||||||||||||||||||||||
| 931 | 0 | To => $opts{'m'}, | |||||||||||||||||||||||||||||||
| 932 | Subject => $sSubject, | ||||||||||||||||||||||||||||||||
| 933 | From => $sFrom, | ||||||||||||||||||||||||||||||||
| 934 | ], | ||||||||||||||||||||||||||||||||
| 935 | attributes => { | ||||||||||||||||||||||||||||||||
| 936 | 'content_type' => 'text/html', | ||||||||||||||||||||||||||||||||
| 937 | }, | ||||||||||||||||||||||||||||||||
| 938 | body => $sEmail, | ||||||||||||||||||||||||||||||||
| 939 | ); | ||||||||||||||||||||||||||||||||
| 940 | 0 | DEBUG_EMAIL && print STDERR " + oMsg is ", Dumper($oMsg); | |||||||||||||||||||||||||||||||
| 941 | 0 | ▶ | if (ref($oMsg)) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 942 | { | ||||||||||||||||||||||||||||||||
| 943 | 0 | DEBUG_EMAIL && print STDERR " + oMsg in sendable format is:\n"; | |||||||||||||||||||||||||||||||
| 944 | 0 | DEBUG_EMAIL && Email::Send::send(IO => $oMsg); | |||||||||||||||||||||||||||||||
| 945 | 0 | my $sRes = &send_email($oMsg); | |||||||||||||||||||||||||||||||
| 946 | 0 | ▶ | print STDERR "result of send_email() is ==$sRes=\n" if ($v_dbg || ($sRes ne '1')); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$v_dbg or $sRes ne 1
MC/DC0%0/2
$v_dbg or $sRes ne 1
$v_dbg
$sRes ne 1
Truth table0%0/3
A or B
A= $v_dbgB= $sRes ne 1
| |||||||||||||||||||||||||||||||||
| 947 | # print STDERR $sRes if ($v_dbg || ($sRes ne '1')); | ||||||||||||||||||||||||||||||||
| 948 | } | ||||||||||||||||||||||||||||||||
| 949 | else | ||||||||||||||||||||||||||||||||
| 950 | { | ||||||||||||||||||||||||||||||||
| 951 | 0 | print STDERR " --- could not create Email::MIME object\n"; | |||||||||||||||||||||||||||||||
| 952 | } | ||||||||||||||||||||||||||||||||
| 953 | } # if | ||||||||||||||||||||||||||||||||
| 954 | } # main | ||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||
| 956 | sub send_email | ||||||||||||||||||||||||||||||||
| 957 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
send_email: not called CC=19 SCAR=59.4
| |||||||||||||||||||||||||||||||||
| 958 | 0 | my $oMessage = shift; | |||||||||||||||||||||||||||||||
| 959 | 0 | ▶ | my $sSMTPserver = $ENV{SMTPSERVER} || shift || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/5
$ENV{'SMTPSERVER'} || shift() || ''
$ENV{"SMTPSERVER"} or shift()
MC/DC0%0/2
$ENV{'SMTPSERVER'} || shift() || ''
$ENV{"SMTPSERVER"}
shift()
Truth table0%0/3
A or B
A= $ENV{"SMTPSERVER"}B= shift()
| |||||||||||||||||||||||||||||||||
| 960 | 0 | ▶ | if ($sSMTPserver ne '') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 961 | { | ||||||||||||||||||||||||||||||||
| 962 | 0 | ▶ | my $sUsername = $ENV{SMTPUSERNAME} || shift || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/5
$ENV{'SMTPUSERNAME'} || shift() || ''
$ENV{"SMTPUSERNAME"} or shift()
MC/DC0%0/2
$ENV{'SMTPUSERNAME'} || shift() || ''
$ENV{"SMTPUSERNAME"}
shift()
Truth table0%0/3
A or B
A= $ENV{"SMTPUSERNAME"}B= shift()
| |||||||||||||||||||||||||||||||||
| 963 | 0 | ▶ | my $sPassword = $ENV{SMTPPASSWORD} || shift || ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/5
$ENV{'SMTPPASSWORD'} || shift() || ''
$ENV{"SMTPPASSWORD"} or shift()
MC/DC0%0/2
$ENV{'SMTPPASSWORD'} || shift() || ''
$ENV{"SMTPPASSWORD"}
shift()
Truth table0%0/3
A or B
A= $ENV{"SMTPPASSWORD"}B= shift()
| |||||||||||||||||||||||||||||||||
| 964 | 0 | ▶ | if ($TESTONLY) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 965 | { | ||||||||||||||||||||||||||||||||
| 966 | 0 | ▶ | $sUsername = '<empty>' if ($sUsername eq ''); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 967 | 0 | ▶ | $sPassword = ($sPassword eq '') ? '<empty>' : '<hidden>'; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 968 | 0 | return qq{$0 chose method SMTP::Auth with server=$sSMTPserver, username=$sUsername, password=$sPassword}; | |||||||||||||||||||||||||||||||
| 969 | } # if | ||||||||||||||||||||||||||||||||
| 970 | 0 | return Email::Send::SMTP->send($oMessage, | |||||||||||||||||||||||||||||||
| 971 | Host => $sSMTPserver, | ||||||||||||||||||||||||||||||||
| 972 | username => $sUsername, | ||||||||||||||||||||||||||||||||
| 973 | password => $sPassword, | ||||||||||||||||||||||||||||||||
| 974 | ); | ||||||||||||||||||||||||||||||||
| 975 | } # if SMTP | ||||||||||||||||||||||||||||||||
| 976 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Email::Send::Qmail::QMAIL ne "qmail-inject" or $Email::Send::Qmail::QMAIL ne "qmail-inject"
MC/DC0%0/2
$Email::Send::Qmail::QMAIL ne "qmail-inject" or $Email::Send::Qmail::QMAIL ne "qmail-inject"
$Email::Send::Qmail::QMAIL ne "qmail-inject"
$Email::Send::Qmail::QMAIL ne "qmail-inject"
Truth table0%0/3
A or B
A= $Email::Send::Qmail::QMAIL ne "qmail-inject"B= $Email::Send::Qmail::QMAIL ne "qmail-inject"
| |||||||||||||||||||||||||||||||||
| 977 | # User has customized the pointer to the qmail program: | ||||||||||||||||||||||||||||||||
| 978 | ($Email::Send::Qmail::QMAIL ne 'qmail-inject') | ||||||||||||||||||||||||||||||||
| 979 | || | ||||||||||||||||||||||||||||||||
| 980 | # I hate that "used only once" warning: | ||||||||||||||||||||||||||||||||
| 981 | ($Email::Send::Qmail::QMAIL ne 'qmail-inject') | ||||||||||||||||||||||||||||||||
| 982 | # HOW else do we indicate in the environment that we want to use | ||||||||||||||||||||||||||||||||
| 983 | # Qmail? | ||||||||||||||||||||||||||||||||
| 984 | ) | ||||||||||||||||||||||||||||||||
| 985 | { | ||||||||||||||||||||||||||||||||
| 986 | 0 | ▶ | if ($TESTONLY) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 987 | { | ||||||||||||||||||||||||||||||||
| 988 | 0 | return qq{$0 chose method Qmail}; | |||||||||||||||||||||||||||||||
| 989 | } # if | ||||||||||||||||||||||||||||||||
| 990 | 0 | return Email::Send::Qmail::send($oMessage, @_); | |||||||||||||||||||||||||||||||
| 991 | } # if qmail | ||||||||||||||||||||||||||||||||
| 992 | # For undef warnings: | ||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | $ENV{SENDMAIL} ||= ''; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$ENV{"SENDMAIL"} ||= ""
MC/DC0%0/1
$ENV{"SENDMAIL"} ||= ""
$ENV{"SENDMAIL"}
Truth table0%0/2
A
A= $ENV{"SENDMAIL"}
| |||||||||||||||||||||||||||||||||
| 994 | 0 | ▶ | if ( | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$^O =~ /solaris/i or $^O =~ /linux/i
MC/DC0%0/2
$^O =~ /solaris/i or $^O =~ /linux/i
$^O =~ /solaris/i
$^O =~ /linux/i
Truth table0%0/3
A or B
A= $^O =~ /solaris/iB= $^O =~ /linux/i
| |||||||||||||||||||||||||||||||||
| 995 | ($^O =~ m!solaris!i) # A fair assumption? | ||||||||||||||||||||||||||||||||
| 996 | || | ||||||||||||||||||||||||||||||||
| 997 | ($^O =~ m!linux!i) # A fair assumption? | ||||||||||||||||||||||||||||||||
| 998 | ) | ||||||||||||||||||||||||||||||||
| 999 | { | ||||||||||||||||||||||||||||||||
| 1000 | # User has customized the pointer to the sendmail program: | ||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | if ($ENV{SENDMAIL} ne '') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1002 | { | ||||||||||||||||||||||||||||||||
| 1003 | 0 | $Email::Send::Sendmail::SENDMAIL = $Email::Send::Sendmail::SENDMAIL = $ENV{SENDMAIL}; | |||||||||||||||||||||||||||||||
| 1004 | } # if | ||||||||||||||||||||||||||||||||
| 1005 | 0 | ▶ | if ($TESTONLY) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1006 | { | ||||||||||||||||||||||||||||||||
| 1007 | 0 | return qq{$0 chose method Sendmail}; | |||||||||||||||||||||||||||||||
| 1008 | } # if | ||||||||||||||||||||||||||||||||
| 1009 | 0 | return Email::Send::Sendmail::send($oMessage, @_); | |||||||||||||||||||||||||||||||
| 1010 | } # if solaris or linux | ||||||||||||||||||||||||||||||||
| 1011 | 0 | return "Error: can not determine email send method\n"; | |||||||||||||||||||||||||||||||
| 1012 | } # send_email | ||||||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||||||
| 1015 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1016 | # | ||||||||||||||||||||||||||||||||
| 1017 | #check_index_file($qid) - insure the index.html file exists. | ||||||||||||||||||||||||||||||||
| 1018 | # | ||||||||||||||||||||||||||||||||
| 1019 | # | ||||||||||||||||||||||||||||||||
| 1020 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1021 | # | ||||||||||||||||||||||||||||||||
| 1022 | #If qid/index.html exists just return. | ||||||||||||||||||||||||||||||||
| 1023 | #Else create qid/ if necessary and call make_index | ||||||||||||||||||||||||||||||||
| 1024 | #to make the F<index.html> file. | ||||||||||||||||||||||||||||||||
| 1025 | # | ||||||||||||||||||||||||||||||||
| 1026 | #=cut | ||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||
| 1028 | 0 | ▶ | sub check_index_file { | ||||||||||||||||||||||||||||||
|
Subroutine
check_index_file: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 1029 | 0 | my ($qid) = @_; | |||||||||||||||||||||||||||||||
| 1030 | # do we have the necessary infrastructure? | ||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | if (open (FIRST,"<$qid/index.html") ) { # yes | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1032 | # OK, close it. | ||||||||||||||||||||||||||||||||
| 1033 | 0 | close (FIRST); | |||||||||||||||||||||||||||||||
| 1034 | } else { # no, make dir. | ||||||||||||||||||||||||||||||||
| 1035 | 0 | ▶ | if (mkdir ($qid, 0755) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | if ($! =~ m/file exists/i) { # already done | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1037 | 0 | die "Can't create directory $qid.\nReason $!"; | |||||||||||||||||||||||||||||||
| 1038 | } | ||||||||||||||||||||||||||||||||
| 1039 | } | ||||||||||||||||||||||||||||||||
| 1040 | 0 | ▶ | chmod 0755, $qid || die "Can't chmod directory $qid.\nReason $!"; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$qid || die("Can't chmod directory $qid.\nReason $!")
MC/DC0%0/1
$qid || die("Can't chmod directory $qid.\nReason $!")
$qid
Truth table0%0/2
A
A= $qid
| |||||||||||||||||||||||||||||||||
| 1041 | 0 | &make_index($qid); | |||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||
| 1043 | 0 | ▶ | print STDERR "index.html exists, " if $main::v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1044 | } # check_index_file | ||||||||||||||||||||||||||||||||
| 1045 | |||||||||||||||||||||||||||||||||
| 1046 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1047 | # | ||||||||||||||||||||||||||||||||
| 1048 | #check_date_file($qid) - insure the date.html file exists. | ||||||||||||||||||||||||||||||||
| 1049 | # | ||||||||||||||||||||||||||||||||
| 1050 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1051 | # | ||||||||||||||||||||||||||||||||
| 1052 | #If qid/date.html exists just return. | ||||||||||||||||||||||||||||||||
| 1053 | #Else create qid/ if necessary and call make_date | ||||||||||||||||||||||||||||||||
| 1054 | #to make the F<date.html> file. | ||||||||||||||||||||||||||||||||
| 1055 | # | ||||||||||||||||||||||||||||||||
| 1056 | #=cut | ||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||
| 1058 | 0 | ▶ | sub check_date_file { | ||||||||||||||||||||||||||||||
|
Subroutine
check_date_file: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 1059 | 0 | my($qid,$qn,$qs) = @_; | |||||||||||||||||||||||||||||||
| 1060 | # do we have the necessary infrastructure? | ||||||||||||||||||||||||||||||||
| 1061 | 0 | ▶ | if (open (FIRST,'<'.$qid."date.html") ) { # yes | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1062 | # OK, close it. | ||||||||||||||||||||||||||||||||
| 1063 | 0 | close (FIRST); | |||||||||||||||||||||||||||||||
| 1064 | } else { # no, make dir. | ||||||||||||||||||||||||||||||||
| 1065 | 0 | ▶ | if (mkdir ($qid, 0755) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1066 | 0 | ▶ | if ($! =~ m/file exists/i) { # already done | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1067 | 0 | die "Can't create directory $qid.\nReason $!"; | |||||||||||||||||||||||||||||||
| 1068 | } | ||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | chmod 0755, $qid || die "Can't chmod directory $qid.\nReason $!"; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$qid || die("Can't chmod directory $qid.\nReason $!")
MC/DC0%0/1
$qid || die("Can't chmod directory $qid.\nReason $!")
$qid
Truth table0%0/2
A
A= $qid
| |||||||||||||||||||||||||||||||||
| 1071 | 0 | &make_date($qid,$qn,$qs); | |||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||
| 1073 | 0 | ▶ | print STDERR "date exists, " if $main::v_dbg; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1074 | } | ||||||||||||||||||||||||||||||||
| 1075 | |||||||||||||||||||||||||||||||||
| 1076 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1077 | # | ||||||||||||||||||||||||||||||||
| 1078 | #read_query($prompt) - read a string from STDIN. | ||||||||||||||||||||||||||||||||
| 1079 | # | ||||||||||||||||||||||||||||||||
| 1080 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1081 | # | ||||||||||||||||||||||||||||||||
| 1082 | #read STDIN, with a prompt and backspace editing, until <return> | ||||||||||||||||||||||||||||||||
| 1083 | # | ||||||||||||||||||||||||||||||||
| 1084 | #=cut | ||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||
| 1086 | 0 | ▶ | sub read_query { | ||||||||||||||||||||||||||||||
|
Subroutine
read_query: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 1087 | 0 | my($prompt) = @_; | |||||||||||||||||||||||||||||||
| 1088 | 0 | my($query) = ''; | |||||||||||||||||||||||||||||||
| 1089 | 0 | my($c) = ''; | |||||||||||||||||||||||||||||||
| 1090 | 0 | my($oldfh) = select(STDOUT); $| =1; select ($oldfh); | |||||||||||||||||||||||||||||||
| 1091 | 0 | print $prompt; | |||||||||||||||||||||||||||||||
| 1092 | 0 | ▶ | while (read(STDIN,$c,1)) { # get a byte. | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1093 | # printf STDERR "%02x",ord($c); | ||||||||||||||||||||||||||||||||
| 1094 | 0 | ▶ | last if $c eq "\x0a"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1095 | 0 | ▶ | if ($c eq "\x08") { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1096 | 0 | chop ($query); | |||||||||||||||||||||||||||||||
| 1097 | 0 | next; | |||||||||||||||||||||||||||||||
| 1098 | } else { | ||||||||||||||||||||||||||||||||
| 1099 | 0 | $query .= $c; | |||||||||||||||||||||||||||||||
| 1100 | } | ||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||
| 1102 | # print STDERR "\ni see $query\n"; | ||||||||||||||||||||||||||||||||
| 1103 | 0 | return ($query); | |||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||
| 1106 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1107 | # | ||||||||||||||||||||||||||||||||
| 1108 | #read_query_list($prompt) - read a list from STDIN. | ||||||||||||||||||||||||||||||||
| 1109 | # | ||||||||||||||||||||||||||||||||
| 1110 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1111 | # | ||||||||||||||||||||||||||||||||
| 1112 | #read STDIN, with a prompt and backspace editing, until <blank-line> | ||||||||||||||||||||||||||||||||
| 1113 | # | ||||||||||||||||||||||||||||||||
| 1114 | #=cut | ||||||||||||||||||||||||||||||||
| 1115 | |||||||||||||||||||||||||||||||||
| 1116 | 0 | ▶ | sub read_query_list { | ||||||||||||||||||||||||||||||
|
Subroutine
read_query_list: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1117 | 0 | my($prompt) = @_; | |||||||||||||||||||||||||||||||
| 1118 | 0 | my(@query_list); | |||||||||||||||||||||||||||||||
| 1119 | my($s); | ||||||||||||||||||||||||||||||||
| 1120 | 0 | while (1) { | |||||||||||||||||||||||||||||||
| 1121 | 0 | $s = &read_query($prompt); | |||||||||||||||||||||||||||||||
| 1122 | 0 | ▶ | last unless ($s); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1123 | 0 | push(@query_list,$s); | |||||||||||||||||||||||||||||||
| 1124 | } | ||||||||||||||||||||||||||||||||
| 1125 | # print STDERR "\ni see $query_list\n"; | ||||||||||||||||||||||||||||||||
| 1126 | 0 | return (@query_list); | |||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||
| 1128 | |||||||||||||||||||||||||||||||||
| 1129 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1130 | # | ||||||||||||||||||||||||||||||||
| 1131 | #C<format_link($template,$field,$data)> - create hyper links from a template. | ||||||||||||||||||||||||||||||||
| 1132 | # | ||||||||||||||||||||||||||||||||
| 1133 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1134 | # | ||||||||||||||||||||||||||||||||
| 1135 | #Replace the $field with $data in the $template given. | ||||||||||||||||||||||||||||||||
| 1136 | #For example: | ||||||||||||||||||||||||||||||||
| 1137 | # print C<&format_link("Hello place.\n","place","world");> | ||||||||||||||||||||||||||||||||
| 1138 | #produces | ||||||||||||||||||||||||||||||||
| 1139 | # Hello world. | ||||||||||||||||||||||||||||||||
| 1140 | # | ||||||||||||||||||||||||||||||||
| 1141 | #Used to replace default strings in the default documents with | ||||||||||||||||||||||||||||||||
| 1142 | #user supplied information. | ||||||||||||||||||||||||||||||||
| 1143 | # | ||||||||||||||||||||||||||||||||
| 1144 | #=cut | ||||||||||||||||||||||||||||||||
| 1145 | |||||||||||||||||||||||||||||||||
| 1146 | # format by text replacement. | ||||||||||||||||||||||||||||||||
| 1147 | 0 | ▶ | sub format_link { | ||||||||||||||||||||||||||||||
|
Subroutine
format_link: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 1148 | 0 | my ($unformated,$field,$data) = @_; | |||||||||||||||||||||||||||||||
| 1149 | 0 | my ($temp) = $unformated; # start with unformated string. | |||||||||||||||||||||||||||||||
| 1150 | 0 | $temp =~ s/$field/$data/; # make the replacement. | |||||||||||||||||||||||||||||||
| 1151 | 0 | return ($temp); | |||||||||||||||||||||||||||||||
| 1152 | } | ||||||||||||||||||||||||||||||||
| 1153 | |||||||||||||||||||||||||||||||||
| 1154 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1155 | # | ||||||||||||||||||||||||||||||||
| 1156 | #C<make_link($template,$url,$title,$description)> - create url. | ||||||||||||||||||||||||||||||||
| 1157 | # | ||||||||||||||||||||||||||||||||
| 1158 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1159 | # | ||||||||||||||||||||||||||||||||
| 1160 | #Replace the URL, TITLE, and DESCRIPTION with $url, $title, and | ||||||||||||||||||||||||||||||||
| 1161 | #$description (respectively) in the $template given. | ||||||||||||||||||||||||||||||||
| 1162 | # | ||||||||||||||||||||||||||||||||
| 1163 | #Used to convert a url template to a hyper-link with title and description. | ||||||||||||||||||||||||||||||||
| 1164 | # | ||||||||||||||||||||||||||||||||
| 1165 | #=cut | ||||||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||||||
| 1167 | 0 | ▶ | sub make_link { | ||||||||||||||||||||||||||||||
|
Subroutine
make_link: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 1168 | 0 | my ($template,$url,$title,$description) = @_; | |||||||||||||||||||||||||||||||
| 1169 | 0 | my ($link) = $template; | |||||||||||||||||||||||||||||||
| 1170 | 0 | ▶ | $link =~ s/URL/$url/ if defined($url); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1171 | 0 | ▶ | $link =~ s/TITLE/$title/ if defined($title); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1172 | 0 | ▶ | $link =~ s/DESCRIPTION/$description/ if defined($description); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1173 | 0 | return ($link); | |||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||
| 1176 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1177 | # | ||||||||||||||||||||||||||||||||
| 1178 | #C<make_no_link($template,$url,$title,$description)> - create url. | ||||||||||||||||||||||||||||||||
| 1179 | # | ||||||||||||||||||||||||||||||||
| 1180 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1181 | # | ||||||||||||||||||||||||||||||||
| 1182 | #Replace the URL, TITLE, and DESCRIPTION with $url, $title, and | ||||||||||||||||||||||||||||||||
| 1183 | #$description (respectively) in the $template given. | ||||||||||||||||||||||||||||||||
| 1184 | # | ||||||||||||||||||||||||||||||||
| 1185 | #Used to convert a url template to a url with title and description. | ||||||||||||||||||||||||||||||||
| 1186 | # | ||||||||||||||||||||||||||||||||
| 1187 | #=cut | ||||||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||||||
| 1189 | 0 | ▶ | sub make_no_link { | ||||||||||||||||||||||||||||||
|
Subroutine
make_no_link: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 1190 | 0 | my ($template,$url,$title,$description) = @_; | |||||||||||||||||||||||||||||||
| 1191 | 0 | my ($link) = $template; | |||||||||||||||||||||||||||||||
| 1192 | 0 | ▶ | $link =~ s/URL/$url/ if defined($url); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1193 | 0 | ▶ | $link =~ s/TITLE/$title/ if defined($title); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1194 | 0 | ▶ | $link =~ s/DESCRIPTION/$description/ if defined($description); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1195 | 0 | return ($link); | |||||||||||||||||||||||||||||||
| 1196 | } | ||||||||||||||||||||||||||||||||
| 1197 | |||||||||||||||||||||||||||||||||
| 1198 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1199 | # | ||||||||||||||||||||||||||||||||
| 1200 | #C<get_weekly_parts($qid)> - break input file into sub-fields. | ||||||||||||||||||||||||||||||||
| 1201 | # | ||||||||||||||||||||||||||||||||
| 1202 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1203 | # | ||||||||||||||||||||||||||||||||
| 1204 | #Used to convert an input file into the data elements, template and headings | ||||||||||||||||||||||||||||||||
| 1205 | #required to build nice looking web pages. | ||||||||||||||||||||||||||||||||
| 1206 | # | ||||||||||||||||||||||||||||||||
| 1207 | #=cut | ||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||
| 1209 | # | ||||||||||||||||||||||||||||||||
| 1210 | # read top.html to get the basic format of the web pages. | ||||||||||||||||||||||||||||||||
| 1211 | # parts include Top, Topic, Appended, Suspended, Bottom | ||||||||||||||||||||||||||||||||
| 1212 | # sub-parts include Heading, Template, actual contents. | ||||||||||||||||||||||||||||||||
| 1213 | # these objects are identified and extracted from the | ||||||||||||||||||||||||||||||||
| 1214 | # complete file. The format for all derived documents | ||||||||||||||||||||||||||||||||
| 1215 | # is determined by this file. How the objects are combined | ||||||||||||||||||||||||||||||||
| 1216 | # to created dervied pages is determined by the software | ||||||||||||||||||||||||||||||||
| 1217 | # enclosed here-in. | ||||||||||||||||||||||||||||||||
| 1218 | # | ||||||||||||||||||||||||||||||||
| 1219 | 0 | ▶ | sub get_weekly_parts { | ||||||||||||||||||||||||||||||
|
Subroutine
get_weekly_parts: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1220 | 0 | my($qid) = @_; | |||||||||||||||||||||||||||||||
| 1221 | 0 | $/ = undef(); # enable paragraph mode. | |||||||||||||||||||||||||||||||
| 1222 | 0 | my($Top,$Bottom); | |||||||||||||||||||||||||||||||
| 1223 | 0 | my($AppendedHeading,$AppendedTemplate,$Appended); | |||||||||||||||||||||||||||||||
| 1224 | 0 | my($SuspendedHeading,$SuspendedTemplate,$Suspended); | |||||||||||||||||||||||||||||||
| 1225 | 0 | ▶ | open (PARTS,'<'.$qid.'date.html') || die "Can't open first date input file.\nReason: $!\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1226 | 0 | my($part) = <PARTS>; | |||||||||||||||||||||||||||||||
| 1227 | 0 | close (PARTS); | |||||||||||||||||||||||||||||||
| 1228 | # print STDERR "Part:\"$part\"\n"; | ||||||||||||||||||||||||||||||||
| 1229 | |||||||||||||||||||||||||||||||||
| 1230 | 0 | $Top = &get_pair_part($part,"Top"); | |||||||||||||||||||||||||||||||
| 1231 | |||||||||||||||||||||||||||||||||
| 1232 | 0 | $AppendedHeading = &get_part($part,"AppendedHeading"); | |||||||||||||||||||||||||||||||
| 1233 | 0 | $AppendedTemplate = &get_part($part,"AppendedTemplate"); | |||||||||||||||||||||||||||||||
| 1234 | 0 | $Appended = &get_pair_part($part,"Appended"); | |||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||
| 1236 | 0 | $SuspendedHeading = &get_part($part,"SuspendedHeading"); | |||||||||||||||||||||||||||||||
| 1237 | 0 | $SuspendedTemplate = &get_part($part,"SuspendedTemplate"); | |||||||||||||||||||||||||||||||
| 1238 | 0 | $Suspended = &get_pair_part($part,"Suspended"); | |||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||
| 1240 | 0 | $Bottom = &get_pair_part($part,"Bottom"); | |||||||||||||||||||||||||||||||
| 1241 | 0 | return($Top, | |||||||||||||||||||||||||||||||
| 1242 | $AppendedHeading,$AppendedTemplate,$Appended, | ||||||||||||||||||||||||||||||||
| 1243 | $SuspendedHeading,$SuspendedTemplate,$Suspended, | ||||||||||||||||||||||||||||||||
| 1244 | $Bottom); | ||||||||||||||||||||||||||||||||
| 1245 | } | ||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||
| 1247 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1248 | # | ||||||||||||||||||||||||||||||||
| 1249 | #C<get_summary_parts($qid)> - break input file into sub-fields. | ||||||||||||||||||||||||||||||||
| 1250 | # | ||||||||||||||||||||||||||||||||
| 1251 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1252 | # | ||||||||||||||||||||||||||||||||
| 1253 | #Used to convert an input file into the data elements, template and headings | ||||||||||||||||||||||||||||||||
| 1254 | #required to build nice looking web pages. | ||||||||||||||||||||||||||||||||
| 1255 | # | ||||||||||||||||||||||||||||||||
| 1256 | #=cut | ||||||||||||||||||||||||||||||||
| 1257 | |||||||||||||||||||||||||||||||||
| 1258 | 0 | ▶ | sub get_summary_parts { | ||||||||||||||||||||||||||||||
|
Subroutine
get_summary_parts: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1259 | 0 | my($qid) = @_; | |||||||||||||||||||||||||||||||
| 1260 | 0 | $/ = undef(); # enable paragraph mode. | |||||||||||||||||||||||||||||||
| 1261 | 0 | my($Top,$Query,$SearchEngine,@QueryOptions,$URLFilter,$Bottom); | |||||||||||||||||||||||||||||||
| 1262 | 0 | my($SummaryHeading,$SummaryTemplate,$Summary); | |||||||||||||||||||||||||||||||
| 1263 | 0 | my($WeeklyHeading,$WeeklyTemplate,$Weekly); | |||||||||||||||||||||||||||||||
| 1264 | 0 | ▶ | open (PARTS,'<'.$qid.'index.html') || die "Can't open index.html input file.\nReason: $!\n"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1265 | 0 | my($part) = <PARTS>; | |||||||||||||||||||||||||||||||
| 1266 | 0 | close (PARTS); | |||||||||||||||||||||||||||||||
| 1267 | # print STDERR "Part:\"$part\"\n"; | ||||||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||||||
| 1269 | 0 | $Top = &get_pair_part($part,"Top"); | |||||||||||||||||||||||||||||||
| 1270 | 0 | $Query = &get_inline_part($part,"Query"); | |||||||||||||||||||||||||||||||
| 1271 | 0 | $SearchEngine = &get_inline_part($part,"SearchEngine"); | |||||||||||||||||||||||||||||||
| 1272 | # get array of key=value pairs | ||||||||||||||||||||||||||||||||
| 1273 | 0 | @QueryOptions = &get_inline_list($part,"QueryOptions"); | |||||||||||||||||||||||||||||||
| 1274 | 0 | $URLFilter = &get_inline_part($part,"URLFilter"); | |||||||||||||||||||||||||||||||
| 1275 | |||||||||||||||||||||||||||||||||
| 1276 | 0 | $SummaryHeading = &get_part($part,"SummaryHeading"); | |||||||||||||||||||||||||||||||
| 1277 | 0 | $SummaryTemplate = &get_part($part,"SummaryTemplate"); | |||||||||||||||||||||||||||||||
| 1278 | 0 | $Summary = &get_pair_part($part,"Summary"); | |||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||
| 1280 | 0 | $WeeklyHeading = &get_part($part,"WeeklyHeading"); | |||||||||||||||||||||||||||||||
| 1281 | 0 | $WeeklyTemplate = &get_part($part,"WeeklyTemplate"); | |||||||||||||||||||||||||||||||
| 1282 | 0 | $Weekly = &get_pair_part($part,"Weekly"); | |||||||||||||||||||||||||||||||
| 1283 | |||||||||||||||||||||||||||||||||
| 1284 | 0 | $Bottom = &get_pair_part($part,"Bottom"); | |||||||||||||||||||||||||||||||
| 1285 | 0 | return($Top,$Query,$SearchEngine,$URLFilter, | |||||||||||||||||||||||||||||||
| 1286 | $SummaryHeading,$SummaryTemplate,$Summary, | ||||||||||||||||||||||||||||||||
| 1287 | $WeeklyHeading,$WeeklyTemplate,$Weekly, | ||||||||||||||||||||||||||||||||
| 1288 | $Bottom,@QueryOptions); | ||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||
| 1291 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1292 | # | ||||||||||||||||||||||||||||||||
| 1293 | #C<get_pair_part($part,$mark)> - locate and return sub-fields. | ||||||||||||||||||||||||||||||||
| 1294 | # | ||||||||||||||||||||||||||||||||
| 1295 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1296 | # | ||||||||||||||||||||||||||||||||
| 1297 | #Use regular expressions to locate <!--$mark--> and <!--/$mark--> and | ||||||||||||||||||||||||||||||||
| 1298 | #return everything in between (including <return>s). | ||||||||||||||||||||||||||||||||
| 1299 | # | ||||||||||||||||||||||||||||||||
| 1300 | #=cut | ||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||
| 1302 | # these objects are surrounded by <!--x--> <!--/x--> comments | ||||||||||||||||||||||||||||||||
| 1303 | # to be easily recognized; but always display.. | ||||||||||||||||||||||||||||||||
| 1304 | 0 | ▶ | sub get_pair_part { | ||||||||||||||||||||||||||||||
|
Subroutine
get_pair_part: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1305 | 0 | my($part,$mark) = @_; | |||||||||||||||||||||||||||||||
| 1306 | 0 | ▶ | if ($part =~ m,<!--$mark-->\n(.*)<!--/$mark-->,s) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1307 | # print STDERR "$mark: \"$1\"\n"; | ||||||||||||||||||||||||||||||||
| 1308 | 0 | return ($1); | |||||||||||||||||||||||||||||||
| 1309 | } | ||||||||||||||||||||||||||||||||
| 1310 | # print STDERR "Warning: can't find <!--$mark--> ... <--/$mark-->\n" if ($v_dbg); | ||||||||||||||||||||||||||||||||
| 1311 | 0 | return (""); | |||||||||||||||||||||||||||||||
| 1312 | } | ||||||||||||||||||||||||||||||||
| 1313 | |||||||||||||||||||||||||||||||||
| 1314 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1315 | # | ||||||||||||||||||||||||||||||||
| 1316 | #C<get_part($part,$mark)> - locate and return sub-fields. | ||||||||||||||||||||||||||||||||
| 1317 | # | ||||||||||||||||||||||||||||||||
| 1318 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1319 | # | ||||||||||||||||||||||||||||||||
| 1320 | #Use regular expressions to locate <!--$mark\n and /$mark--> and | ||||||||||||||||||||||||||||||||
| 1321 | #return everything in between (including <return>s). | ||||||||||||||||||||||||||||||||
| 1322 | # | ||||||||||||||||||||||||||||||||
| 1323 | #=cut | ||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||
| 1325 | # these objects are surrounded by similiar matching x /x marks. | ||||||||||||||||||||||||||||||||
| 1326 | # these objects are actually comments and won't be seen unless | ||||||||||||||||||||||||||||||||
| 1327 | # modified. | ||||||||||||||||||||||||||||||||
| 1328 | 0 | ▶ | sub get_part { | ||||||||||||||||||||||||||||||
|
Subroutine
get_part: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1329 | 0 | my($part,$mark) = @_; | |||||||||||||||||||||||||||||||
| 1330 | 0 | ▶ | if ($part =~ m,<!--$mark\n(.*)/$mark-->,s) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1331 | # print STDERR "$mark: \"$1\"\n"; | ||||||||||||||||||||||||||||||||
| 1332 | 0 | return ($1); | |||||||||||||||||||||||||||||||
| 1333 | } | ||||||||||||||||||||||||||||||||
| 1334 | # print STDERR "Warning: can't find <!--$mark\\n ... /$mark-->\n" if ($v_dbg); | ||||||||||||||||||||||||||||||||
| 1335 | 0 | return (""); | |||||||||||||||||||||||||||||||
| 1336 | } | ||||||||||||||||||||||||||||||||
| 1337 | |||||||||||||||||||||||||||||||||
| 1338 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1339 | # | ||||||||||||||||||||||||||||||||
| 1340 | #C<get_inline_part($part,$mark)> - locate and return sub-fields. | ||||||||||||||||||||||||||||||||
| 1341 | # | ||||||||||||||||||||||||||||||||
| 1342 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1343 | # | ||||||||||||||||||||||||||||||||
| 1344 | #Use regular expressions to locate <!--$mark{ and }/$mark--> and | ||||||||||||||||||||||||||||||||
| 1345 | #return everything in between. | ||||||||||||||||||||||||||||||||
| 1346 | # | ||||||||||||||||||||||||||||||||
| 1347 | #=cut | ||||||||||||||||||||||||||||||||
| 1348 | |||||||||||||||||||||||||||||||||
| 1349 | # these objects are surrounded by similiar matching x /x marks. | ||||||||||||||||||||||||||||||||
| 1350 | # these objects are actually comments and won't be seen unless | ||||||||||||||||||||||||||||||||
| 1351 | # modified. | ||||||||||||||||||||||||||||||||
| 1352 | 0 | ▶ | sub get_inline_part { | ||||||||||||||||||||||||||||||
|
Subroutine
get_inline_part: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||
| 1353 | 0 | my($part,$mark) = @_; | |||||||||||||||||||||||||||||||
| 1354 | 0 | ▶ | if ($part =~ m,<!--$mark\{(.*)\}/$mark-->,s) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1355 | # print STDERR "inline $mark: \{$1\}\n"; | ||||||||||||||||||||||||||||||||
| 1356 | 0 | return ($1); | |||||||||||||||||||||||||||||||
| 1357 | } | ||||||||||||||||||||||||||||||||
| 1358 | # print STDERR "Warning: can't find <!--$mark\{ ... \}/$mark-->\n" if ($v_dbg); | ||||||||||||||||||||||||||||||||
| 1359 | 0 | return (""); | |||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||
| 1363 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1364 | # | ||||||||||||||||||||||||||||||||
| 1365 | #C<get_inline_list($part,$mark)> - locate and return sub-fields. | ||||||||||||||||||||||||||||||||
| 1366 | # | ||||||||||||||||||||||||||||||||
| 1367 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1368 | # | ||||||||||||||||||||||||||||||||
| 1369 | #Use regular expressions to locate multiple occurances of | ||||||||||||||||||||||||||||||||
| 1370 | #<!--$mark{ and }/$mark--> and return them as a list. | ||||||||||||||||||||||||||||||||
| 1371 | # | ||||||||||||||||||||||||||||||||
| 1372 | #=cut | ||||||||||||||||||||||||||||||||
| 1373 | |||||||||||||||||||||||||||||||||
| 1374 | # these objects are surrounded by similiar matching x /x marks. | ||||||||||||||||||||||||||||||||
| 1375 | # these objects are actually comments and won't be seen unless | ||||||||||||||||||||||||||||||||
| 1376 | # modified. | ||||||||||||||||||||||||||||||||
| 1377 | 0 | ▶ | sub get_inline_list { | ||||||||||||||||||||||||||||||
|
Subroutine
get_inline_list: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||
| 1378 | 0 | my($part,$mark) = @_; | |||||||||||||||||||||||||||||||
| 1379 | 0 | ▶ | if ($part =~ m,<!--$mark\{(.*)\}/$mark-->,s) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1380 | 0 | my(@PARTS) = split(/\n/, $part); | |||||||||||||||||||||||||||||||
| 1381 | 0 | my(@LINES) = grep(m,<!--$mark\{(.*)\}/$mark-->,s, @PARTS); | |||||||||||||||||||||||||||||||
| 1382 | 0 | my(@LIST,$is); | |||||||||||||||||||||||||||||||
| 1383 | 0 | foreach (@LINES) { | |||||||||||||||||||||||||||||||
| 1384 | 0 | ▶ | next unless ($_ =~ m,<!--$mark\{(.*)\}/$mark-->,s); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1385 | # print STDERR "inline $mark: \{$1\}\n"; | ||||||||||||||||||||||||||||||||
| 1386 | 0 | push (@LIST,$1); | |||||||||||||||||||||||||||||||
| 1387 | } | ||||||||||||||||||||||||||||||||
| 1388 | 0 | return (@LIST); | |||||||||||||||||||||||||||||||
| 1389 | } | ||||||||||||||||||||||||||||||||
| 1390 | # print STDERR "Warning: can't find <!--$mark\{ ... \}/$mark-->\n" if ($v_dbg); | ||||||||||||||||||||||||||||||||
| 1391 | 0 | return (""); | |||||||||||||||||||||||||||||||
| 1392 | } | ||||||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||||||
| 1394 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1395 | # | ||||||||||||||||||||||||||||||||
| 1396 | #C<make_index($qid)> - make working copy of F<index.html>. | ||||||||||||||||||||||||||||||||
| 1397 | # | ||||||||||||||||||||||||||||||||
| 1398 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1399 | # | ||||||||||||||||||||||||||||||||
| 1400 | #Create F<qid/index.html> from either F<first_index.html> | ||||||||||||||||||||||||||||||||
| 1401 | #or from 'memory'. | ||||||||||||||||||||||||||||||||
| 1402 | # | ||||||||||||||||||||||||||||||||
| 1403 | #=cut | ||||||||||||||||||||||||||||||||
| 1404 | |||||||||||||||||||||||||||||||||
| 1405 | # check the root directory for default first_index file; | ||||||||||||||||||||||||||||||||
| 1406 | # else make one of our own. | ||||||||||||||||||||||||||||||||
| 1407 | 0 | ▶ | sub make_index { | ||||||||||||||||||||||||||||||
|
Subroutine
make_index: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||
| 1408 | 0 | my ($qid) = @_; | |||||||||||||||||||||||||||||||
| 1409 | 0 | ▶ | open (INDEX, ">$qid/index.html") || die "Can't create index.html in $qid\nReason $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1410 | # copy user-provided file... | ||||||||||||||||||||||||||||||||
| 1411 | 0 | ▶ | if (open (DEFAULT, "<$qid/../first_index.html") ) { # look for a default | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1412 | # copy in default provided by user. | ||||||||||||||||||||||||||||||||
| 1413 | 0 | ▶ | while (<DEFAULT>) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1414 | 0 | print INDEX $_; | |||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||
| 1416 | 0 | ▶ | close (DEFAULT) || die "Can't close file $qid/../first_index.html: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1417 | 0 | ▶ | close (INDEX) || die "Can't close file $qid/index.html: $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1418 | 0 | return; | |||||||||||||||||||||||||||||||
| 1419 | } | ||||||||||||||||||||||||||||||||
| 1420 | # or OUR provided file | ||||||||||||||||||||||||||||||||
| 1421 | 0 | my($it) = <<EOF; | |||||||||||||||||||||||||||||||
| 1422 | <HEAD> | ||||||||||||||||||||||||||||||||
| 1423 | <Title> index.html empty page to establish summary file format </Title> | ||||||||||||||||||||||||||||||||
| 1424 | </HEAD> | ||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||
| 1426 | <BODY> | ||||||||||||||||||||||||||||||||
| 1427 | <!--Top--> | ||||||||||||||||||||||||||||||||
| 1428 | <!--Place the html to make your page start to look nice here--> | ||||||||||||||||||||||||||||||||
| 1429 | <!--In the next line place the pretty name of the query.--> | ||||||||||||||||||||||||||||||||
| 1430 | <h1>AutoSearch WEB Searching</h1> | ||||||||||||||||||||||||||||||||
| 1431 | <!--/Top--> | ||||||||||||||||||||||||||||||||
| 1432 | |||||||||||||||||||||||||||||||||
| 1433 | <!--In the next line place the actual query.--> | ||||||||||||||||||||||||||||||||
| 1434 | <!--Query{ask user}/Query--> | ||||||||||||||||||||||||||||||||
| 1435 | <!--In the next line place the actual search engine.--> | ||||||||||||||||||||||||||||||||
| 1436 | <!--SearchEngine{Null}/SearchEngine--> | ||||||||||||||||||||||||||||||||
| 1437 | <!--In the next line(s) place the query/search engine specific options.--> | ||||||||||||||||||||||||||||||||
| 1438 | <!--QueryOptions{}/QueryOptions--> | ||||||||||||||||||||||||||||||||
| 1439 | <!--In the next line place the actual url filter.--> | ||||||||||||||||||||||||||||||||
| 1440 | <!--URLFilter{}/URLFilter--> | ||||||||||||||||||||||||||||||||
| 1441 | |||||||||||||||||||||||||||||||||
| 1442 | <!--SummaryHeading | ||||||||||||||||||||||||||||||||
| 1443 | <h3>Summary of WEB search results</h3><p> | ||||||||||||||||||||||||||||||||
| 1444 | /SummaryHeading--> | ||||||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||||||
| 1446 | <!--The list of unique 'hits' including a url and title.--> | ||||||||||||||||||||||||||||||||
| 1447 | <!--SummaryTemplate | ||||||||||||||||||||||||||||||||
| 1448 | <a href="URL">TITLE</a><br> | ||||||||||||||||||||||||||||||||
| 1449 | /SummaryTemplate--> | ||||||||||||||||||||||||||||||||
| 1450 | |||||||||||||||||||||||||||||||||
| 1451 | <!--Summary--> | ||||||||||||||||||||||||||||||||
| 1452 | <!--the list of unique 'hits' goes here.--> | ||||||||||||||||||||||||||||||||
| 1453 | <!--/Summary--> | ||||||||||||||||||||||||||||||||
| 1454 | |||||||||||||||||||||||||||||||||
| 1455 | <!--WeeklyHeading | ||||||||||||||||||||||||||||||||
| 1456 | <hr> | ||||||||||||||||||||||||||||||||
| 1457 | <h3>Weekly Search Results</h3><p> | ||||||||||||||||||||||||||||||||
| 1458 | /WeeklyHeading--> | ||||||||||||||||||||||||||||||||
| 1459 | |||||||||||||||||||||||||||||||||
| 1460 | <!--The list of 'hits' including a url and title.--> | ||||||||||||||||||||||||||||||||
| 1461 | <!--WeeklyTemplate | ||||||||||||||||||||||||||||||||
| 1462 | <a href="URL">TITLE</a><br> | ||||||||||||||||||||||||||||||||
| 1463 | /WeeklyTemplate--> | ||||||||||||||||||||||||||||||||
| 1464 | |||||||||||||||||||||||||||||||||
| 1465 | <!--Weekly--> | ||||||||||||||||||||||||||||||||
| 1466 | <!--the list of weekly results goes here.--> | ||||||||||||||||||||||||||||||||
| 1467 | <!--/Weekly--> | ||||||||||||||||||||||||||||||||
| 1468 | |||||||||||||||||||||||||||||||||
| 1469 | <!--Bottom--> | ||||||||||||||||||||||||||||||||
| 1470 | <!--Place the html to make your page finish up sharply here--> | ||||||||||||||||||||||||||||||||
| 1471 | <p> | ||||||||||||||||||||||||||||||||
| 1472 | Last modified October 17, 1996. | ||||||||||||||||||||||||||||||||
| 1473 | <!--/Bottom--> | ||||||||||||||||||||||||||||||||
| 1474 | </BODY> | ||||||||||||||||||||||||||||||||
| 1475 | EOF | ||||||||||||||||||||||||||||||||
| 1476 | |||||||||||||||||||||||||||||||||
| 1477 | 0 | print INDEX $it; | |||||||||||||||||||||||||||||||
| 1478 | 0 | close(INDEX); | |||||||||||||||||||||||||||||||
| 1479 | } | ||||||||||||||||||||||||||||||||
| 1480 | |||||||||||||||||||||||||||||||||
| 1481 | #=head1 NAME | ||||||||||||||||||||||||||||||||
| 1482 | # | ||||||||||||||||||||||||||||||||
| 1483 | #make_date($qid) - make working copy of F<date.html>. | ||||||||||||||||||||||||||||||||
| 1484 | # | ||||||||||||||||||||||||||||||||
| 1485 | #=head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1486 | # | ||||||||||||||||||||||||||||||||
| 1487 | #Create F<qid/date.html> from either F<first_date.html> | ||||||||||||||||||||||||||||||||
| 1488 | #or from 'memory'. | ||||||||||||||||||||||||||||||||
| 1489 | # | ||||||||||||||||||||||||||||||||
| 1490 | #=cut | ||||||||||||||||||||||||||||||||
| 1491 | |||||||||||||||||||||||||||||||||
| 1492 | # check the root directory for default first_date file; | ||||||||||||||||||||||||||||||||
| 1493 | # else make one of our own. | ||||||||||||||||||||||||||||||||
| 1494 | 0 | ▶ | sub make_date { | ||||||||||||||||||||||||||||||
|
Subroutine
make_date: not called CC=10 SCAR=47.0
| |||||||||||||||||||||||||||||||||
| 1495 | 0 | my($qid,$qn,$qs) = @_; | |||||||||||||||||||||||||||||||
| 1496 | 0 | ▶ | open (FIRST,'>'.$qid."date.html") || die "Can't create date in $qid\nReason $!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1497 | # copy user-provided file... | ||||||||||||||||||||||||||||||||
| 1498 | 0 | ▶ | if (open (DEFAULT,'<'.$qid."../first_date.html") ) { # look for a default | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1499 | # copy in default provided by user. | ||||||||||||||||||||||||||||||||
| 1500 | 0 | ▶ | while (<DEFAULT>) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1501 | 0 | ▶ | s/{ask user}/\{$qs\}/ if (m,Query\{ask user\}/Query,); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1502 | 0 | ▶ | s/AutoSearch WEB Searching/$qn/ if (m,AutoSearch WEB Searching,); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1503 | 0 | print FIRST $_; | |||||||||||||||||||||||||||||||
| 1504 | } | ||||||||||||||||||||||||||||||||
| 1505 | 0 | ▶ | close (DEFAULT) || die "Can't close default first_date.html file.\nReason:$!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1506 | 0 | ▶ | close (FIRST) || die "Can't close date.html file.\nReason:$!"; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1507 | 0 | return; | |||||||||||||||||||||||||||||||
| 1508 | } | ||||||||||||||||||||||||||||||||
| 1509 | # or OUR provided file | ||||||||||||||||||||||||||||||||
| 1510 | 0 | my($it) = <<EOF; | |||||||||||||||||||||||||||||||
| 1511 | <HEAD> | ||||||||||||||||||||||||||||||||
| 1512 | <Title> first_date.html empty page to establish weekly file format </Title> | ||||||||||||||||||||||||||||||||
| 1513 | </HEAD> | ||||||||||||||||||||||||||||||||
| 1514 | |||||||||||||||||||||||||||||||||
| 1515 | <BODY> | ||||||||||||||||||||||||||||||||
| 1516 | <!--Top--> | ||||||||||||||||||||||||||||||||
| 1517 | <!--Place the html to make your page start to look nice here--> | ||||||||||||||||||||||||||||||||
| 1518 | <!--In the next line place the pretty name of the query.--> | ||||||||||||||||||||||||||||||||
| 1519 | <h1>AutoSearch WEB Searching</h1> | ||||||||||||||||||||||||||||||||
| 1520 | <!--/Top--> | ||||||||||||||||||||||||||||||||
| 1521 | |||||||||||||||||||||||||||||||||
| 1522 | <!--The Title of the search results. 'DATE' will be replaced with the date.--> | ||||||||||||||||||||||||||||||||
| 1523 | <!--AppendedHeading | ||||||||||||||||||||||||||||||||
| 1524 | <h3>Web Search Results for DATE</h3><p> | ||||||||||||||||||||||||||||||||
| 1525 | /AppendedHeading--> | ||||||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||||||
| 1527 | <!--The list of 'hits' including a url, title and description.--> | ||||||||||||||||||||||||||||||||
| 1528 | <!--AppendedTemplate | ||||||||||||||||||||||||||||||||
| 1529 | <a href="URL">TITLE</a><br> | ||||||||||||||||||||||||||||||||
| 1530 | DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1531 | /AppendedTemplate--> | ||||||||||||||||||||||||||||||||
| 1532 | |||||||||||||||||||||||||||||||||
| 1533 | <!--Appended--> | ||||||||||||||||||||||||||||||||
| 1534 | <!--the list of 'hits' goes here.--> | ||||||||||||||||||||||||||||||||
| 1535 | <!--/Appended--> | ||||||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||||||
| 1537 | <!--SuspendedHeading | ||||||||||||||||||||||||||||||||
| 1538 | <hr> | ||||||||||||||||||||||||||||||||
| 1539 | <h3>URLs Apparently Suspended</h3><p> | ||||||||||||||||||||||||||||||||
| 1540 | /SuspendedHeading--> | ||||||||||||||||||||||||||||||||
| 1541 | |||||||||||||||||||||||||||||||||
| 1542 | <!--The list of 'misses' only the title.--> | ||||||||||||||||||||||||||||||||
| 1543 | <!--SuspendedTemplate | ||||||||||||||||||||||||||||||||
| 1544 | TITLE<br> | ||||||||||||||||||||||||||||||||
| 1545 | /SuspendedTemplate--> | ||||||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||||||
| 1547 | <!--Suspended--> | ||||||||||||||||||||||||||||||||
| 1548 | <!--the list of 'misses' goes here.--> | ||||||||||||||||||||||||||||||||
| 1549 | <!--/Suspended--> | ||||||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||||||
| 1551 | <!--Bottom--> | ||||||||||||||||||||||||||||||||
| 1552 | <!--Place the html to make your page finish up sharply here--> | ||||||||||||||||||||||||||||||||
| 1553 | <p> | ||||||||||||||||||||||||||||||||
| 1554 | Web searches maintained by <a href="http://www.isi.edu/lsam/tools/autosearch">AutoSearch</a>. | ||||||||||||||||||||||||||||||||
| 1555 | <!--/Bottom--> | ||||||||||||||||||||||||||||||||
| 1556 | </BODY> | ||||||||||||||||||||||||||||||||
| 1557 | EOF | ||||||||||||||||||||||||||||||||
| 1558 | 0 | ▶ | $it =~ s/{ask user}/\{$qs\}/ if ($it =~ m,Query\{ask user\}/Query,); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1559 | 0 | ▶ | $it =~ s/AutoSearch WEB Searching/$qn/ if ($it =~ m,AutoSearch WEB Searching,); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 1560 | 0 | print FIRST $it; | |||||||||||||||||||||||||||||||
| 1561 | 0 | close(FIRST); | |||||||||||||||||||||||||||||||
| 1562 | } | ||||||||||||||||||||||||||||||||
| 1563 | |||||||||||||||||||||||||||||||||
| 1564 | 0 | ▶ | sub time_now { | ||||||||||||||||||||||||||||||
|
Subroutine
time_now: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 1565 | 0 | return strftime("%m/%d/%Y %H:%M:%S", localtime(time)); | |||||||||||||||||||||||||||||||
| 1566 | } | ||||||||||||||||||||||||||||||||
| 1567 | |||||||||||||||||||||||||||||||||
| 1568 | 0 | ▶ | sub time_today { | ||||||||||||||||||||||||||||||
|
Subroutine
time_today: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 1569 | 0 | return strftime("%b %d, %Y", localtime(time)); | |||||||||||||||||||||||||||||||
| 1570 | } | ||||||||||||||||||||||||||||||||
| 1571 | |||||||||||||||||||||||||||||||||
| 1572 | 0 | ▶ | sub time_file_of_the_day_numeric { | ||||||||||||||||||||||||||||||
|
Subroutine
time_file_of_the_day_numeric: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 1573 | 0 | return strftime("%Y%m%d", localtime(time)); | |||||||||||||||||||||||||||||||
| 1574 | } | ||||||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||||||
| 1576 | |||||||||||||||||||||||||||||||||
| 1577 | 0 | ▶ | sub http_error_as_nice_string { | ||||||||||||||||||||||||||||||
|
Subroutine
http_error_as_nice_string: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 1578 | 0 | my($response) = @_; | |||||||||||||||||||||||||||||||
| 1579 | 0 | my($message) = $response->message(); | |||||||||||||||||||||||||||||||
| 1580 | 0 | my($code) = $response->code(); | |||||||||||||||||||||||||||||||
| 1581 | 0 | chomp($message); | |||||||||||||||||||||||||||||||
| 1582 | 0 | return "$message (code $code)"; | |||||||||||||||||||||||||||||||
| 1583 | } | ||||||||||||||||||||||||||||||||
| 1584 | |||||||||||||||||||||||||||||||||
| 1585 | sub add_to_hash | ||||||||||||||||||||||||||||||||
| 1586 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
add_to_hash: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||
| 1587 | # This is a bit of a hack. A set of CGI options is not strictly a | ||||||||||||||||||||||||||||||||
| 1588 | # hash, because multiple values for the same key can be specified. | ||||||||||||||||||||||||||||||||
| 1589 | # To get around this, we rely on the fact that this hash of options | ||||||||||||||||||||||||||||||||
| 1590 | # is only used to construct a CGI parameter list. If we see | ||||||||||||||||||||||||||||||||
| 1591 | # multiple values for the same key, we append the multiple values | ||||||||||||||||||||||||||||||||
| 1592 | # onto the value of the key in CGI '?key=value' format. | ||||||||||||||||||||||||||||||||
| 1593 | 0 | my ($key, $value, $hashref) = @_; | |||||||||||||||||||||||||||||||
| 1594 | 0 | ▶ | if (exists($hashref->{$key}) && $hashref->{$key} ne '') | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $hashref->{$key} and $hashref->{$key} ne ""
MC/DC0%0/2
exists $hashref->{$key} and $hashref->{$key} ne ""
exists $hashref->{$key}
$hashref->{$key} ne ""
Truth table0%0/3
A and B
A= exists $hashref->{$key}B= $hashref->{$key} ne ""
| |||||||||||||||||||||||||||||||||
| 1595 | { | ||||||||||||||||||||||||||||||||
| 1596 | # There was already an option of this key given; append | ||||||||||||||||||||||||||||||||
| 1597 | # multiple values as CGI arguments: | ||||||||||||||||||||||||||||||||
| 1598 | 0 | $hashref->{$key} .= "&$key=$value"; | |||||||||||||||||||||||||||||||
| 1599 | } # if exists | ||||||||||||||||||||||||||||||||
| 1600 | else | ||||||||||||||||||||||||||||||||
| 1601 | { | ||||||||||||||||||||||||||||||||
| 1602 | # This is the only instance of this key; just insert the | ||||||||||||||||||||||||||||||||
| 1603 | # hash value: | ||||||||||||||||||||||||||||||||
| 1604 | 0 | $hashref->{$key} = $value; | |||||||||||||||||||||||||||||||
| 1605 | } | ||||||||||||||||||||||||||||||||
| 1606 | } # add_to_hash | ||||||||||||||||||||||||||||||||
| 1607 | |||||||||||||||||||||||||||||||||
| 1608 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1609 | |||||||||||||||||||||||||||||||||
| 1610 | B<AutoSearch> performs a web-based search and puts the results | ||||||||||||||||||||||||||||||||
| 1611 | set in F<qid/index.html>. | ||||||||||||||||||||||||||||||||
| 1612 | Subsequent searches (i.e., the second form above) | ||||||||||||||||||||||||||||||||
| 1613 | B<AutoSearch> determine what changes (if any) occured to the | ||||||||||||||||||||||||||||||||
| 1614 | results sent since the last run. | ||||||||||||||||||||||||||||||||
| 1615 | These incremental changes are recorded in F<qid/YYYYMMDD.html>. | ||||||||||||||||||||||||||||||||
| 1616 | |||||||||||||||||||||||||||||||||
| 1617 | B<AutoSearch> is amenable to be run as a B<cron> job because all | ||||||||||||||||||||||||||||||||
| 1618 | the input parameters are saved in the web pages. B<AutoSearch> | ||||||||||||||||||||||||||||||||
| 1619 | can act as a automated query agent for a particular search. The output | ||||||||||||||||||||||||||||||||
| 1620 | files are designed to be a set of web pages to easily display the | ||||||||||||||||||||||||||||||||
| 1621 | results set with a web browser. | ||||||||||||||||||||||||||||||||
| 1622 | |||||||||||||||||||||||||||||||||
| 1623 | Example: | ||||||||||||||||||||||||||||||||
| 1624 | |||||||||||||||||||||||||||||||||
| 1625 | AutoSearch -n 'LSAM Replication' | ||||||||||||||||||||||||||||||||
| 1626 | -s '"lsam replication"' | ||||||||||||||||||||||||||||||||
| 1627 | -e AltaVista | ||||||||||||||||||||||||||||||||
| 1628 | replication_query | ||||||||||||||||||||||||||||||||
| 1629 | |||||||||||||||||||||||||||||||||
| 1630 | This query (which should be all on one line) | ||||||||||||||||||||||||||||||||
| 1631 | creates a directory replication_query | ||||||||||||||||||||||||||||||||
| 1632 | and fills it with the fascinating output of the AltaVista query | ||||||||||||||||||||||||||||||||
| 1633 | on C<"lsam replication">, | ||||||||||||||||||||||||||||||||
| 1634 | with pages titled ``LSAM Replication''. | ||||||||||||||||||||||||||||||||
| 1635 | (Note the quoting: the single quotes in | ||||||||||||||||||||||||||||||||
| 1636 | C<'"lsam replication"'> are for the shell, | ||||||||||||||||||||||||||||||||
| 1637 | the double quotes are for AltaVista | ||||||||||||||||||||||||||||||||
| 1638 | to search for the phrase rather than the separate words.) | ||||||||||||||||||||||||||||||||
| 1639 | |||||||||||||||||||||||||||||||||
| 1640 | A more complicated example: | ||||||||||||||||||||||||||||||||
| 1641 | |||||||||||||||||||||||||||||||||
| 1642 | AutoSearch -n 'External Links to LSAM' | ||||||||||||||||||||||||||||||||
| 1643 | -s '(link:www.isi.edu/lsam or link:www.isi.edu/~lsam) -url:isi.edu' | ||||||||||||||||||||||||||||||||
| 1644 | -e AltaVista::AdvancedWeb | ||||||||||||||||||||||||||||||||
| 1645 | -o coolness=hot | ||||||||||||||||||||||||||||||||
| 1646 | |||||||||||||||||||||||||||||||||
| 1647 | This query does an advanced AltaVista search | ||||||||||||||||||||||||||||||||
| 1648 | and specifies the (hypothetical) ``coolness'' option | ||||||||||||||||||||||||||||||||
| 1649 | to the search engine. | ||||||||||||||||||||||||||||||||
| 1650 | |||||||||||||||||||||||||||||||||
| 1651 | =head1 OPTIONS | ||||||||||||||||||||||||||||||||
| 1652 | |||||||||||||||||||||||||||||||||
| 1653 | =over | ||||||||||||||||||||||||||||||||
| 1654 | |||||||||||||||||||||||||||||||||
| 1655 | =item C<qid> | ||||||||||||||||||||||||||||||||
| 1656 | |||||||||||||||||||||||||||||||||
| 1657 | The I<query identifer> specifies the directory in which all the | ||||||||||||||||||||||||||||||||
| 1658 | files that relate to this query and search results will live. | ||||||||||||||||||||||||||||||||
| 1659 | It can be an absolute path, or a relative path from cwd. | ||||||||||||||||||||||||||||||||
| 1660 | If the directory does not exist, it will be created and a new search started. | ||||||||||||||||||||||||||||||||
| 1661 | |||||||||||||||||||||||||||||||||
| 1662 | =item C<--stats> | ||||||||||||||||||||||||||||||||
| 1663 | |||||||||||||||||||||||||||||||||
| 1664 | Show search statistics: the query string, | ||||||||||||||||||||||||||||||||
| 1665 | number of hits, number of filtered hits, | ||||||||||||||||||||||||||||||||
| 1666 | filter string, number of suspended (deleted) hits, | ||||||||||||||||||||||||||||||||
| 1667 | previous set size, current set size, etc. | ||||||||||||||||||||||||||||||||
| 1668 | |||||||||||||||||||||||||||||||||
| 1669 | =item C<-v> or C<--verbose> | ||||||||||||||||||||||||||||||||
| 1670 | |||||||||||||||||||||||||||||||||
| 1671 | Verbose: output additional messages and warnings. | ||||||||||||||||||||||||||||||||
| 1672 | |||||||||||||||||||||||||||||||||
| 1673 | =item C<-n> or C<--qn> or C<--queryname> | ||||||||||||||||||||||||||||||||
| 1674 | |||||||||||||||||||||||||||||||||
| 1675 | Specify the query name. The query name is used as a heading in the | ||||||||||||||||||||||||||||||||
| 1676 | web pages, therefore it should be a 'nice' looking version of the | ||||||||||||||||||||||||||||||||
| 1677 | query string. | ||||||||||||||||||||||||||||||||
| 1678 | |||||||||||||||||||||||||||||||||
| 1679 | =item C<-s> or C<--qs> or C<--querystring> | ||||||||||||||||||||||||||||||||
| 1680 | |||||||||||||||||||||||||||||||||
| 1681 | Specify the query string. The query string is the character string | ||||||||||||||||||||||||||||||||
| 1682 | which will be submitted to the search engine. You may include special | ||||||||||||||||||||||||||||||||
| 1683 | characters to group or to qualify the search. | ||||||||||||||||||||||||||||||||
| 1684 | |||||||||||||||||||||||||||||||||
| 1685 | =item C<-e> or C<--engine> | ||||||||||||||||||||||||||||||||
| 1686 | |||||||||||||||||||||||||||||||||
| 1687 | Specify the search engine. The query string will be submitted | ||||||||||||||||||||||||||||||||
| 1688 | to the user specified search engine. | ||||||||||||||||||||||||||||||||
| 1689 | |||||||||||||||||||||||||||||||||
| 1690 | In many cases there are specialized versions of search engines. | ||||||||||||||||||||||||||||||||
| 1691 | For example, B<AltaVista::AdvancedWeb> and B<AltaVista::News> | ||||||||||||||||||||||||||||||||
| 1692 | allow more powerful and Usenet searches. | ||||||||||||||||||||||||||||||||
| 1693 | See L<AltaVista> or the man page for your search engine | ||||||||||||||||||||||||||||||||
| 1694 | for details about specialized variations. | ||||||||||||||||||||||||||||||||
| 1695 | |||||||||||||||||||||||||||||||||
| 1696 | =item C<--listnewurls> | ||||||||||||||||||||||||||||||||
| 1697 | |||||||||||||||||||||||||||||||||
| 1698 | In addition to all the normal file maintenance, | ||||||||||||||||||||||||||||||||
| 1699 | print all new URLs to STDOUT, one per line. | ||||||||||||||||||||||||||||||||
| 1700 | |||||||||||||||||||||||||||||||||
| 1701 | =item C<-o> or C<--options> | ||||||||||||||||||||||||||||||||
| 1702 | |||||||||||||||||||||||||||||||||
| 1703 | Specify the query options. The query options will be submitted | ||||||||||||||||||||||||||||||||
| 1704 | to the user search engine with the query string. This feature | ||||||||||||||||||||||||||||||||
| 1705 | permits modification of the query string for a specific search | ||||||||||||||||||||||||||||||||
| 1706 | engine or option. More than one query option may be specified. | ||||||||||||||||||||||||||||||||
| 1707 | |||||||||||||||||||||||||||||||||
| 1708 | Example: | ||||||||||||||||||||||||||||||||
| 1709 | C<-o what=news> | ||||||||||||||||||||||||||||||||
| 1710 | causes AltaVista to search Usenet. | ||||||||||||||||||||||||||||||||
| 1711 | Although this works, the preferred mechanism | ||||||||||||||||||||||||||||||||
| 1712 | in this case would be C<-e AltaVista::News> or C<-e AltaVista::AdvancedNews>. | ||||||||||||||||||||||||||||||||
| 1713 | Options are intended for internal or expert use. | ||||||||||||||||||||||||||||||||
| 1714 | |||||||||||||||||||||||||||||||||
| 1715 | |||||||||||||||||||||||||||||||||
| 1716 | =item C<-f> or C<--uf> or C<--urlfilter> | ||||||||||||||||||||||||||||||||
| 1717 | |||||||||||||||||||||||||||||||||
| 1718 | This option specifies a regular expression which will | ||||||||||||||||||||||||||||||||
| 1719 | be compared against the URLs of any results; | ||||||||||||||||||||||||||||||||
| 1720 | if they match the case-insensitive regular expression, they will be removed | ||||||||||||||||||||||||||||||||
| 1721 | from the hit set. | ||||||||||||||||||||||||||||||||
| 1722 | |||||||||||||||||||||||||||||||||
| 1723 | Example: | ||||||||||||||||||||||||||||||||
| 1724 | C<-f '.*\.isi\.edu'> avoids all of ISI's web pages. | ||||||||||||||||||||||||||||||||
| 1725 | |||||||||||||||||||||||||||||||||
| 1726 | =item C<--cleanup i> | ||||||||||||||||||||||||||||||||
| 1727 | |||||||||||||||||||||||||||||||||
| 1728 | Delete all traces of query results from more than i days ago. If | ||||||||||||||||||||||||||||||||
| 1729 | --cleanup is given, all other options other than the qid will be | ||||||||||||||||||||||||||||||||
| 1730 | ignored. | ||||||||||||||||||||||||||||||||
| 1731 | |||||||||||||||||||||||||||||||||
| 1732 | =item C<--cmdline> | ||||||||||||||||||||||||||||||||
| 1733 | |||||||||||||||||||||||||||||||||
| 1734 | Reconstruct the complete command line (AutoSearch and all its | ||||||||||||||||||||||||||||||||
| 1735 | arguments) that was used to create the query results. Command line | ||||||||||||||||||||||||||||||||
| 1736 | will be shown on STDERR. If --cmdline is given, all other options | ||||||||||||||||||||||||||||||||
| 1737 | other than the qid will be ignored. | ||||||||||||||||||||||||||||||||
| 1738 | |||||||||||||||||||||||||||||||||
| 1739 | =item C<--mail user@address> or C<-m user@address> | ||||||||||||||||||||||||||||||||
| 1740 | |||||||||||||||||||||||||||||||||
| 1741 | After search is complete, send email to that user, listing the NEW results. | ||||||||||||||||||||||||||||||||
| 1742 | Email is HTML format. | ||||||||||||||||||||||||||||||||
| 1743 | Requires the Email::Send and related modules. | ||||||||||||||||||||||||||||||||
| 1744 | If you send email through an SMTP server, you must set environment variable SMTPSERVER to your server name or IP address. | ||||||||||||||||||||||||||||||||
| 1745 | If your SMTP server requires password, you must set environment variables SMTPUSERNAME and SMTPPASSWORD. | ||||||||||||||||||||||||||||||||
| 1746 | If you send email via sendmail, you should set environment variable SENDMAIL if the sendmail executable is not in the path. | ||||||||||||||||||||||||||||||||
| 1747 | |||||||||||||||||||||||||||||||||
| 1748 | =item C<--emailfrom user@address> | ||||||||||||||||||||||||||||||||
| 1749 | |||||||||||||||||||||||||||||||||
| 1750 | If your outgoing mail server rejects email from certain users, | ||||||||||||||||||||||||||||||||
| 1751 | you can use this argument to set the From: header. | ||||||||||||||||||||||||||||||||
| 1752 | |||||||||||||||||||||||||||||||||
| 1753 | =item C<--userid bbunny> | ||||||||||||||||||||||||||||||||
| 1754 | |||||||||||||||||||||||||||||||||
| 1755 | If the search engine requires a login/password (e.g. Ebay::Completed), use this. | ||||||||||||||||||||||||||||||||
| 1756 | |||||||||||||||||||||||||||||||||
| 1757 | =item C<--password Carr0t5> | ||||||||||||||||||||||||||||||||
| 1758 | |||||||||||||||||||||||||||||||||
| 1759 | If the search engine requires a login/password (e.g. Ebay::Mature), use this. | ||||||||||||||||||||||||||||||||
| 1760 | |||||||||||||||||||||||||||||||||
| 1761 | =back | ||||||||||||||||||||||||||||||||
| 1762 | |||||||||||||||||||||||||||||||||
| 1763 | |||||||||||||||||||||||||||||||||
| 1764 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 1765 | |||||||||||||||||||||||||||||||||
| 1766 | B<AutoSearch> submits a query to a search engine, produces HTML pages | ||||||||||||||||||||||||||||||||
| 1767 | that reflect the set of 'hits' (filtered search results) returned by | ||||||||||||||||||||||||||||||||
| 1768 | the search engine, and tracks these results over time. The URL and | ||||||||||||||||||||||||||||||||
| 1769 | title are displayed in the F<qid/index.html>, the URL, the title, and | ||||||||||||||||||||||||||||||||
| 1770 | description are displayed in the 'weekly' files. | ||||||||||||||||||||||||||||||||
| 1771 | |||||||||||||||||||||||||||||||||
| 1772 | To organize these results, each search result is placed in a query | ||||||||||||||||||||||||||||||||
| 1773 | information directory (qid). The directory becomes the search results | ||||||||||||||||||||||||||||||||
| 1774 | 'handle', an easy way to track a set of results. Thus a qid of | ||||||||||||||||||||||||||||||||
| 1775 | C</usr/local/htdocs/lsam/autosearch/load_balancing> might locate the | ||||||||||||||||||||||||||||||||
| 1776 | results on your web server at | ||||||||||||||||||||||||||||||||
| 1777 | C<http://www.isi.edu/lsam/autosearch/load_balancing>. | ||||||||||||||||||||||||||||||||
| 1778 | |||||||||||||||||||||||||||||||||
| 1779 | Inside the qid directory you will find files relating to this query. | ||||||||||||||||||||||||||||||||
| 1780 | The primary file is F<index.html>, which reflects the latest search | ||||||||||||||||||||||||||||||||
| 1781 | results. Every not-filtered hit for every search is stored in | ||||||||||||||||||||||||||||||||
| 1782 | F<index.html>. When a hit is no longer found by the search engine it | ||||||||||||||||||||||||||||||||
| 1783 | a removed from F<index.html>. As new results for a search are | ||||||||||||||||||||||||||||||||
| 1784 | returned from the search engine they are placed in F<index.html>. | ||||||||||||||||||||||||||||||||
| 1785 | |||||||||||||||||||||||||||||||||
| 1786 | At the bottom of F<index.html>, there is a heading "Weekly Search | ||||||||||||||||||||||||||||||||
| 1787 | Results", which is updated each time the search is submitted (see | ||||||||||||||||||||||||||||||||
| 1788 | L<AUTOMATED SEARCHING>). The list of search runs is stored in reverse | ||||||||||||||||||||||||||||||||
| 1789 | chronological order. Runs which provide no new information are | ||||||||||||||||||||||||||||||||
| 1790 | identified with | ||||||||||||||||||||||||||||||||
| 1791 | |||||||||||||||||||||||||||||||||
| 1792 | No Unique Results found for search on <date> | ||||||||||||||||||||||||||||||||
| 1793 | |||||||||||||||||||||||||||||||||
| 1794 | Runs which contain changes are identified by | ||||||||||||||||||||||||||||||||
| 1795 | |||||||||||||||||||||||||||||||||
| 1796 | Web search results for search on <date> | ||||||||||||||||||||||||||||||||
| 1797 | |||||||||||||||||||||||||||||||||
| 1798 | which will be linked a page detailing the changes from that run. | ||||||||||||||||||||||||||||||||
| 1799 | |||||||||||||||||||||||||||||||||
| 1800 | Detailed search results are noted in weekly files. These files are | ||||||||||||||||||||||||||||||||
| 1801 | named F<YYYYMMDD.html> and are stored in the qid directory. The | ||||||||||||||||||||||||||||||||
| 1802 | weekly files include THE URL, title, and a the description (if | ||||||||||||||||||||||||||||||||
| 1803 | available). The title is a link to the original web page. | ||||||||||||||||||||||||||||||||
| 1804 | |||||||||||||||||||||||||||||||||
| 1805 | |||||||||||||||||||||||||||||||||
| 1806 | =head1 AUTOMATED SEARCHING | ||||||||||||||||||||||||||||||||
| 1807 | |||||||||||||||||||||||||||||||||
| 1808 | On UNIX-like systems, cron(1) may be used to establish periodic | ||||||||||||||||||||||||||||||||
| 1809 | searches and the web pages will be maintained by B<AutoSearch>. To | ||||||||||||||||||||||||||||||||
| 1810 | establish the first search, use the first example under SYNOPSIS. You | ||||||||||||||||||||||||||||||||
| 1811 | must specify the qid, query name and query string. If any of the | ||||||||||||||||||||||||||||||||
| 1812 | items are missing, you will be interactively prompted for the missing | ||||||||||||||||||||||||||||||||
| 1813 | item(s). | ||||||||||||||||||||||||||||||||
| 1814 | |||||||||||||||||||||||||||||||||
| 1815 | Once the first search is complete you can re-run the search with the | ||||||||||||||||||||||||||||||||
| 1816 | second form under SYNOPSIS. | ||||||||||||||||||||||||||||||||
| 1817 | |||||||||||||||||||||||||||||||||
| 1818 | A cron entry like: | ||||||||||||||||||||||||||||||||
| 1819 | |||||||||||||||||||||||||||||||||
| 1820 | 0 3 * * 1 /nfs/u1/wls/AutoSearch.pl /www/div7/lsam/autosearch/caching | ||||||||||||||||||||||||||||||||
| 1821 | |||||||||||||||||||||||||||||||||
| 1822 | might be used to run the search each Monday at 3:00 AM. The query | ||||||||||||||||||||||||||||||||
| 1823 | name and query string may be repeated; but they will not be used. | ||||||||||||||||||||||||||||||||
| 1824 | This means that with a cron line like: | ||||||||||||||||||||||||||||||||
| 1825 | |||||||||||||||||||||||||||||||||
| 1826 | 0 3 * * 1 /nfs/u1/wls/AutoSearch.pl /www/div7/lsam/autosearch/caching -n caching -s caching | ||||||||||||||||||||||||||||||||
| 1827 | |||||||||||||||||||||||||||||||||
| 1828 | a whole new search series can be originated by | ||||||||||||||||||||||||||||||||
| 1829 | |||||||||||||||||||||||||||||||||
| 1830 | rm -r /www/div7/lsam/autosearch/caching | ||||||||||||||||||||||||||||||||
| 1831 | |||||||||||||||||||||||||||||||||
| 1832 | However, the only reason to start a new search series would be to | ||||||||||||||||||||||||||||||||
| 1833 | throw away the old weekly files. | ||||||||||||||||||||||||||||||||
| 1834 | |||||||||||||||||||||||||||||||||
| 1835 | We don't recommend running searches more than once per day, but if so | ||||||||||||||||||||||||||||||||
| 1836 | the per-run files will be updated in-place. Any changes are added to | ||||||||||||||||||||||||||||||||
| 1837 | the page with a comment that "Recently Added:"; and deletions are | ||||||||||||||||||||||||||||||||
| 1838 | indicated with "Recently Suspended:." | ||||||||||||||||||||||||||||||||
| 1839 | |||||||||||||||||||||||||||||||||
| 1840 | =head1 CHANGING THE LOOK OF THE PAGES | ||||||||||||||||||||||||||||||||
| 1841 | |||||||||||||||||||||||||||||||||
| 1842 | The basic format of these two pages is simple and customizable. One | ||||||||||||||||||||||||||||||||
| 1843 | requirement is that the basic structure remain unchanged. HTML | ||||||||||||||||||||||||||||||||
| 1844 | comments are used to identify sections of the document. Almost | ||||||||||||||||||||||||||||||||
| 1845 | everything can be changed except for the strings which identify the | ||||||||||||||||||||||||||||||||
| 1846 | section starts and ends. | ||||||||||||||||||||||||||||||||
| 1847 | |||||||||||||||||||||||||||||||||
| 1848 | Noteworthy tags and their meaning: | ||||||||||||||||||||||||||||||||
| 1849 | |||||||||||||||||||||||||||||||||
| 1850 | =over 16 | ||||||||||||||||||||||||||||||||
| 1851 | |||||||||||||||||||||||||||||||||
| 1852 | =item <!--Top-->.*<!--/Top--> | ||||||||||||||||||||||||||||||||
| 1853 | |||||||||||||||||||||||||||||||||
| 1854 | The text contained within this tag is placed at the top of the output | ||||||||||||||||||||||||||||||||
| 1855 | page. If the text contains I<AutoSearch WEB Searching>, then the | ||||||||||||||||||||||||||||||||
| 1856 | query name will replace it. If the text does not contain this magic | ||||||||||||||||||||||||||||||||
| 1857 | string and it is the first ever search, the user will be asked for a | ||||||||||||||||||||||||||||||||
| 1858 | query name. | ||||||||||||||||||||||||||||||||
| 1859 | |||||||||||||||||||||||||||||||||
| 1860 | =item <!--Query{.*}/Query--> | ||||||||||||||||||||||||||||||||
| 1861 | |||||||||||||||||||||||||||||||||
| 1862 | The text contained between the braces is the query string. This is | ||||||||||||||||||||||||||||||||
| 1863 | how B<AutoSearch> maintains the query string. You may edit this | ||||||||||||||||||||||||||||||||
| 1864 | string to change the query string; but only in F<qid/index.html>. The | ||||||||||||||||||||||||||||||||
| 1865 | text I<ask user> is special and will force B<AutoSearch> to request | ||||||||||||||||||||||||||||||||
| 1866 | the search string from the user. | ||||||||||||||||||||||||||||||||
| 1867 | |||||||||||||||||||||||||||||||||
| 1868 | =item <!--SearchEngine{.*}/SearchEngine--> | ||||||||||||||||||||||||||||||||
| 1869 | |||||||||||||||||||||||||||||||||
| 1870 | The text contained between the braces is the search engine. Other | ||||||||||||||||||||||||||||||||
| 1871 | engines supported are HotBot and Lycos. You may edit this string to | ||||||||||||||||||||||||||||||||
| 1872 | change the engine used; but only in F<qid/index.html>. The text I<ask | ||||||||||||||||||||||||||||||||
| 1873 | user> is special and will force B<AutoSearch> to to request the search | ||||||||||||||||||||||||||||||||
| 1874 | string from the user. | ||||||||||||||||||||||||||||||||
| 1875 | |||||||||||||||||||||||||||||||||
| 1876 | =item <!--QueryOptions{.*}/QueryOptions--> | ||||||||||||||||||||||||||||||||
| 1877 | |||||||||||||||||||||||||||||||||
| 1878 | The text contained between the braces specifies a query options. | ||||||||||||||||||||||||||||||||
| 1879 | Multiple occurrencs of this command are allowed to specify multiple | ||||||||||||||||||||||||||||||||
| 1880 | options. | ||||||||||||||||||||||||||||||||
| 1881 | |||||||||||||||||||||||||||||||||
| 1882 | =item <!--URLFilter{.*}/URLFilter--> | ||||||||||||||||||||||||||||||||
| 1883 | |||||||||||||||||||||||||||||||||
| 1884 | The text contained between the braces is the URL filter. This is how | ||||||||||||||||||||||||||||||||
| 1885 | B<AutoSearch> maintains the filter. Again you may edit this string to | ||||||||||||||||||||||||||||||||
| 1886 | change the query string; but only in F<qid/index.html>. The text | ||||||||||||||||||||||||||||||||
| 1887 | I<ask user> is special and will force B<AutoSearch> to ask the user | ||||||||||||||||||||||||||||||||
| 1888 | (STDIN) for the query string. When setting up the first search, you | ||||||||||||||||||||||||||||||||
| 1889 | must edit F<first_index.html>, not F<qid/index.html>. The URL filter | ||||||||||||||||||||||||||||||||
| 1890 | is a standard perl5 regular expression. URLs which do not match will | ||||||||||||||||||||||||||||||||
| 1891 | be kept. | ||||||||||||||||||||||||||||||||
| 1892 | |||||||||||||||||||||||||||||||||
| 1893 | =item <!--Bottom-->.*<!--/Bottom--> | ||||||||||||||||||||||||||||||||
| 1894 | |||||||||||||||||||||||||||||||||
| 1895 | The text contained within this tag is placed at the bottom of the | ||||||||||||||||||||||||||||||||
| 1896 | output page. This is a good place to put navigation, page owner | ||||||||||||||||||||||||||||||||
| 1897 | information, etc. | ||||||||||||||||||||||||||||||||
| 1898 | |||||||||||||||||||||||||||||||||
| 1899 | =back | ||||||||||||||||||||||||||||||||
| 1900 | |||||||||||||||||||||||||||||||||
| 1901 | The remainder of the tags fall into a triplet of I<~Heading>, | ||||||||||||||||||||||||||||||||
| 1902 | I<~Template>, and I<~>, where ~ is Summary, Weekly, Appended, and | ||||||||||||||||||||||||||||||||
| 1903 | Suspended. The sub-sections appear in the order given. To produce a | ||||||||||||||||||||||||||||||||
| 1904 | section B<AutoSearch> outputs the heading, the template, the section, | ||||||||||||||||||||||||||||||||
| 1905 | n copies of the formatted data, and an /section. The tags and their | ||||||||||||||||||||||||||||||||
| 1906 | function are: | ||||||||||||||||||||||||||||||||
| 1907 | |||||||||||||||||||||||||||||||||
| 1908 | =over 16 | ||||||||||||||||||||||||||||||||
| 1909 | |||||||||||||||||||||||||||||||||
| 1910 | =item ~Heading | ||||||||||||||||||||||||||||||||
| 1911 | |||||||||||||||||||||||||||||||||
| 1912 | The heading tag identifies the heading for a section of the output | ||||||||||||||||||||||||||||||||
| 1913 | file. The SummaryHeading is for the summary portion, etc. The | ||||||||||||||||||||||||||||||||
| 1914 | section may be empty (e.g., Suspended) and thus no heading is output. | ||||||||||||||||||||||||||||||||
| 1915 | |||||||||||||||||||||||||||||||||
| 1916 | =item ~Template | ||||||||||||||||||||||||||||||||
| 1917 | |||||||||||||||||||||||||||||||||
| 1918 | The template tag identifies how each item is to be formatted. Simple | ||||||||||||||||||||||||||||||||
| 1919 | text replacement is used to change the template into the actual output | ||||||||||||||||||||||||||||||||
| 1920 | text. The text to be replaced is noted in ALLCAPS. | ||||||||||||||||||||||||||||||||
| 1921 | |||||||||||||||||||||||||||||||||
| 1922 | =item ~ | ||||||||||||||||||||||||||||||||
| 1923 | |||||||||||||||||||||||||||||||||
| 1924 | This tag is used to locate the section (Summary, Weekly, etc.). This | ||||||||||||||||||||||||||||||||
| 1925 | section represents the actual n-items of data. | ||||||||||||||||||||||||||||||||
| 1926 | |||||||||||||||||||||||||||||||||
| 1927 | =back | ||||||||||||||||||||||||||||||||
| 1928 | |||||||||||||||||||||||||||||||||
| 1929 | You can edit these values in the F<qid/index.html> page of an existing | ||||||||||||||||||||||||||||||||
| 1930 | search. The file F<first_index.html> (in the directory above F<qid>) | ||||||||||||||||||||||||||||||||
| 1931 | will be used as a default template for new queries. | ||||||||||||||||||||||||||||||||
| 1932 | |||||||||||||||||||||||||||||||||
| 1933 | Examples of these files can be seen in the pages under | ||||||||||||||||||||||||||||||||
| 1934 | C<http://www.isi.edu/lsam/tools/autosearch/>, or in the output generated by | ||||||||||||||||||||||||||||||||
| 1935 | a new AutoSearch. | ||||||||||||||||||||||||||||||||
| 1936 | |||||||||||||||||||||||||||||||||
| 1937 | =head1 FILES | ||||||||||||||||||||||||||||||||
| 1938 | |||||||||||||||||||||||||||||||||
| 1939 | =over 20 | ||||||||||||||||||||||||||||||||
| 1940 | |||||||||||||||||||||||||||||||||
| 1941 | =item F<first_index.html> | ||||||||||||||||||||||||||||||||
| 1942 | |||||||||||||||||||||||||||||||||
| 1943 | optional file to determine the default format of the F<index.html> | ||||||||||||||||||||||||||||||||
| 1944 | file of a new query. | ||||||||||||||||||||||||||||||||
| 1945 | |||||||||||||||||||||||||||||||||
| 1946 | =item F<first_date.html> | ||||||||||||||||||||||||||||||||
| 1947 | |||||||||||||||||||||||||||||||||
| 1948 | optional file to determine the default format of the F<YYYYMMDD.html> | ||||||||||||||||||||||||||||||||
| 1949 | file for a new query. | ||||||||||||||||||||||||||||||||
| 1950 | |||||||||||||||||||||||||||||||||
| 1951 | =item F<qid/index.html> | ||||||||||||||||||||||||||||||||
| 1952 | |||||||||||||||||||||||||||||||||
| 1953 | (automatically created) latest search results, and reverse | ||||||||||||||||||||||||||||||||
| 1954 | chronological list of periodic searches. | ||||||||||||||||||||||||||||||||
| 1955 | |||||||||||||||||||||||||||||||||
| 1956 | =item F<qid/date.html> | ||||||||||||||||||||||||||||||||
| 1957 | |||||||||||||||||||||||||||||||||
| 1958 | file used as a template for the F<YYYYMMDD.html> files. | ||||||||||||||||||||||||||||||||
| 1959 | |||||||||||||||||||||||||||||||||
| 1960 | =item F<qid/YYYYMMDD.html> | ||||||||||||||||||||||||||||||||
| 1961 | |||||||||||||||||||||||||||||||||
| 1962 | (automatically created) summary of changes for a particular date (AKA | ||||||||||||||||||||||||||||||||
| 1963 | 'Weekly' file). | ||||||||||||||||||||||||||||||||
| 1964 | |||||||||||||||||||||||||||||||||
| 1965 | =back | ||||||||||||||||||||||||||||||||
| 1966 | |||||||||||||||||||||||||||||||||
| 1967 | Optional files F<first_index.html> and F<first_date.html> are used for | ||||||||||||||||||||||||||||||||
| 1968 | the initial search as a template for F<qid/index.html> and | ||||||||||||||||||||||||||||||||
| 1969 | F<date.html>, respectively. If either of these files does not exist; | ||||||||||||||||||||||||||||||||
| 1970 | a default-default template is stored within the F<AutoSearch> source. | ||||||||||||||||||||||||||||||||
| 1971 | The intention of these two files is to permit a user to establish a | ||||||||||||||||||||||||||||||||
| 1972 | framework for a group of search sets which have a common format. By | ||||||||||||||||||||||||||||||||
| 1973 | leaving the default query name and query string alone, they will be | ||||||||||||||||||||||||||||||||
| 1974 | overridden by command line inputs. | ||||||||||||||||||||||||||||||||
| 1975 | |||||||||||||||||||||||||||||||||
| 1976 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||
| 1977 | |||||||||||||||||||||||||||||||||
| 1978 | For the library, see L<WWW::Search>, | ||||||||||||||||||||||||||||||||
| 1979 | for the perl regular expressions, see L<perlre>. | ||||||||||||||||||||||||||||||||
| 1980 | |||||||||||||||||||||||||||||||||
| 1981 | =head1 AUTHORS | ||||||||||||||||||||||||||||||||
| 1982 | |||||||||||||||||||||||||||||||||
| 1983 | Wm. L. Scheding | ||||||||||||||||||||||||||||||||
| 1984 | |||||||||||||||||||||||||||||||||
| 1985 | B<AutoSearch> is a re-implementation of an earlier version written by | ||||||||||||||||||||||||||||||||
| 1986 | Kedar Jog. | ||||||||||||||||||||||||||||||||
| 1987 | |||||||||||||||||||||||||||||||||
| 1988 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||
| 1989 | |||||||||||||||||||||||||||||||||
| 1990 | Copyright (C) 1996-1997 University of Southern California. | ||||||||||||||||||||||||||||||||
| 1991 | All rights reserved. | ||||||||||||||||||||||||||||||||
| 1992 | |||||||||||||||||||||||||||||||||
| 1993 | Redistribution and use in source and binary forms are permitted | ||||||||||||||||||||||||||||||||
| 1994 | provided that the above copyright notice and this paragraph are | ||||||||||||||||||||||||||||||||
| 1995 | duplicated in all such forms and that any documentation, advertising | ||||||||||||||||||||||||||||||||
| 1996 | materials, and other materials related to such distribution and use | ||||||||||||||||||||||||||||||||
| 1997 | acknowledge that the software was developed by the University of | ||||||||||||||||||||||||||||||||
| 1998 | Southern California, Information Sciences Institute. The name of the | ||||||||||||||||||||||||||||||||
| 1999 | University may not be used to endorse or promote products derived from | ||||||||||||||||||||||||||||||||
| 2000 | this software without specific prior written permission. | ||||||||||||||||||||||||||||||||
| 2001 | |||||||||||||||||||||||||||||||||
| 2002 | THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED | ||||||||||||||||||||||||||||||||
| 2003 | WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||||||||||||||||||||||||||||||||
| 2004 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||||||
| 2005 | |||||||||||||||||||||||||||||||||
| 2006 | =head1 DESIRED FEATURES | ||||||||||||||||||||||||||||||||
| 2007 | |||||||||||||||||||||||||||||||||
| 2008 | These are good ideas that people have suggested. | ||||||||||||||||||||||||||||||||
| 2009 | |||||||||||||||||||||||||||||||||
| 2010 | =over 4 | ||||||||||||||||||||||||||||||||
| 2011 | |||||||||||||||||||||||||||||||||
| 2012 | =item URL validation. | ||||||||||||||||||||||||||||||||
| 2013 | |||||||||||||||||||||||||||||||||
| 2014 | Validate the status of each URL (with HTTP HEAD requests) and indicate | ||||||||||||||||||||||||||||||||
| 2015 | this status in the output. | ||||||||||||||||||||||||||||||||
| 2016 | |||||||||||||||||||||||||||||||||
| 2017 | =item Multi-search. | ||||||||||||||||||||||||||||||||
| 2018 | |||||||||||||||||||||||||||||||||
| 2019 | It should be possible to merge the results of searches from two | ||||||||||||||||||||||||||||||||
| 2020 | search-engines. If this merger were done as a new search engine, this | ||||||||||||||||||||||||||||||||
| 2021 | operation would be transparent to AutoSearch. | ||||||||||||||||||||||||||||||||
| 2022 | |||||||||||||||||||||||||||||||||
| 2023 | =back | ||||||||||||||||||||||||||||||||
| 2024 | |||||||||||||||||||||||||||||||||
| 2025 | =head1 BUGS | ||||||||||||||||||||||||||||||||
| 2026 | |||||||||||||||||||||||||||||||||
| 2027 | None known at this time; please inform the maintainer mthurn@cpan.org | ||||||||||||||||||||||||||||||||
| 2028 | if any crop up. | ||||||||||||||||||||||||||||||||
| 2029 | |||||||||||||||||||||||||||||||||
| 2030 | =cut | ||||||||||||||||||||||||||||||||
| 2031 | |||||||||||||||||||||||||||||||||
| 2032 | __END__ | ||||||||||||||||||||||||||||||||