Changeset 1693
- Timestamp:
- 2000-11-23T11:51:09+13:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/mgppbuildcol.pl
r1303 r1693 26 26 # 27 27 ########################################################################### 28 package mgppbuildcol; 28 29 29 30 BEGIN { … … 32 33 unshift (@INC, "$ENV{'GSDLHOME'}/perllib"); 33 34 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/plugins"); 35 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/classify"); 34 36 } 35 37 #$ENV{'PATH'} = "$ENV{'GSDLHOME'}/src/mgpp/text:".$ENV{'PATH'}; … … 38 40 use parsargv; 39 41 use util; 42 use FileHandle; 40 43 41 44 &main(); … … 56 59 print STDERR " building directory\n"; 57 60 print STDERR " -allclassifications Don't remove empty classifications\n\n"; 58 } 61 print STDERR " -create_images Attempt to create default images for new\n"; 62 print STDERR " collection. This relies on the Gimp being\n"; 63 print STDERR " installed along with relevant perl modules\n"; 64 print STDERR " to allow scripting from perl\n"; 65 print STDERR " -collectdir directory Collection directory (defaults to " . 66 &util::filename_cat ($ENV{'GSDLHOME'}, "collect") . ")\n"; 67 print STDERR " -out Filename or handle to print output status to.\n"; 68 print STDERR " The default is STDERR\n\n"; 69 } 70 59 71 60 72 … … 62 74 { 63 75 my ($verbosity, $archivedir, $cachedir, $builddir, $maxdocs, 64 $debug, $mode, $indexname, $keepold, $allclassifications); 76 $debug, $mode, $indexname, $keepold, $allclassifications, 77 $create_images, $collectdir, $out); 65 78 if (!parsargv::parse(\@ARGV, 66 79 'verbosity/\d+/2', \$verbosity, … … 73 86 'index/.*/', \$indexname, 74 87 'keepold', \$keepold, 75 'allclassifications', \$allclassifications)) { 88 'allclassifications', \$allclassifications, 89 'create_images', \$create_images, 90 'collectdir/.*/', \$collectdir, 91 'out/.*/STDERR', \$out)) { 76 92 &print_usage(); 77 93 die "\n"; 78 94 } 95 96 my $close_out = 0; 97 if ($out !~ /^(STDERR|STDOUT)$/i) { 98 open (OUT, ">$out") || die "Couldn't open output file $out\n"; 99 $out = "buildcol::OUT"; 100 $close_out = 1; 101 } 102 $out->autoflush(1); 79 103 80 104 # get and check the collection 81 105 # this sets up GSDLCOLLECTION (eg demo) and GSDLCOLLECTDIR (eg 82 106 # GSDLHOME/collect/demo ) 83 if (($collection = &util::use_collection(@ARGV )) eq "") {107 if (($collection = &util::use_collection(@ARGV, $collectdir)) eq "") { 84 108 &print_usage(); 85 109 die "\n"; … … 107 131 } 108 132 133 # create default images if required 134 if ($create_images) { 135 my $collection_name = $collection; 136 $collection_name = $collectcfg->{'collectionmeta'}->{'collectionname'} 137 if defined $collectcfg->{'collectionmeta'}->{'collectionname'}; 138 139 &create_images ($collection_name); 140 } 141 109 142 # fill in the default archives and building directories if none 110 143 # were supplied, turn all \ into / and remove trailing / … … 118 151 # update the archive cache if needed 119 152 if ($cachedir) { 120 print STDERR"Updating archive cache\n" if ($verbosity >= 1);153 print $out "Updating archive cache\n" if ($verbosity >= 1); 121 154 122 155 $cachedir =~ s/[\\\/]+$//; … … 138 171 &util::mk_all_dir ($realbuilddir); 139 172 140 141 # if a builder class has been created for this collection, use it 173 # if a builder class has been created for this collection, use it 142 174 # otherwise, use the mg builder 143 175 if (-e "$ENV{'GSDLCOLLECTDIR'}/perllib/${collection}builder.pm") { … … 153 185 eval("\$builder = new $buildertype(\$collection, " . 154 186 "\$realarchivedir, \$realbuilddir, \$verbosity, " . 155 "\$maxdocs, \$debug, \$keepold, \$allclassifications )");187 "\$maxdocs, \$debug, \$keepold, \$allclassifications, \$out)"); 156 188 die "$@" if $@; 157 189 … … 159 191 160 192 161 print STDERR "text index=$textindex, indexname= $indexname\n";162 193 if ($mode =~ /^all$/i) { 163 194 # $builder->build_collection($textindex, $indexname); … … 180 211 181 212 if (($realbuilddir ne $builddir) && !$debug) { 182 print STDERR"Copying back the cached build\n" if ($verbosity >= 1);213 print $out "Copying back the cached build\n" if ($verbosity >= 1); 183 214 &util::rm_r ($builddir); 184 215 &util::cp_r ($realbuilddir, $builddir); 185 216 } 186 } 187 188 217 218 close OUT if $close_out; 219 } 220 221 222 sub create_images { 223 my ($collection_name) = @_; 224 225 my $image_script = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "script", "gimp", "title_icon.pl"); 226 if (!-e $image_script) { 227 print $out "WARNING: Image making script ($image_script) could not be found\n"; 228 print $out " Default images will not be generated\n\n"; 229 return; 230 } 231 232 my $imagedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "images"); 233 234 &util::mk_all_dir ($imagedir); 235 236 # create the images 237 system ("$image_script -size 1.5 -image_dir \"$imagedir\" -filename $collection.gif -text \"$collection_name\""); 238 system ("$image_script -image_dir \"$imagedir\" -filename ${collection}sm.gif -text \"$collection_name\""); 239 240 # update the collect.cfg configuration file (this will need 241 # to be changed when the config file format changes) 242 if (!open (CFGFILE, $configfilename)) { 243 print $out "WARNING: Couldn't open config file ($configfilename)\n"; 244 print $out " for updating so collection images may not be linked correctly\n"; 245 return; 246 } 247 248 my $line = ""; my $file = ""; 249 my $found = 0; my $foundsm = 0; 250 while (defined ($line = <CFGFILE>)) { 251 if ($line =~ /collectionmeta\s+iconcollection\s+/) { 252 $line = "collectionmeta iconcollection _httpprefix_/collect/$collection/images/$collection.gif\n"; 253 $found = 1; 254 } elsif ($line =~ /collectionmeta\s+iconcollectionsmall\s+/) { 255 $line = "collectionmeta iconcollectionsmall _httpprefix_/collect/$collection/images/${collection}sm.gif\n"; 256 $foundsm = 1; 257 } 258 $file .= $line; 259 } 260 close CFGFILE; 261 262 $file .= "collectionmeta iconcollection _httpprefix_/collect/$collection/images/$collection.gif\n" if !$found; 263 $file .= "collectionmeta iconcollectionsmall _httpprefix_/collect/$collection/images/${collection}sm.gif\n" if !$foundsm; 264 265 if (!open (CFGFILE, ">$configfilename")) { 266 print $out "WARNING: Couldn't open config file ($configfilename)\n"; 267 print $out " for updating so collection images may not be linked correctly\n"; 268 return; 269 } 270 print CFGFILE $file; 271 close CFGFILE; 272 } 273
Note:
See TracChangeset
for help on using the changeset viewer.