Changeset 8510


Ignore:
Timestamp:
2004-11-11T13:59:37+13:00 (19 years ago)
Author:
chi
Message:

Add a new method metadat_read to deal with specific (or external) metadata in the first pass. Also, provide a smart_block option to store associated images and stylesheet files for each of html files. This is intended to provide a better soultion when there are multiple types of files in a single data item.

File:
1 edited

Legend:

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

    r8166 r8510  
    319319             q^cover_image^, \$self->{'cover_image'},
    320320             q^separate_cjk^, \$self->{'separate_cjk'},
     321             q^smart_block^, \$self->{'smart_block'},
    321322             "allow_extra_options")) {
    322323
     
    325326    die "\n";
    326327    }
     328    $self->{'file_blocks'} = {};
    327329
    328330    return bless $self, $class;
     
    388390
    389391    return "";
     392}
     393
     394sub metadata_read {
     395    my $self = shift (@_); 
     396    my ($pluginfo, $base_dir, $file, $metadata, $extrametakeys, $extrametadata, $processor, $maxdocs, $gli) = @_;
     397    return undef;
    390398}
    391399
     
    413421    &gsprintf(STDERR, "{BasPlug.read_must_be_implemented}") && die "\n";
    414422    }
     423    my $smart_block = $self->{'smart_block'};
    415424
    416425    my $outhandle = $self->{'outhandle'};
     
    419428    $filename = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
    420429
    421     if ($self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/) {
     430
     431    if ($smart_block){
     432    if (defined $self->{'file_blocks'}->{$filename} && $self->{'file_blocks'}->{$filename} == 1){
     433        return 0; # blocked
     434    }
     435    } elsif ($self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/) {
    422436    $self->{'num_blocked'} ++;
    423437    return 0; # blocked
    424438    }
     439   
    425440    if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) {
    426441    return undef; # can't recognise
     
    440455
    441456    my ($filemeta) = $file =~ /([^\\\/]+)$/;
     457
    442458    # how do we know what encoding the filename is in?
    443459    $doc_obj->add_metadata($doc_obj->get_top_section(), "Source", &ghtml::dmsafe($filemeta));
     
    464480    # include any metadata passed in from previous plugins
    465481    # note that this metadata is associated with the top level section
     482
    466483    $self->extra_metadata ($doc_obj, $doc_obj->get_top_section(), $metadata);
    467484
     
    553570    return $file_derived_title;
    554571}
    555 
    556572
    557573sub title_fallback
     
    722738    foreach my $field (keys(%$metadata)) {
    723739    # $metadata->{$field} may be an array reference
    724     if (ref ($metadata->{$field}) eq "ARRAY") {
     740
     741    if ($field eq "gsdlassocfile_tobe") {
     742        # 'gsdlassocfile_tobe' is artificially introduced metadata
     743        # that is used to signal that certain additional files should
     744        # be tied to this document.  Useful in situations where a
     745        # metadata pass in the plugin pipeline works out some files
     746        # need to be associated with a document, but the document hasn't
     747        # been formed yet.
     748       
     749        my $equiv_form = "";
     750        foreach my $gaf (@{$metadata->{$field}}) {
     751        #print STDERR "**** gsdlassocfile_tobe = $gaf\n";
     752        my ($full_filename,$mimetype) = ($gaf =~ m/^(.*):(.*):$/);
     753        my ($tail_filename) = ($full_filename =~ /^.*[\/\\](.+?)$/);
     754        my $filename = $full_filename;
     755                 
     756        $doc_obj->associate_file($full_filename,$tail_filename,$mimetype);
     757       
     758        my ($doc_ext) = ($tail_filename =~ m/^.*\.(.*)$/);
     759        my $start_doclink = "<a href=\"_httpcollection_/index/assoc/[archivedir]/$tail_filename\">";
     760        my $srcicon = "_icon".$doc_ext."_";
     761        my $end_doclink = "</a>";
     762
     763        $equiv_form .= " $start_doclink\{If\}{$srcicon,$srcicon,$doc_ext\}$end_doclink";       
     764        }
     765        $doc_obj->add_utf8_metadata ($cursection, "equivlink", $equiv_form);
     766    }
     767    elsif (ref ($metadata->{$field}) eq "ARRAY") {
    725768        map {
    726769        $doc_obj->add_utf8_metadata ($cursection, $field, $_);
Note: See TracChangeset for help on using the changeset viewer.