Changeset 9143


Ignore:
Timestamp:
2005-02-23T10:08:05+13:00 (19 years ago)
Author:
davidb
Message:

Added handling of <embed> tag in a similar fashion to <img>

Also, problem found in handling of URLs extracted in <a>, <img> etc.
tags. Lost leading /. Now fixed.

File:
1 edited

Legend:

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

    r9125 r9143  
    182182    my @usemap_matches = ($$textref =~ m/<img[^>]*?usemap\s*=\s*($attval)[^>]*>/igs);
    183183    my @link_matches = ($$textref =~ m/<link[^>]*?href\s*=\s*($attval)[^>]*>/igs);
    184    
    185 
    186     foreach my $link (@img_matches, @usemap_matches, @link_matches) {
     184    my @embed_matches = ($$textref =~ m/<embed[^>]*?src\s*=\s*($attval)[^>]*>/igs);
     185
     186    foreach my $link (@img_matches, @usemap_matches, @link_matches, @embed_matches) {
    187187
    188188    # remove quotes from link at start and end if necessary
     
    194194    $link =~ s/\#.*$//s; # remove any anchor names, e.g. foo.html#name becomes foo.html
    195195
    196     if ($link !~ s@^/@@ && $link !~ /^([A-Z]:?)\\/) {
     196    if ($link !~ m@^/@ && $link !~ m/^([A-Z]:?)\\/) {
    197197        # Turn relative file path into full path
    198198        my $dirname = &File::Basename::dirname($filename);
     
    200200    }
    201201    $link = $self->eval_dir_dots($link);
     202   
    202203    $self->{'file_blocks'}->{$link} = 1;
    203204    }
     
    238239    my $web_url = "http://$file";
    239240    $doc_obj->add_metadata($cursection, "URL", $web_url);
     241    $doc_obj->add_metadata($cursection, "weblink", "<a href=\"$web_url\">");
     242    $doc_obj->add_metadata($cursection, "webicon", "_iconworld_");
     243    $doc_obj->add_metadata($cursection, "/weblink", "</a>");
    240244
    241245    if ($self->{'description_tags'}) {
     
    397401
    398402    # allow spaces if inside quotes - jrm21
    399     $$textref =~ s/(<img[^>]*?src\s*=\s*)(\"[^\"]+\"|[^\s>]+)([^>]*>)/
     403    $$textref =~ s/(<(?:img|embed)[^>]*?src\s*=\s*)(\"[^\"]+\"|[^\s>]+)([^>]*>)/
    400404    $self->replace_images ($1, $2, $3, $base_dir, $file, $doc_obj, $cursection)/isge;
    401405
     
    430434
    431435    my ($href, $hash_part, $rl) = $self->format_link ($link, $base_dir, $file);
    432    
     436
    433437    my $img_file =  $self->add_file ($href, $rl, $hash_part, $base_dir, $doc_obj, $section);
     438
    434439    my $anchor_name = $img_file;
    435440    $anchor_name =~ s/^.*\///;
     
    503508
    504509    my ($ext) = $filename =~ /(\.[^\.]*)$/;
     510
     511    if ($rl == 0) {
     512    if ((!defined $ext) || ($ext !~ /$self->{'assoc_files'}/)) {
     513        return "_httpextlink_&rl=0&el=prompt&href=" . $href . $hash_part;
     514    }
     515    else {
     516        return "_httpextlink_&rl=0&el=direct&href=" . $href . $hash_part;
     517    }
     518    }
    505519
    506520    if ((!defined $ext) || ($ext !~ /$self->{'assoc_files'}/)) {
     
    592606        }
    593607        else {
     608            # before_hash has lost leading slash by this point,
     609            # -> add back in prior to substitution with $base_dir
     610            $before_hash = "/$before_hash";
     611
    594612            $before_hash = &util::filename_cat("",$before_hash);
    595613            $before_hash =~ s@^$base_dir/@@;
Note: See TracChangeset for help on using the changeset viewer.