Changeset 965


Ignore:
Timestamp:
02/23/00 09:46:16 (21 years ago)
Author:
sjboddie
Message:

fixed bug - added assoc_files option

File:
1 edited

Legend:

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

    r900 r965  
    7171    print STDERR "   -w3mir                 Set if w3mir was used to generate input file structure.\n";
    7272    print STDERR "                          w3mir \n";
     73    print STDERR "   -assoc_files           Perl regular expression of file extensions to associate with\n";
     74    print STDERR "                          html documents. Defaults to '(?i)\.(jpe?g|gif|png|css|pdf)$'\n";
    7375    print STDERR "   -rename_assoc_files    Renames files associated with documents (e.g. images). Also\n";
    7476    print STDERR "                          creates much shallower directory structure (useful when creating\n";
     
    8890             q^metadata_fields/.*/Title^, \$self->{'metadata_fields'},
    8991             q^w3mir^, \$self->{'w3mir'},
     92             q^assoc_files/.*/(?i)\.(jpe?g|gif|png|css|pdf)$^, \$self->{'assoc_files'},
    9093             q^rename_assoc_files^, \$self->{'rename_assoc_files'})) {
    9194    &print_usage();
     
    134137    $/ = "\n";
    135138    close FILE;
    136     if ($text !~ /\w/) {
     139    if (!defined $text || $text !~ /\w/) {
    137140    print STDERR "HTMLPlug: ERROR: $file contains no text\n" if $self->{'verbosity'};
    138141    return 0;
     
    191194   
    192195    my ($href, $hash_part, $rl) = $self->format_link ($link, $base_dir, $file);
    193     return $front . $self->add_file ($href, $base_dir, $doc_obj, $section) . $back;
     196    return $front . $self->add_file ($href, $rl, $hash_part, $base_dir, $doc_obj, $section) . $back;
    194197}
    195198
     
    234237    # link is to some other type of file (image, pdf etc.) so we'll
    235238    # need to associate that file
    236     return $front . $self->add_file ($href, $base_dir, $doc_obj, $section) . $back;
     239    return $front . $self->add_file ($href, $rl, $hash_part, $base_dir, $doc_obj, $section) . $back;
    237240    }
    238241}
     
    240243sub add_file {
    241244    my $self = shift (@_);
    242     my ($href, $base_dir, $doc_obj, $section) = @_;
     245    my ($href, $rl, $hash_part, $base_dir, $doc_obj, $section) = @_;
    243246    my ($newname);
    244247
     
    247250    $filename = &util::filename_cat ($base_dir, $filename);
    248251    my ($ext) = $filename =~ /(\.[^\.]*)$/;
     252
     253    if ((!defined $ext) || ($ext !~ /$self->{'assoc_files'}/)) {
     254    return "_httpextlink_&rl=" . $rl . "&href=" . $href . $hash_part;
     255    }
     256
    249257    if ($self->{'rename_assoc_files'}) {
    250258    if (defined $self->{'aux_files'}->{$href}) {
     
    253261    } else {
    254262        $newname = $self->{'dir_num'} . "/" . $self->{'file_num'} . $ext;
     263        $self->{'aux_files'}->{$href} = {'dir_num' => $self->{'dir_num'}, 'file_num' => $self->{'file_num'}};
    255264        $self->inc_filecount ();
    256265    }
Note: See TracChangeset for help on using the changeset viewer.