Ignore:
Timestamp:
2005-02-16T16:26:34+13:00 (19 years ago)
Author:
kjdon
Message:

moved smart blocking stuff in htmlplug metadata_read into basplug metadata read. htmlplug now just needs to implement store_block_files. basplug smart block will block a cover image if -cover_images is on. Converttoplug store_block_files needs to call the basplug default one (do nothing) cos it doesn't want to use the html specific one. Image plug needs to implement store_cover_image to do nothing cos it doesn'tmake sense

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/BasPlug.pm

    r8915 r9067  
    6969    'type' => "regexp",
    7070    'deft' => "",
     71    'reqd' => "no" },
     72      { 'name' => "smart_block",
     73    'desc' => "{BasPlug.smart_block}",
     74    'type' => "flag",
    7175    'reqd' => "no" },
    7276      { 'name' => "associate_ext",
     
    428432}
    429433
     434# default implementation is to do nothing.
     435sub store_block_files
     436{
     437    my $self =shift (@_);
     438    my ($filename) = @_;
     439    return;
     440}
     441
     442#default implementation is to block a file with same name as this, but extension jpg or JPG, if cover_images is on.
     443sub block_cover_image
     444{
     445    my $self =shift (@_);
     446    my ($filename) = @_;
     447    if ($self->{'cover_image'}) {
     448    my $coverfile = $filename;
     449    $coverfile =~ s/\.[^\\\/\.]+$/\.jpg/;
     450    if (!-e $coverfile) {
     451        $coverfile =~ s/jpg$/JPG/;
     452    }   
     453    if (-e $coverfile) {
     454        $self->{'file_blocks'}->{$coverfile} = 1;
     455    }
     456    }
     457
     458    return;
     459}
     460   
    430461sub metadata_read {
    431462    my $self = shift (@_); 
    432463    my ($pluginfo, $base_dir, $file, $metadata, $extrametakeys, $extrametadata, $processor, $maxdocs, $gli) = @_;
    433 
    434464    # Keep track of filenames with same root but different extensions
    435     # Used to support -assoicate_ext
     465    # Used to support -associate_ext
    436466
    437467    my $associate_ext = $self->{'associate_ext'};
     
    460490    }
    461491    }
    462 
    463     return undef;
     492   
     493    # now check whether we are actually processing this
     494    my $filename = $file;
     495    $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
     496    if ($self->{'process_exp'} eq "" || $filename !~ /$self->{'process_exp'}/ || !-f $filename) {
     497    return undef; # can't recognise
     498    }
     499
     500    # do smart blocking if appropriate
     501    if (defined $self->{'smart_block'}) {
     502    $self->block_cover_image($filename);
     503    $self->store_block_files($filename);
     504    }
     505       
     506    return 1;
    464507}
    465508
Note: See TracChangeset for help on using the changeset viewer.