Ignore:
Timestamp:
2008-10-23T09:11:16+13:00 (16 years ago)
Author:
kjdon
Message:

removed the create_images option and its code. Relies on a script we no longer provide, and the title images are created on the fly anyway using text over background image

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/bin/script/buildcol.pl

    r17118 r17570  
    2020# along with this program; if not, write to the Free Software
    2121# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    22 #
    23 # @note 11/04/03 Added usage datastructure - John Thompson
    2422#
    2523# @author New Zealand Digital Library Project unless otherwise stated
     
    6361no strict 'subs'; # allow barewords (eg STDERR) as function arguments
    6462
    65 # used in updating Collectionconfig.xml in create_images()
    66 use Twig;
    6763
    6864my $mode_list =
     
    118114    'reqd' => "no",
    119115        'hiddengli' => "yes" },
    120       { 'name' => "create_images",
    121     'desc' => "{buildcol.create_images}",
    122     'type' => "flag",
    123     'reqd' => "no",
    124     'modegli' => "4" },
    125116      { 'name' => "debug",
    126117    'desc' => "{buildcol.debug}",
     
    285276    $debug, $mode, $indexname, $removeold, $keepold, $incremental,
    286277    $remove_empty_classifications,
    287     $create_images, $collectdir, $build, $type, $textindex,
     278    $collectdir, $build, $type, $textindex,
    288279    $no_strip_html, $no_text, $faillog, $gli, $index, $language,
    289280    $sections_index_document_metadata, $maxnumeric,
     
    443434    }
    444435   
    445    
    446     if (defined $collectcfg->{'create_images'} && $collectcfg->{'create_images'} =~ /^true$/i) {
    447     $create_images = 1;
    448     }
    449436    if ($buildtype eq "mgpp" && defined $collectcfg->{'textcompress'}) {
    450437    $textindex = $collectcfg->{'textcompress'};
     
    482469    else {
    483470    $textindex = "section:text";
    484     }
    485 
    486     # create default images if required
    487     if ($create_images) {
    488     my $collection_name = $collection;
    489     $collection_name = $collectcfg->{'collectionmeta'}->{'collectionname'}->{'default'}
    490     if defined $collectcfg->{'collectionmeta'}->{'collectionname'}->{'default'};
    491     &create_images ($collection_name);
    492471    }
    493472
     
    612591## main() ##
    613592
    614 ## @method create_images()
    615 #
    616 #  [Used to create default cover images... from what I'm not quite sure - John]
    617 #
    618 sub create_images {
    619     my ($collection_name) = @_;
    620 
    621     my $image_script = &util::filename_cat ($ENV{'GSDLHOME'}, "bin", "script", "gimp", "title_icon-1.2.pl");
    622     if (!-e $image_script) {
    623     &gsprintf($out, "{buildcol.no_image_script}", $image_script);
    624     &gsprintf($out, "{buildcol.no_default_images}\n\n");
    625     return;
    626     }
    627 
    628     my $imagedir = &util::filename_cat ($ENV{'GSDLCOLLECTDIR'}, "images");
    629 
    630     &util::mk_all_dir ($imagedir);
    631 
    632     # create the images
    633     system ("$image_script -size 1.5 -image_dir \"$imagedir\" -filename $collection.gif -text \"$collection_name\"");
    634     system ("$image_script -image_dir \"$imagedir\" -filename ${collection}sm.gif -text \"$collection_name\"");
    635 
    636     if ($gs_mode eq "gs3") {
    637     # update the CollectionConfig.xml file
    638     # what we need to do is find in CollectionConfig.xml the two elements with attributes 'icon' and 'smallicon'
    639     # and replace the node text with $collection.gif and ${collection}sm.gif respectively. If they don't exist,
    640     # create new ones by using the image names.
    641 
    642 
    643     my $found = 0; my $foundsm = 0;
    644    
    645     my $twig = XML::Twig->new();
    646     $twig->parsefile($configfilename);
    647     my $root = $twig->root;
    648     my $displayItemList = $root->first_child('displayItemList');
    649     my @displayItem = $displayItemList->children('displayItem');
    650     foreach my $displayItem (@displayItem) {
    651         my $att_value = $displayItem->{'att'}->{'name'};
    652        
    653         if($att_value eq 'icon') {
    654         $found = 1;
    655         }
    656         elsif ( $att_value eq 'smallicon') {
    657         $foundsm = 1;
    658         }
    659     }
    660 
    661     if ($found eq 0) { print "write icon";
    662         my $icon_displayItem_element = XML::Twig::Elt->new('displayItem');
    663         $icon_displayItem_element->set_att('name', '$collection.gif');
    664         $icon_displayItem_element->set_att('lang', 'en');
    665         $icon_displayItem_element->set_text("$collection.gif");
    666         $icon_displayItem_element->paste('last_child', $displayItemList);
    667     }
    668     if ($foundsm eq 0) {
    669         my $smallicon_displayItem_element = XML::Twig::Elt->new('displayItem');
    670         $smallicon_displayItem_element->set_att('name', 'smallicon');
    671         $smallicon_displayItem_element->set_att('lang', 'en');
    672         $smallicon_displayItem_element->set_text("${collection}sm.gif");
    673         $smallicon_displayItem_element->paste('last_child', $displayItemList);
    674        
    675        
    676     }
    677     open (OUT, ">$configfilename") or die "cannot open file $configfilename for output: $!";
    678     #select OUT;
    679     $twig->print( \*OUT );
    680     close OUT;
    681     return;
    682     }
    683 
    684     # update the collect.cfg configuration file (this will need
    685     # to be changed when the config file format changes)
    686     if (!open (CFGFILE, $configfilename)) {
    687     &gsprintf($out, "{buildcol.cannot_open_cfg_file}\n", $configfilename);
    688     &gsprintf($out, "{buildcol.unlinked_col_images}\n");
    689     return;
    690     }
    691 
    692     my $line = ""; my $file = "";
    693     my $found = 0; my $foundsm = 0;
    694     while (defined ($line = <CFGFILE>)) {
    695     if ($line =~ /collectionmeta\s+iconcollection\s+/) {
    696         $line = "collectionmeta iconcollection _httpprefix_/collect/$collection/images/$collection.gif\n";
    697         $found = 1;
    698     } elsif ($line =~ /collectionmeta\s+iconcollectionsmall\s+/) {
    699         $line = "collectionmeta iconcollectionsmall _httpprefix_/collect/$collection/images/${collection}sm.gif\n";
    700         $foundsm = 1;
    701     }
    702     $file .= $line;
    703     }
    704     close CFGFILE;
    705 
    706     $file .= "collectionmeta iconcollection _httpprefix_/collect/$collection/images/$collection.gif\n" if !$found;
    707     $file .= "collectionmeta iconcollectionsmall _httpprefix_/collect/$collection/images/${collection}sm.gif\n" if !$foundsm;
    708 
    709     if (!open (CFGFILE, ">$configfilename")) {
    710     &gsprintf($out, "{buildcol.cannot_open_cfg_file}\n", $configfilename);
    711     &gsprintf($out, "{buildcol.unlinked_col_images}\n");
    712     return;
    713     }
    714     print CFGFILE $file;
    715     close CFGFILE;
    716 }
    717 ## create_images() ##
    718593
    719594## @method make_absolute()
Note: See TracChangeset for help on using the changeset viewer.