--- rat/lonpage.pm 2000/10/10 20:34:09 1.11 +++ rat/lonpage.pm 2000/10/16 09:46:23 1.12 @@ -5,7 +5,7 @@ # # 05/29/00,05/30 Gerd Kortemeyer) # 08/30,08/31,09/06,09/14,09/15,09/16,09/19,09/20,09/21,09/23, -# 10/02,10/10 Gerd Kortemeyer +# 10/02,10/10,10/14,10/16 Gerd Kortemeyer package Apache::lonpage; @@ -205,8 +205,10 @@ sub handler { my $output=Apache::lonnet::ssi($src,%posthash); my $parser=HTML::TokeParser->new(\$output); my $token; + my $thisdir=$src; my $bodydef=0; my $thisxml=0; + my @rlinks=(); if ($output=~/\?xml/) { $isxml=1; $thisxml=1; @@ -214,9 +216,22 @@ sub handler { /((?:\<(?:\?xml|\!DOC|html)[^\>]*(?:\>|\>\]\>)\s*)+)\]*\>/si; $xmlheader=$1; } - while (($bodydef==0) && - ($token=$parser->get_token)) { - if ($token->[1] eq 'body') { + while ($token=$parser->get_token) { + if ($token->[0] eq 'S') { + if ($token->[1] eq 'a') { + if ($token->[2]->{'href'}) { + $rlinks[$#rlinks+1]= + $token->[2]->{'href'}; + } + } elsif ($token->[1] eq 'img') { + $rlinks[$#rlinks+1]= + $token->[2]->{'src'}; + } elsif ($token->[1] eq 'embed') { + $rlinks[$#rlinks+1]= + $token->[2]->{'src'}; + } elsif ($token->[1] eq 'base') { + $thisdir=$token->[2]->{'href'}; + } elsif ($token->[1] eq 'body') { $bodydef=1; $ssibgcolor{$_}=$token->[2]->{'bgcolor'}; $ssitext{$_}=$token->[2]->{'text'}; @@ -226,15 +241,15 @@ sub handler { if ($thisxml) { $xmlbody=$token->[4]; } - } - if ($token->[1] eq 'meta') { + } elsif ($token->[1] eq 'meta') { $allmeta.="\n".$token->[4].''; - } - if ($token->[1] eq 'script') { + } elsif (($token->[1] eq 'script') && + ($bodydef==0)) { $allscript.="\n\n" .$parser->get_text('/script'); } - } + } + } if ($output=~/\]*\>(.*)/si) { $output=$1; } @@ -244,6 +259,16 @@ sub handler { $output=~s/\]*\>//gsi; $output=~s/\<\/form[^\>]*\>//gsi; } + $thisdir=~s/\/[^\/]*$//; + map { + unless (($_=~/^http:\/\//i) || + ($_=~/^\//)) { + my $newlocation= + &Apache::lonnet::hreflocation($thisdir,$_); + $output=~s/(\"|\'|\=\s*)$_(\"|\'|\s|\>)/$1$newlocation$2/; + } + } @rlinks; + $output=~s/\<\s*applet/\