Changeset 3019
- Timestamp:
- 2002-02-27T18:57:30+13:00 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/HTMLPlug.pm
r2995 r3019 141 141 my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj) = @_; 142 142 my $outhandle = $self->{'outhandle'}; 143 144 143 print $outhandle "HTMLPlug: processing $file\n" 145 144 if $self->{'verbosity'} > 1; 146 145 146 if ($ENV{'GSDLOS'} =~ /^windows/i) { 147 # this makes life so much easier... perl can cope with unix-style '/'s. 148 $base_dir =~ s@(\\)+@/@g; 149 $file =~ s@(\\)+@/@g; 150 } 147 151 my $cursection = $doc_obj->get_top_section(); 148 152 … … 155 159 # like when w3mir is used to download a website). 156 160 my $web_url = "http://$file"; 157 $web_url =~ s/\\/\//g; # for windows158 161 $doc_obj->add_utf8_metadata($cursection, "URL", $web_url); 159 162 … … 258 261 my $self = shift (@_); 259 262 my ($textref, $base_dir, $file, $doc_obj, $cursection) = @_; 260 261 263 # trap links 262 264 if (!$self->{'nolinks'}) { … … 277 279 278 280 # add text to document object 281 # turn \ into \\ so that the rest of greenstone doesn't think there 282 # is an escape code following. (Macro parsing loses them...) 283 $$textref =~ s/\\/\\\\/go; 279 284 $doc_obj->add_utf8_text($cursection, $$textref); 280 285 } … … 350 355 $filename =~ s/^[^:]*:\/\///; 351 356 $filename = &util::filename_cat($base_dir, $filename); 352 357 353 358 my ($ext) = $filename =~ /(\.[^\.]*)$/; 354 359 … … 391 396 } 392 397 393 if ($before_hash =~ s /^((?:http|ftp|file):\/\/)//i) {398 if ($before_hash =~ s@^((?:http|ftp|file)://)@@i) { 394 399 my $type = $1; 395 400 … … 415 420 416 421 } elsif ($link !~ /^(mailto|news|gopher|nntp|telnet|javascript):/i) { 417 if ($before_hash =~ s /^\///|| $before_hash =~ /\\/) {422 if ($before_hash =~ s@^/@@ || $before_hash =~ /\\/) { 418 423 419 424 # the first directory will be the domain name if file_is_url 420 425 # to generate archives, otherwise we'll assume all files are 421 426 # from the same site and base_dir is the root 422 # This is not called in Windows 427 423 428 if ($self->{'file_is_url'}) { 424 429 my @dirs = split /[\/\\]/, $file; 425 430 my $domname = shift (@dirs); 426 431 $before_hash = &util::filename_cat($domname, $before_hash); 427 $before_hash =~ s /\\/\//g; # for windows432 $before_hash =~ s@\\@/@g; # for windows 428 433 } 429 434 else … … 431 436 # see if link shares directory with source document 432 437 # => turn into relative link if this is so! 433 my $before_hash_fix = "";434 438 435 # filename_cat appends / or \ to the beginning of the436 # file pathname but in Windows we don't want to do that437 439 if ($ENV{'GSDLOS'} =~ /^windows/i) { 438 $before_hash_fix = $before_hash; 440 # too difficult doing a pattern match with embedded '\'s... 441 my $win_before_hash=$before_hash; 442 $win_before_hash =~ s@(\\)+@/@g; 443 # $base_dir is already similarly "converted" on windows. 444 if ($win_before_hash =~ s@^$base_dir/@@o) { 445 # if this is true, we removed a prefix 446 $before_hash=$win_before_hash; 447 } 448 439 449 } 440 450 else { 441 $before_hash_fix = &util::filename_cat("",$before_hash); 442 } 443 444 my $base_dir_win_match = $base_dir; 445 $base_dir_win_match =~ s/\\/\\\\/g; 446 447 $before_hash_fix =~ s/^$base_dir_win_match(\\|\/)//; 448 $before_hash = $before_hash_fix; 451 $before_hash = &util::filename_cat("",$before_hash); 452 $before_hash =~ s@^$base_dir/@@; 453 } 449 454 450 455 } … … 665 670 &BasPlug::read_file($self, $filename, $encoding, $language, $textref); 666 671 667 # turn \ into \\ so that the rest of greenstone doesn't think there668 # is an escape code following.669 $$textref =~ s/\\/\\\\/go;670 672 671 673 # Convert things like é to their UTF8 equivalents
Note:
See TracChangeset
for help on using the changeset viewer.