Changeset 1279 for branches/New_Config_Format-branch/gsdl/bin/script
- Timestamp:
- 2000-07-13T10:21:53+12:00 (24 years ago)
- Location:
- branches/New_Config_Format-branch/gsdl/bin/script
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New_Config_Format-branch/gsdl/bin/script/buildcol.pl
r1031 r1279 54 54 print STDERR " -keepold will not destroy the current contents of the\n"; 55 55 print STDERR " building directory\n"; 56 print STDERR " -allclassifications Don't remove empty classifications\n\n"; 56 print STDERR " -allclassifications Don't remove empty classifications\n"; 57 print STDERR " -create_images Attempt to create default images for new\n"; 58 print STDERR " collection. This relies on the Gimp being\n"; 59 print STDERR " installed along with relevant perl modules\n"; 60 print STDERR " to allow scripting from perl\n\n"; 57 61 } 58 62 … … 61 65 { 62 66 my ($verbosity, $archivedir, $cachedir, $builddir, $maxdocs, 63 $debug, $mode, $indexname, $keepold, $allclassifications); 67 $debug, $mode, $indexname, $keepold, $allclassifications, 68 $create_images); 64 69 if (!parsargv::parse(\@ARGV, 65 70 'verbosity/\d+/2', \$verbosity, … … 72 77 'index/.*/', \$indexname, 73 78 'keepold', \$keepold, 74 'allclassifications', \$allclassifications)) { 79 'allclassifications', \$allclassifications, 80 'create_images', \$create_images)) { 75 81 &print_usage(); 76 82 die "\n"; … … 85 91 # read the configuration file 86 92 $textindex = "section:text"; 87 $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc /collect.cfg");93 $configfilename = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "etc", "collect.cfg"); 88 94 if (-e $configfilename) { 89 95 $collectcfg = &colcfg::read_collect_cfg ($configfilename); … … 101 107 } 102 108 109 # create default images if required 110 if ($create_images) { 111 my $collection_name = $collection; 112 $collection_name = $collectcfg->{'collectionmeta'}->{'collectionname'} 113 if defined $collectcfg->{'collectionmeta'}->{'collectionname'}; 114 115 &create_images ($collection_name); 116 } 117 103 118 # fill in the default archives and building directories if none 104 119 # were supplied, turn all \ into / and remove trailing / … … 177 192 } 178 193 179 194 sub create_images { 195 my ($collection_name) = @_; 196 197 my $image_script = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "script", "gimp", "title_icon.pl"); 198 if (!-e $image_script) { 199 print STDERR "WARNING: Image making script ($image_script) could not be found\n"; 200 print STDERR " Default images will not be generated\n\n"; 201 return; 202 } 203 204 my $imagedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "images"); 205 206 &util::mk_all_dir ($imagedir); 207 208 # create the images 209 system ("$image_script -size 1.5 -image_dir \"$imagedir\" -filename $collection.gif -text \"$collection_name\""); 210 system ("$image_script -image_dir \"$imagedir\" -filename ${collection}sm.gif -text \"$collection_name\""); 211 212 # update the collect.cfg configuration file (this will need 213 # to be changed when the config file format changes) 214 if (!open (CFGFILE, $configfilename)) { 215 print STDERR "WARNING: Couldn't open config file ($configfilename)\n"; 216 print STDERR " for updating so collection images may not be linked correctly\n"; 217 return; 218 } 219 220 my $line = ""; my $file = ""; 221 my $found = 0; my $foundsm = 0; 222 while (defined ($line = <CFGFILE>)) { 223 if ($line =~ /collectionmeta\s+iconcollection\s+/) { 224 $line = "collectionmeta iconcollection _httprefix_/collect/$collection/images/$collection.gif\n"; 225 $found = 1; 226 } elsif ($line =~ /collectionmeta\s+iconcollectionsmall\s+/) { 227 $line = "collectionmeta iconcollectionsmall _httprefix_/collect/$collection/images/${collection}sm.gif\n"; 228 $foundsm = 1; 229 } 230 $file .= $line; 231 } 232 close CFGFILE; 233 234 $file .= "collectionmeta iconcollection _httprefix_/collect/$collection/images/$collection.gif\n" if !$found; 235 $file .= "collectionmeta iconcollectionsmall _httprefix_/collect/$collection/images/${collection}sm.gif\n" if !$foundsm; 236 237 if (!open (CFGFILE, ">$configfilename")) { 238 print STDERR "WARNING: Couldn't open config file ($configfilename)\n"; 239 print STDERR " for updating so collection images may not be linked correctly\n"; 240 return; 241 } 242 print CFGFILE $file; 243 close CFGFILE; 244 } -
branches/New_Config_Format-branch/gsdl/bin/script/gimp/flash_button.pl
r1037 r1279 55 55 56 56 sub print_usage { 57 print STDERR "\n usage: $0 [options] macrofile\n\n";57 print STDERR "\n usage: $0 [options]\n\n"; 58 58 print STDERR " options:\n"; 59 59 print STDERR " -cfg_file file configuration file containing one or more\n"; … … 136 136 chomp $image_dir; 137 137 } 138 139 # replace any '\n' occurring in text with carriage return 140 $text =~ s/\\n/\n/gi; 138 141 139 142 if ($cfg_file =~ /\w/) { -
branches/New_Config_Format-branch/gsdl/bin/script/gimp/title_icon.pl
r1037 r1279 46 46 47 47 48 my ($cfg_file, $imagefile, $width, $height, $imageheight, $stripecolor, $stripewidth,49 $stripe_alignment, $i_transparency, $text, $text_alignment, $filename, $textspace_x,50 $textspace_y, $bgcolor, $fontcolor, $fontsize, $minfontsize, $fontname,51 $fontweight, $fontslant, $fontwidth, $fontspacing, $image_dir);48 local ($cfg_file, $size, $imagefile, $width, $height, $imageheight, $stripecolor, $stripewidth, 49 $stripe_alignment, $i_transparency, $text, $text_alignment, $filename, $textspace_x, 50 $textspace_y, $bgcolor, $fontcolor, $fontsize, $minfontsize, $fontname, 51 $fontweight, $fontslant, $fontwidth, $fontspacing, $image_dir, $dont_wrap); 52 52 53 53 sub print_usage { … … 57 57 print STDERR " sets of the following options - use to create\n"; 58 58 print STDERR " batches of images\n"; 59 print STDERR " -size number the overall size ratio of the image (i.e. a size\n"; 60 print STDERR " of 2 will create an image twice the default size)\n"; 59 61 print STDERR " -image_dir directory directory to create images in [`pwd`]\n"; 60 62 print STDERR " this should be full path to existing directory\n"; … … 83 85 print STDERR " -fontslant [r]\n"; 84 86 print STDERR " -fontwidth [*]\n"; 85 print STDERR " -fontspacing [*]\n\n"; 87 print STDERR " -fontspacing [*]\n"; 88 print STDERR " -dont_wrap don't attempt to wrap text\n\n"; 86 89 } 87 90 … … 89 92 $image_dir = "./"; 90 93 $imagefile = ""; 91 $width = 150;92 $height = 44;93 $imageheight = 110;94 $width = int (150 * $size); 95 $height = int (44 * $size); 96 $imageheight = int (110 * $size); 94 97 $stripecolor = $gsdl_green; 95 $stripewidth = 40;98 $stripewidth = int (40 * $size); 96 99 $stripe_alignment = "left"; 97 100 $i_transparency = 60; … … 99 102 $text_alignment = "left"; 100 103 $filename = ""; 101 $textspace_x = 3;102 $textspace_y = 3;104 $textspace_x = int (3 * $size); 105 $textspace_y = int (3 * $size); 103 106 $bgcolor = $gsdl_green; 104 107 $fontcolor = $black; 105 $fontsize = 17;106 $minfontsize = 10;108 $fontsize = int (17 * $size); 109 $minfontsize = int (10 * $size); 107 110 $fontname = "lucida"; 108 111 $fontweight = "medium"; … … 116 119 if (!parsargv::parse(\@ARGV, 117 120 'cfg_file/.*/', \$cfg_file, 121 'size/\d+/1', \$size, 118 122 'image_dir/.*/./', \$image_dir, 119 123 'imagefile/.*/', \$imagefile, … … 138 142 'fontslant/.*/r', \$fontslant, 139 143 'fontwidth/.*/*', \$fontwidth, 140 'fontspacing/.*/*', \$fontspacing)) { 144 'fontspacing/.*/*', \$fontspacing, 145 'dont_wrap', \$dont_wrap)) { 141 146 &print_usage(); 142 147 die "title_icon.pl: incorrect options\n"; … … 148 153 chomp $image_dir; 149 154 } 150 155 151 156 if ($cfg_file =~ /\w/) { 152 157 … … 177 182 178 183 sub produce_image { 184 185 &adjust_args (); 186 &wrap_text () unless $dont_wrap; 179 187 180 188 my $use_image = 0; … … 338 346 return 1; 339 347 } 348 349 # adjust arguments that are effected by the size argument 350 sub adjust_args { 351 352 if ($size != 1) { 353 my @size_args = ('width', 'height', 'imageheight', 'stripewidth', 354 'textspace_x', 'textspace_y', 'fontsize', 'minfontsize'); 355 foreach $arg (@size_args) { 356 $$arg = int ($$arg * $size); 357 } 358 } 359 } 360 361 sub wrap_text { 362 363 # don't wrap text if it already contains carriage returns 364 return if $text =~ /\n/; 365 366 # the following assumes that all words are less than $wrap_length long 367 my $wrap_length = 14; 368 369 my $new_text = ""; 370 while (length ($text) >= $wrap_length) { 371 my $line = substr ($text, 0, $wrap_length); 372 $text =~ s/^$line//; 373 $line =~ s/\s([^\s]*)$/\n/; 374 $text = $1 . $text; 375 $new_text .= $line; 376 } 377 $new_text .= $text; 378 $text = $new_text; 379 } 340 380 341 381 sub query { -
branches/New_Config_Format-branch/gsdl/bin/script/gsw3mir.pl
r845 r1279 1 #!/usr/ local/bin/perl5-w1 #!/usr/bin/perl -w 2 2 3 3 ########################################################################### -
branches/New_Config_Format-branch/gsdl/bin/script/import.pl
r1031 r1279 56 56 print STDERR " directory -- use with care\n"; 57 57 print STDERR " -gzip Use gzip to compress resulting gml documents\n"; 58 print STDERR " (don't forget to include ZIPPlug in your plugin\n"; 59 print STDERR " list when building from compressed documents)\n"; 58 60 print STDERR " -maxdocs number Maximum number of documents to import\n"; 59 61 print STDERR " -groupsize number Number of GML documents to group into one file\n"; … … 135 137 136 138 # load all the plugins 137 $pluginfo = &plugin::load_plugins ($plugins );139 $pluginfo = &plugin::load_plugins ($plugins, $verbosity); 138 140 if (scalar(@$pluginfo) == 0) { 139 141 print STDERR "No plugins were loaded.\n"; -
branches/New_Config_Format-branch/gsdl/bin/script/mkcol.pl
r1031 r1279 51 51 print STDERR " -title text The title for the collection\n"; 52 52 print STDERR " -about text The about text for the collection\n"; 53 print STDERR " -plugins list Space separated list of perl plugin modules to use\n"; 53 print STDERR " -plugin text perl plugin module to use (there may be multiple\n"; 54 print STDERR " plugin entries\n"; 54 55 print STDERR " -refine list Space separated list of perl plugin modules to use\n"; 55 56 … … 106 107 $line =~ s/\*\*title\*\*/$title/g; 107 108 $line =~ s/\*\*about\*\*/$about/g; 108 $line =~ s/\*\*plugins\*\*/$plugins /g;109 $line =~ s/\*\*plugins\*\*/$pluginstring/g; 109 110 $line =~ s/\*\*refine\*\*/$refine/g; 110 111 … … 119 120 120 121 121 my (@indexes, @indexestext );122 my (@indexes, @indexestext, @plugin); 122 123 123 124 # get and check options … … 132 133 'title/.+/', \$title, 133 134 'about/.+/', \$about, 134 'plugin s/.+/GMLPlug TEXTPlug ArcPlug RecPlug/', \$plugins,135 'plugin/.+', \@plugin, 135 136 'refine/.+/', \$refine 136 137 )) { … … 138 139 die "\n"; 139 140 } 140 141 142 # load default plugins if none were on command line 143 if (!scalar(@plugin)) { 144 @plugin = (GMLPlug,TEXTPlug,ArcPlug,RecPlug); 145 } 146 141 147 # get and check the collection name 142 148 ($collection) = @ARGV; … … 195 201 } 196 202 203 $pluginstring = ""; 204 foreach $plugin (@plugin) { 205 $pluginstring .= "plugin $plugin\n"; 206 } 197 207 198 208 # make sure the model collection exists -
branches/New_Config_Format-branch/gsdl/bin/script/newsrc.pl
r546 r1279 1 #!/usr/ local/bin/perl5-w1 #!/usr/bin/perl -w 2 2 3 3 ########################################################################### -
branches/New_Config_Format-branch/gsdl/bin/script/togb.pl
r630 r1279 1 #!/usr/ local/bin/perl5-w1 #!/usr/bin/perl -w 2 2 3 3 ########################################################################### … … 36 36 if (!parsargv::parse(\@ARGV, 37 37 'unicode', \$unicode, 38 ' extended', \$extended,38 'iso_8859_1', \$iso_8859_1, 39 39 'gb', \$gb)) { 40 40 print STDERR "\n usage: $0 [options]\n\n"; 41 41 print STDERR " options:\n"; 42 print STDERR " -u tf8input is in utf-8 or unicode (default)\n";43 print STDERR " - extended input is in extended ascii\n";44 print STDERR " -gb input is in GB or GBK\n\n";42 print STDERR " -unicode input is in utf-8 or unicode (default)\n"; 43 print STDERR " -iso_8859_1 input is in extended ascii (ISO-8859-1 Latin 1)\n"; 44 print STDERR " -gb input is in GB or GBK (simplified Chinese)\n\n"; 45 45 die "\n"; 46 46 } 47 47 48 48 $encoding = "utf8" if $unicode; 49 $encoding = " extended" if $extended;49 $encoding = "iso_8859_1" if $iso_8859_1; 50 50 $encoding = "gb" if $gb; 51 51 -
branches/New_Config_Format-branch/gsdl/bin/script/touc.pl
r630 r1279 1 #!/usr/ local/bin/perl5-w1 #!/usr/bin/perl -w 2 2 3 3 ########################################################################### … … 36 36 if (!parsargv::parse(\@ARGV, 37 37 'unicode', \$unicode, 38 'extended', \$extended, 38 'iso_8859_1', \$iso_8859_1, 39 'iso_8859_6', \$iso_8859_6, 40 'windows_1256', \$windows_1256, 39 41 'gb', \$gb)) { 40 42 print STDERR "\n usage: $0 [options]\n\n"; 41 43 print STDERR " options:\n"; 42 print STDERR " -utf8 input is in utf-8 or unicode (default)\n"; 43 print STDERR " -extended input is in extended ascii\n"; 44 print STDERR " -gb input is in GB or GBK\n\n"; 44 print STDERR " -unicode input is in utf-8 or unicode (default)\n"; 45 print STDERR " -iso_8859_1 input is in extended ascii (ISO-8859-1 Latin 1)\n"; 46 print STDERR " -iso_8859_6 input is in 8 bit Arabic (ISO-8859-6)\n"; 47 print STDERR " -windows_1256 input is in Windows 1256 (Arabic)\n"; 48 print STDERR " -gb input is in GB or GBK (simplified Chinese)\n\n"; 45 49 die "\n"; 46 50 } 47 51 48 52 $encoding = "utf8" if $unicode; 49 $encoding = "extended" if $extended; 53 $encoding = "iso_8859_1" if $iso_8859_1; 54 $encoding = "iso_8859_6" if $iso_8859_6; 55 $encoding = "windows_1256" if $windows_1256; 50 56 $encoding = "gb" if $gb; 51 57 -
branches/New_Config_Format-branch/gsdl/bin/script/toutf8.pl
r630 r1279 1 #!/usr/ local/bin/perl5-w1 #!/usr/bin/perl -w 2 2 3 3 ########################################################################### … … 36 36 if (!parsargv::parse(\@ARGV, 37 37 'unicode', \$unicode, 38 'extended', \$extended, 38 'iso_8859_1', \$iso_8859_1, 39 'iso_8859_6', \$iso_8859_6, 40 'windows_1256', \$windows_1256, 39 41 'gb', \$gb)) { 40 42 print STDERR "\n usage: $0 [options]\n\n"; 41 43 print STDERR " options:\n"; 42 print STDERR " -utf8 input is in utf-8 or unicode (default)\n"; 43 print STDERR " -extended input is in extended ascii\n"; 44 print STDERR " -gb input is in GB or GBK\n\n"; 44 print STDERR " -unicode input is in utf-8 or unicode (default)\n"; 45 print STDERR " -iso_8859_1 input is in extended ascii (ISO-8859-1 Latin 1)\n"; 46 print STDERR " -iso_8859_6 input is in 8 bit Arabic (ISO-8859-6)\n"; 47 print STDERR " -windows_1256 input is in Windows 1256 (Arabic)\n"; 48 print STDERR " -gb input is in GB or GBK (simplified Chinese)\n\n"; 45 49 die "\n"; 46 50 } 47 51 48 52 $encoding = "utf8" if $unicode; 49 $encoding = "extended" if $extended; 53 $encoding = "iso_8859_1" if $iso_8859_1; 54 $encoding = "iso_8859_6" if $iso_8859_6; 55 $encoding = "windows_1256" if $windows_1256; 50 56 $encoding = "gb" if $gb; 51 57 -
branches/New_Config_Format-branch/gsdl/bin/script/translate.pl
r1062 r1279 54 54 'Ouml' => chr (214), 55 55 'Uuml' => chr (220), 56 'szlig' => chr (223)); 56 'szlig' => chr (223), 57 'aacute' => chr (225), 58 'eacute' => chr (233), 59 'iacute' => chr (237), 60 'oacute' => chr (243), 61 'uacute' => chr (250), 62 'Aacute' => chr (193), 63 'Eacute' => chr (201), 64 'Iacute' => chr (205), 65 'Oacute' => chr (211), 66 'Uacute' => chr (218), 67 'ntilde' => chr (241), 68 'Ntilde' => chr (209)); 57 69 58 70 my $hand_made = 0; … … 137 149 # process all the images 138 150 139 $dmfile =~ s/\n\#\#\s*\"([^\"]*)\"\s*\#\#\s*([^\s\#]*)\s*\#\#\s*([^\s\#]*)\s*\#\#(.*?)(?=(\n\#|\s*\Z))/ 140 &process_image ($1, $2, $3, $4)/esg; 151 $dmfile =~ s/\n\#\#\s*\"([^\"]*)\"\s*\#\#\s*([^\s\#]*)\s*\#\#\s*([^\s\#]*)\s*\#\#(.*?)(?=(\n\#|\s*\Z))/&process_image ($1, $2, $3, $4)/esg; 141 152 142 153 # add language parameter to each macro … … 150 161 151 162 my $origtext = $text; 163 $text =~ s/&(\d{3,4});/chr($1)/ge; 152 164 $text =~ s/&([^;]*);/$rmap{$1}/g; 153 165 … … 204 216 } elsif ($image_type eq "green_title") { 205 217 206 # generate green title image 218 # read the width if it is specified in $image_macros 219 my ($width) = $image_macros =~ /_width${image_name}x?_\s*[^\{]*\{(\d+)\}/; 220 $width = 200 unless ($width); 221 222 # generate green title image 207 223 my $options = "-text \"$text\" -filename ${image_name}.gif -image_dir $image_dir"; 208 $options .= " -width 200-height 57 -stripe_alignment right -text_alignment right";224 $options .= " -width $width -height 57 -stripe_alignment right -text_alignment right"; 209 225 $options .= " -fontsize 26 -fontweight bold"; 210 226 `$ENV{'GSDLHOME'}/bin/script/gimp/title_icon.pl $options`; 211 227 212 # get width of new images and edit width macro 213 # we'll do this even though title_icon.pl will always create images of the 214 # width specified (200) 215 my $fullfilename = &util::filename_cat ($image_dir, "${image_name}.gif"); 216 &process_width_macro ($fullfilename, $image_name, \$image_macros); 228 # get width of resulting image and edit _width..._ macro in $image_macros 229 # (no longer needed since we always resize to the width read from $image_macros.) 230 # my $fullfilename = &util::filename_cat ($image_dir, "${image_name}.gif"); 231 # &process_width_macro ($fullfilename, $image_name, \$image_macros); 217 232 218 233 } elsif ($image_type eq "hand_made") { … … 226 241 } 227 242 228 return "\n\#\# \"$ text\" \#\# $image_type \#\# $image_name \#\#$image_macros";243 return "\n\#\# \"$origtext\" \#\# $image_type \#\# $image_name \#\#$image_macros"; 229 244 } 230 245 … … 233 248 234 249 my $img_info = &get_img_info ($filename); 235 $$image_macros =~ s/(_width${image_name}x _\s*(?:\[[^\]]*\])?\s*\{)(\d+)(\})/$1$img_info->{'width'}$3/s;250 $$image_macros =~ s/(_width${image_name}x?_\s*(?:\[[^\]]*\])?\s*\{)(\d+)(\})/$1$img_info->{'width'}$3/s; 236 251 } 237 252
Note:
See TracChangeset
for help on using the changeset viewer.