Diff for /loncom/publisher/lonpublisher.pm between versions 1.70 and 1.76

version 1.70, 2002/01/16 19:09:31 version 1.76, 2002/04/10 15:28:45
Line 43 Line 43
 # 12/06,12/07 Gerd Kortemeyer  # 12/06,12/07 Gerd Kortemeyer
 # 12/15,12/16 Scott Harrison  # 12/15,12/16 Scott Harrison
 # 12/25 Gerd Kortemeyer  # 12/25 Gerd Kortemeyer
   # YEAR=2002
   # 1/16,1/17 Scott Harrison
   # 1/17 Gerd Kortemeyer
 #  #
 ###  ###
   
Line 65  use strict; Line 68  use strict;
 use Apache::File;  use Apache::File;
 use File::Copy;  use File::Copy;
 use Apache::Constants qw(:common :http :methods);  use Apache::Constants qw(:common :http :methods);
 use HTML::TokeParser;  use HTML::LCParser;
 use Apache::lonxml;  use Apache::lonxml;
 use Apache::lonhomework;  use Apache::lonhomework;
 use Apache::loncacc;  use Apache::loncacc;
Line 88  my $cudom; Line 91  my $cudom;
 sub metaeval {  sub metaeval {
     my $metastring=shift;      my $metastring=shift;
         
         my $parser=HTML::TokeParser->new(\$metastring);          my $parser=HTML::LCParser->new(\$metastring);
         my $token;          my $token;
         while ($token=$parser->get_token) {          while ($token=$parser->get_token) {
            if ($token->[0] eq 'S') {             if ($token->[0] eq 'S') {
Line 200  sub urlfixup { Line 203  sub urlfixup {
     }      }
     if ($url=~/^http\:\/\//) { return $url; }      if ($url=~/^http\:\/\//) { return $url; }
     $url=~s/\~$cuname/res\/$cudom\/$cuname/;      $url=~s/\~$cuname/res\/$cudom\/$cuname/;
       return $url;
   }
   
   
   sub absoluteurl {
       my ($url,$target)=@_;
       unless ($url) { return ''; }
     if ($target) {      if ($target) {
  $target=~s/\/[^\/]+$//;   $target=~s/\/[^\/]+$//;
        $url=&Apache::lonnet::hreflocation($target,$url);         $url=&Apache::lonnet::hreflocation($target,$url);
Line 247  sub publish { Line 257  sub publish {
           $content=join('',<$org>);            $content=join('',<$org>);
         }          }
         {          {
           my $parser=HTML::TokeParser->new(\$content);            my $parser=HTML::LCParser->new(\$content);
           my $token;            my $token;
           while ($token=$parser->get_token) {            while ($token=$parser->get_token) {
               if ($token->[0] eq 'S') {                if ($token->[0] eq 'S') {
Line 278  sub publish { Line 288  sub publish {
                 "Max Index: $maxindex (min 10)\n";                  "Max Index: $maxindex (min 10)\n";
       }        }
           my $outstring='';            my $outstring='';
           my $parser=HTML::TokeParser->new(\$content);            my $parser=HTML::LCParser->new(\$content);
           $parser->xml_mode(1);            $parser->xml_mode(1);
           my $token;            my $token;
           while ($token=$parser->get_token) {            while ($token=$parser->get_token) {
Line 304  sub publish { Line 314  sub publish {
                               print $logfile 'Index: '.$tag.':'.$maxindex."\n";                                print $logfile 'Index: '.$tag.':'.$maxindex."\n";
   }    }
       }        }
   }     }
                     
                   foreach ('src','href','background') {                    foreach my $type ('src','href','background','bgimg') {
                       if (defined($parms{$_})) {        foreach my $key (keys(%parms)) {
   my $oldurl=$parms{$_};    if ($key =~ /^$type$/i) {
                           my $newurl=&urlfixup($oldurl,$target);        my $oldurl=$parms{$key};
                           if ($newurl ne $oldurl) {        my $newurl=&urlfixup($oldurl,$target);
       $parms{$_}=$newurl;        if ($newurl ne $oldurl) {
                               print $logfile 'URL: '.$tag.':'.$oldurl.' - '.    $parms{$key}=$newurl;
   $newurl."\n";    print $logfile 'URL: '.$tag.':'.$oldurl.' - '.
         $newurl."\n";
         }
         if (($newurl !~ /^javascript:/i) &&
     ($newurl !~ /^mailto:/i) &&
     ($newurl !~ /^http:/i) &&
     ($newurl !~ /^\#/)) {
     $allow{&absoluteurl($newurl,$target)}=1;
         }
   }    }
                           $allow{$newurl}=1;    last;
                       }        }
                   }                    }
   
                   if ($lctag eq 'applet') {                    if ($lctag eq 'applet') {
Line 334  sub publish { Line 352  sub publish {
                                   $oldcodebase.' - '.                                    $oldcodebase.' - '.
   $codebase."\n";    $codebase."\n";
  }   }
                          $allow{$codebase.'/*'}=1;                           $allow{&absoluteurl($codebase,$target).'/*'}=1;
       } else {        } else {
                         foreach ('archive','code','object') {                          foreach ('archive','code','object') {
                           if (defined($parms{$_})) {                            if (defined($parms{$_})) {
Line 344  sub publish { Line 362  sub publish {
                                   print $logfile 'Allow: applet '.$_.':'.                                    print $logfile 'Allow: applet '.$_.':'.
                                   $oldurl.' allows '.                                    $oldurl.' allows '.
   $newurl."\n";    $newurl."\n";
                               $allow{$newurl}=1;                                $allow{&absoluteurl($newurl,$target)}=1;
                           }                            }
                         }                          }
                       }                        }
Line 379  sub publish { Line 397  sub publish {
           
  $scrout.='<h3>Dependencies</h3>';   $scrout.='<h3>Dependencies</h3>';
         my $allowstr='';          my $allowstr='';
         foreach (keys %allow) {          foreach (sort(keys(%allow))) {
    my $thisdep=$_;     my $thisdep=$_;
      if ($thisdep !~ /[^\s]/) { next; }
            unless ($style eq 'rat') {              unless ($style eq 'rat') { 
               $allowstr.="\n".'<allow src="'.$thisdep.'" />';                $allowstr.="\n".'<allow src="'.$thisdep.'" />';
    }     }
Line 407  sub publish { Line 426  sub publish {
        }         }
            }             }
         }          }
           $allowstr=~s/\n+/\n/g;
         $outstring=~s/(\<\/[^\>]+\>\s*)$/$allowstr$1/s;          $outstring=~s/(\<\/[^\>]+\>\s*)$/$allowstr$1/s;
   
    #Encode any High ASCII characters
    $outstring=&HTML::Entities::encode($outstring,"\200-\377");
 # ------------------------------------------------------------- Write modified  # ------------------------------------------------------------- Write modified
   
         {          {
Line 578  sub publish { Line 600  sub publish {
                       $keywordout.=' checked';                         $keywordout.=' checked'; 
                    }                     }
         } elsif (&Apache::loncommon::keyword($_)) {          } elsif (&Apache::loncommon::keyword($_)) {
     $keywordout.=' checked';              $keywordout.=' checked';
                 }                   } 
                 $keywordout.='>'.$_.'</td>';                  $keywordout.='>'.$_.'</td>';
                 if ($colcount>10) {                  if ($colcount>10) {
Line 702  sub phasetwo { Line 724  sub phasetwo {
                $value=~s/\"/\'\'/g;                 $value=~s/\"/\'\'/g;
                print $mfh ' '.$_.'="'.$value.'"';                 print $mfh ' '.$_.'="'.$value.'"';
            }             }
    print $mfh '>'.$metadatafields{$unikey}.'</'.$tag.'>';     print $mfh '>'.
        &HTML::Entities::encode($metadatafields{$unikey})
          .'</'.$tag.'>';
          }           }
        }         }
        $scrout.='<p>Wrote Metadata';         $scrout.='<p>Wrote Metadata';
Line 927  if (-e $target) { Line 951  if (-e $target) {
   
   
     return $warning.$scrout.      return $warning.$scrout.
       '<hr><a href="'.$thisdistarget.'"><font size=+2>View Target</font></a>'.        '<hr><a href="'.$thisdistarget.'"><font size=+2>View Published Version</font></a>'.
       '<p><a href="'.$thissrc.'"><font size=+2>Back to Source</font></a>'.        '<p><a href="'.$thissrc.'"><font size=+2>Back to Source</font></a>'.
       '<p><a href="'.$thissrcdir.        '<p><a href="'.$thissrcdir.
       '"><font size=+2>Back to Source Directory</font></a>';        '"><font size=+2>Back to Source Directory</font></a>';

Removed from v.1.70  
changed lines
  Added in v.1.76


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>