Changeset 27703

Show
Ignore:
Timestamp:
25.06.2013 16:36:58 (6 years ago)
Author:
ak19
Message:

Dr Bainbridge fixed the final diffcol issue with Small-HTML on windows where links in the body of the text had backslashes on Windows. They needed to be linux style slashes. The code change and logic was slightly more complicated as the links were used to test whether referenced files existed on the file system and were therefore relative (to the GS collection) or external links.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/HTMLPlugin.pm

    r27306 r27703  
    796796    my $img_file =  $self->add_file ($href, $rl, $hash_part, $base_dir, $doc_obj, $section); 
    797797 
    798 #    print STDERR "**** link = $link\n**** href = $href\n**** img_file = $img_file, rl = $rl\n"; 
     798#    print STDERR "**** link = $link\n**** href = $href\n**** img_file = $img_file, rl = $rl\n\n"; 
    799799 
    800800    my $anchor_name = $img_file; 
     
    980980    $filename =~ s/^[^:]*:\/\///; 
    981981    } 
    982  
     982     
     983    if ($ENV{'GSDLOS'} =~ m/^windows$/i) { 
     984        $filename =~ s@\/@\\@g; 
     985    } 
     986     
    983987    $filename = &FileUtils::filenameConcatenate($base_dir, $filename); 
    984988 
     
    11291133    if ($before_hash =~ s@^((?:http|https|ftp|file|mms)://)@@i) { 
    11301134        my $type = $1; 
    1131  
     1135        my $before_hash_file = $before_hash; 
     1136         
    11321137    if ($link =~ m/^(http|ftp):/i) { 
     1138         
    11331139        # Turn url (using /) into file name (possibly using \ on windows) 
    1134         my @http_dir_split = split('/', $before_hash); 
    1135         $before_hash = &FileUtils::filenameConcatenate(@http_dir_split); 
    1136     } 
    1137  
    1138     $before_hash = $self->eval_dir_dots($before_hash); 
    1139      
    1140     my $linkfilename = &FileUtils::filenameConcatenate($base_dir, $before_hash); 
     1140        my @http_dir_split = split('/', $before_hash_file); 
     1141        $before_hash_file = &FileUtils::filenameConcatenate(@http_dir_split);        
     1142    } 
     1143     
     1144    # want to maintain two version of "before_hash": one representing the URL, the other using filesystem specific directory separator 
     1145    $before_hash_file = $self->eval_dir_dots($before_hash_file); 
     1146    my $before_hash_url = $before_hash_file; 
     1147    if ($ENV{'GSDLOS'} =~ /^windows$/i) { 
     1148        $before_hash_url =~ s@\\@\/@g; 
     1149    } 
     1150     
     1151    my $linkfilename = &FileUtils::filenameConcatenate($base_dir, $before_hash_file); 
    11411152     
    11421153    my $rl = 0; 
     
    11441155 
    11451156    # make sure there's a slash on the end if it's a directory 
    1146     if ($before_hash !~ m/\/$/) { 
    1147         $before_hash .= "/" if (-d $linkfilename); 
    1148     } 
    1149     return ($type . $before_hash, $hash_part, $rl); 
     1157    if ($before_hash_url !~ m/\/$/) { 
     1158        $before_hash_url .= "/" if (-d $linkfilename); 
     1159    } 
     1160    return ($type . $before_hash_url, $hash_part, $rl); 
    11501161     
    11511162    } elsif ($link !~ m/^(mailto|news|gopher|nntp|telnet|javascript):/i && $link !~ m/^\//) { 
     
    11911202        my $dirname = &File::Basename::dirname($file); 
    11921203        $before_hash = &FileUtils::filenameConcatenate($dirname, $before_hash); 
    1193         $before_hash = $self->eval_dir_dots($before_hash);               
     1204        $before_hash = $self->eval_dir_dots($before_hash);    
     1205        $before_hash =~ s@\\@/@g; # for windows          
    11941206    } 
    11951207