--- loncom/metadata_database/searchcat.pl 2002/03/04 05:06:18 1.16 +++ loncom/metadata_database/searchcat.pl 2002/07/01 18:23:00 1.19 @@ -2,7 +2,7 @@ # The LearningOnline Network # searchcat.pl "Search Catalog" batch script # -# $Id: searchcat.pl,v 1.16 2002/03/04 05:06:18 harris41 Exp $ +# $Id: searchcat.pl,v 1.19 2002/07/01 18:23:00 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -27,15 +27,20 @@ # http://www.lon-capa.org/ # # YEAR=2001 -# # 04/14/2001, 04/16/2001 Scott Harrison # +# YEAR=2002 +# 05/11/2002 Scott Harrison +# ### # This script goes through a LON-CAPA resource # directory and gathers metadata. # The metadata is entered into a SQL database. +use lib '/home/httpd/lib/perl/'; +use LONCAPA::Configuration; + use IO::File; use HTML::TokeParser; use DBI; @@ -50,17 +55,12 @@ sub wanted { push(@metalist,"$dir/$_"); } -# ------------------------------------ Read httpd access.conf and get variables -open (CONFIG,"/etc/httpd/conf/access.conf") || die "Can't read access.conf"; - -while ($configline=) { - if ($configline =~ /PerlSetVar/) { - my ($dummy,$varname,$varvalue)=split(/\s+/,$configline); - chomp($varvalue); - $perlvar{$varname}=$varvalue; - } -} -close(CONFIG); +# --------------- Read loncapa_apache.conf and loncapa.conf and get variables +my $perlvarref=LONCAPA::Configuration::read_conf('loncapa_apache.conf', + 'loncapa.conf'); +my %perlvar=%{$perlvarref}; +undef $perlvarref; # remove since sensitive and not needed +delete $perlvar{'lonReceipt'}; # remove since sensitive and not needed # ------------------------------------- Only run if machine is a library server exit unless $perlvar{'lonRole'} eq 'library'; @@ -74,6 +74,19 @@ my $dbh; print "Cannot connect to database!\n"; exit; } + my $make_metadata_table = "CREATE TABLE IF NOT EXISTS metadata (". + "title TEXT, author TEXT, subject TEXT, url TEXT, keywords TEXT, ". + "version TEXT, notes TEXT, abstract TEXT, mime TEXT, language TEXT, ". + "creationdate DATETIME, lastrevisiondate DATETIME, owner TEXT, ". + "copyright TEXT, FULLTEXT idx_title (title), ". + "FULLTEXT idx_author (author), FULLTEXT idx_subject (subject), ". + "FULLTEXT idx_url (url), FULLTEXT idx_keywords (keywords), ". + "FULLTEXT idx_version (version), FULLTEXT idx_notes (notes), ". + "FULLTEXT idx_abstract (abstract), FULLTEXT idx_mime (mime), ". + "FULLTEXT idx_language (language), FULLTEXT idx_owner (owner), ". + "FULLTEXT idx_copyright (copyright)) TYPE=MYISAM"; + # It would sure be nice to have some logging mechanism. + $dbh->do($make_metadata_table); } # ------------------------------------------------------------- get .meta files