[LON-CAPA-cvs] cvs: loncom /interface londocs.pm lonprintout.pm /lonnet/perl lonnet.pm rat lonpage.pm lonuserstate.pm

raeburn raeburn at source.lon-capa.org
Mon Mar 2 20:16:39 EST 2020


raeburn		Tue Mar  3 01:16:39 2020 EDT

  Modified files:              
    /rat	lonuserstate.pm lonpage.pm 
    /loncom/interface	londocs.pm lonprintout.pm 
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - URL for external resources in uploaded .page ("Composite page") changed
    to begin /ext/ (but are not wrapped).
  - Printouts of external resources include title of item in course, and link
    unless encrypturl is set to yes for the resource.
  
  
-------------- next part --------------
Index: rat/lonuserstate.pm
diff -u rat/lonuserstate.pm:1.157 rat/lonuserstate.pm:1.158
--- rat/lonuserstate.pm:1.157	Tue Nov 13 03:59:17 2018
+++ rat/lonuserstate.pm	Tue Mar  3 01:16:31 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construct and maintain state and binary representation of course for user
 #
-# $Id: lonuserstate.pm,v 1.157 2018/11/13 03:59:17 raeburn Exp $
+# $Id: lonuserstate.pm,v 1.158 2020/03/03 01:16:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -470,7 +470,11 @@
     # is not a page.  If the resource is a page then it must be
     # assembled (at fetch time?).
 
-    unless ($ispage) {
+    if ($ispage) {
+        if ($token->[2]->{'external'} eq 'true') { # external
+            $turi=~s{^http\://}{/ext/};
+        }
+    } else {
 	$turi=~/\.(\w+)$/;
 	my $embstyle=&Apache::loncommon::fileembstyle($1);
 	if ($token->[2]->{'external'} eq 'true') { # external
Index: rat/lonpage.pm
diff -u rat/lonpage.pm:1.133 rat/lonpage.pm:1.134
--- rat/lonpage.pm:1.133	Tue Feb 18 22:28:41 2020
+++ rat/lonpage.pm	Tue Mar  3 01:16:31 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Page Handler
 #
-# $Id: lonpage.pm,v 1.133 2020/02/18 22:28:41 raeburn Exp $
+# $Id: lonpage.pm,v 1.134 2020/03/03 01:16:31 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -304,22 +304,38 @@
                       foreach (@colcont) {
                           my $src=$hash{'src_'.$_};
                           my $plainsrc = $src;
+                          if ($hash{'ext_'.$_} eq 'true:') {
+                              $cellexternal{$_}=($hash{'ext_'.$_} eq 'true:');
+                              $src =~ s{^/ext/}{http://};
+                              $src =~ s{http://https://}{https://};
+                          }
                           my ($extension)=($src=~/\.(\w+)$/);
-			  $cellexternal{$_}=($hash{'ext_'.$_} eq 'true:');
 			  if ($hash{'encrypted_'.$_}) {
 			      $src=&Apache::lonenc::encrypted($src);
 			  }
                           my ($mapid,$resid)=split(/\./,$_);
-                          my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$src);
+                          my $symb=&Apache::lonnet::encode_symb($hash{'map_id_'.$mapid},$resid,$plainsrc);
                           unless ($env{'request.role.adv'}) {
                               $buttonshide{$symb} = &Apache::lonnet::EXT("resource.0.buttonshide",$symb);
                           }
                           $cellemb{$_}=
 			      &Apache::loncommon::fileembstyle($extension);
                           if ($cellexternal{$_}) {
-                              unless (($target eq 'tex') || ($target eq 'tex_answer')) {
+                              if (($target eq 'tex') || ($target eq 'tex_answer')) {
+                                  my $shown = $src;
+                                  if ($hash{'encrypted_'.$_}) {
+                                      $shown = &mt('URL not shown (encrypted)');
+                                  }
+                                  my $title=&Apache::lonnet::gettitle($symb);
+                                  $title = &Apache::lonxml::latex_special_symbols($title);
+                                  $ssibody{$_} = ' \strut \\\\ \textit{'.$title.'} \strut \\\\ '.$shown.'\\\\';
+                              } else {
+                                  my $showsrc = $src;
+                                  if (($hash{'encrypted_'.$_}) && ($symb)) {
+                                      $showsrc .= '?symb='.&Apache::lonenc::encrypted($symb);
+                                  }
                                   $ssibody{$_} = <<ENDEXT;
-<iframe src="$src" width="100%">No iframe support!</iframe>
+<iframe src="$showsrc" width="100%">No iframe support!</iframe>
 ENDEXT
                               }
                           } elsif ($cellemb{$_} eq 'ssi') {
@@ -903,15 +919,14 @@
                                                ? "/$env{'request.course.sec'}"
                                                : '');
     if ($hash->{'encrypted_'.$rid}) {
-	$symb=&Apache::lonenc::encrypted($symb);
 	$esrc=&Apache::lonenc::encrypted($esrc);
     }
     if ($hash->{'src_'.$rid} !~ m-^/uploaded/-
-        && $hash->{'src_'.$rid} !~ m{^https?://}
+        && $hash->{'src_'.$rid} !~ m{^/ext/}
 	&& !$env{'request.enc'}
 	&& ($env{'request.role.adv'}
 	    || !$hash->{'encrypted_'.$rid})) { 
-	$metainfo .='<a name="'.&escape($symb).'" />'.
+	$metainfo .='<a name="'.&escape($symb).'"></a>'.
 	    '<a href="'.$hash->{'src_'.$rid}.'.meta'.'" target="LONcatInfo">'.
             '<img src="/res/adm/pages/catalog.png" class="LC_icon"'.
             ' alt="'.&mt('Show Metadata').'"'.
@@ -919,7 +934,7 @@
 	    '</a>';
     }
     if (($hash->{'src_'.$rid} !~ m{^/uploaded/}) &&
-        ($hash->{'src_'.$rid} !~ m{^https?://})) {
+        ($hash->{'src_'.$rid} !~ m{^/ext/})) {
         $metainfo .= '<a href="/adm/evaluate?postdata='.
 	    &escape($esrc).
 	    '" target="LONcatInfo">'.
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.667 loncom/interface/londocs.pm:1.668
--- loncom/interface/londocs.pm:1.667	Sun Mar  1 15:39:17 2020
+++ loncom/interface/londocs.pm	Tue Mar  3 01:16:35 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.667 2020/03/01 15:39:17 raeburn Exp $
+# $Id: londocs.pm,v 1.668 2020/03/03 01:16:35 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4157,11 +4157,19 @@
     my ($editlink,$extresform,$anchor,$hiddenres,$nomodal);
     my $orig_url = $url;
     $orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
-    $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
+    if ($container eq 'page') {
+        $url=~s{^http(|s)(:|:)//}{/ext/};
+    } else {
+        $url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
+    }
     if (!$supplementalflag && $residx && $symb) {
         if ((!$isfolder) && (!$ispage)) {
 	    (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
-	    $url=&Apache::lonnet::clutter($url);
+            if (($url =~ m{^ext/}) && ($container eq 'page')) {
+                $url=&Apache::lonnet::clutter_with_no_wrapper($url);
+            } else {
+                $url=&Apache::lonnet::clutter($url);
+            } 
 	    if ($url=~/^\/*uploaded\//) {
 	        $url=~/\.(\w+)$/;
 	        my $embstyle=&Apache::loncommon::fileembstyle($1);
@@ -4175,7 +4183,7 @@
 	    } elsif ($url=~m{^(|/adm/wrapper)/ext/([^#]+)}) {
                 my $wrapped = $1;
                 my $exturl = $2;
-                if ($wrapped eq '') {
+                if (($wrapped eq '') && ($container ne 'page')) { 
                     $url='/adm/wrapper'.$url;
                 }
                 if (($ENV{'SERVER_PORT'} == 443) && ($exturl !~ /^https:/)) {
@@ -4201,6 +4209,9 @@
                         my $escan = &escape('#');
                         $shownsymb =~ s/^([^\#]+)#([^\#]+)$/$1$escan$2/;
                     }
+                    if ($container eq 'page') {
+                        $url = &Apache::lonnet::clutter($url);
+                    }
                 }
                 unless ($env{'request.role.adv'}) {
                     if ((&LONCAPA::map::getparameter($orderidx,'parameter_hiddenresource'))[0]=~/^yes$/i) {
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.671 loncom/interface/lonprintout.pm:1.672
--- loncom/interface/lonprintout.pm:1.671	Sat Feb 29 16:05:30 2020
+++ loncom/interface/lonprintout.pm	Tue Mar  3 01:16:35 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.671 2020/02/29 16:05:30 raeburn Exp $
+# $Id: lonprintout.pm,v 1.672 2020/03/03 01:16:35 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2072,17 +2072,28 @@
 
 sub unsupported {
     my ($currentURL,$mode,$symb)=@_;
+    my $cleanURL=&Apache::lonenc::check_decrypt($currentURL);
+    my $shown = $currentURL;
+    if (($cleanURL ne $currentURL) || ($symb =~ m{/^enc/})) {
+        $shown = &mt('URL not shown (encrypted)');
+    }
     if ($mode ne '') {$mode='\\'.$mode}
-    my $result.= &print_latex_header($mode);
-    if ($currentURL=~m|^(/adm/wrapper/)?ext/|) {
-	$currentURL=~s|^(/adm/wrapper/)?ext/|http://|;
-        $currentURL=~s|^http://https://|https://|;
-	my $title=&Apache::lonnet::gettitle($symb);
-	$title = &Apache::lonxml::latex_special_symbols($title);
-        my $url =  &Apache::lonxml::latex_special_symbols($currentURL);
-	$result.=' \strut \\\\ '.$title.' \strut \\\\ '.$url.' ';
+    my $result = &print_latex_header($mode);
+    if ($cleanURL=~m|^(/adm/wrapper)?/ext/|) {
+        $cleanURL=~s|^(/adm/wrapper)?/ext/|http://|;
+        $cleanURL=~s|^http://https://|https://|;
+        if ($shown eq $currentURL) {
+            $shown = &Apache::lonxml::latex_special_symbols($cleanURL);
+        }
+        my $title=&Apache::lonnet::gettitle($symb);
+        $title = &Apache::lonxml::latex_special_symbols($title);
+        $result.=' \strut \\\\ \textit{'.$title.'} \strut \\\\ '.$shown.' ';
     } else {
-	$result.= &Apache::lonxml::latex_special_symbols($currentURL);
+        if ($shown eq $currentURL) {
+	    $result.=&Apache::lonxml::latex_special_symbols($currentURL);
+        } else {
+            $result.=$shown;
+        }
     }
     $result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}';
     return $result;
@@ -2120,19 +2131,12 @@
 								      $numberofcolumns);
     my $LaTeXwidth=&recalcto_mm($textwidth); 
 
-
     if ($mode ne '') {$mode='\\'.$mode}
     my $result   =    &print_latex_header($mode);
-    if ($currentURL=~m|^(/adm/wrapper/)?ext/|) {
-	$currentURL=~s|^(/adm/wrapper/)?ext/|http://|;
-	my $title=&Apache::lonnet::gettitle($symb);
-	$title = &Apache::lonxml::latex_special_symbols($title);
-    } else {
-        my $esc_currentURL= $currentURL;
-        $esc_currentURL =~ s/_/\\_/g;
-	$result.=$esc_currentURL;
-    }
-    $result .= '\\\\';
+
+    my $title=&Apache::lonnet::gettitle($currentURL);
+    $title = &Apache::lonxml::latex_special_symbols($title);
+    $result .= '\noindent\textit{'.$title.'}\\\\';
 
     if ($helper->{'VARS'}->{'style_file'}=~/\w/) {
 	&Apache::lonnet::appenv({'construct.style' =>
@@ -2148,7 +2152,7 @@
 
     foreach my $resource (@page_resources) {
 	my $resource_src   = $resource->src(); # Essentially the URL of the resource.
-	$result           .= $resource->title() . '\\\\';
+        my $current_url = $resource->link();
 
 	# Recurse if a .page:
 
@@ -2158,11 +2162,10 @@
 	    $result           .= &print_page_in_course($helper, $rparmhash, 
 						       $resource_src, \@page_resources);
         } elsif ($resource->ext()) {
-            $result .= &unsupported($currentURL,$mode,$symb);
-	}
-	# these resources go through the XML transformer:
-
-	elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/)  {
+            $result.=&latex_header_footer_remove(&unsupported($current_url,$mode,$resource->symb));
+	} elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/)  {
+            # these resources go through the XML transformer:
+            $result .= &Apache::lonxml::latex_special_symbols($resource->title()) . '\\\\';
 
 	    my $urlp = &Apache::lonnet::clutter($resource_src);
 
@@ -2939,7 +2942,6 @@
 
 	    &Apache::lonenc::reset_enc();
 
-
 	    # Note due to document structure, not allowed to put \newpage
 	    # prior to the first resource
 
@@ -3455,8 +3457,9 @@
         my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}{'symb'});
         my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'};
         my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'};
-        my ($anchor,$usehttp);
+        my ($anchor,$usehttp,$plainurl);
         $url = &Apache::lonnet::clutter($url);
+        $plainurl = $url;
         if (($ENV{'SERVER_PORT'} == 443) && ($env{'request.course.id'}) &&
             (($url =~ m{^\Q/public/$cdom/$cnum/syllabus\E($|\?)}) ||
              ($url =~ m{^\Q/adm/wrapper/ext/\E(?!https:)}))) {
@@ -3481,7 +3484,9 @@
             if ($usehttp) {
                 $URLback .= (($URLback =~ /\?/) ? '&':'?').'usehttp=1';
             }
-            $URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor);
+            unless ($plainurl =~ /\.page$/) {
+                $URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor);
+            }
         }
     }
     #
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1418 loncom/lonnet/perl/lonnet.pm:1.1419
--- loncom/lonnet/perl/lonnet.pm:1.1418	Fri Jan 17 16:43:02 2020
+++ loncom/lonnet/perl/lonnet.pm	Tue Mar  3 01:16:39 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1418 2020/01/17 16:43:02 raeburn Exp $
+# $Id: lonnet.pm,v 1.1419 2020/03/03 01:16:39 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3661,6 +3661,18 @@
                         $forceedit = 1;
                     }
                     $cfile = $resurl;
+                } elsif (($resurl =~ m{^/ext/}) && ($symb ne '')) {
+                    my ($map,$id,$res) = &decode_symb($symb);
+                    if ($map =~ /\.page$/) {
+                        $incourse = 1;
+                        if ($env{'form.forceedit'}) {
+                            $forceview = 1;
+                            $cfile = $map;
+                        } else {
+                            $forceedit = 1;
+                            $cfile =  '/adm/wrapper'.$resurl;
+                        }
+                    }
                 } elsif ($resurl =~ m{^/adm/wrapper/adm/$cdom/$cnum/\d+/ext\.tool$}) {
                     $incourse = 1;
                     if ($env{'form.forceedit'}) {
@@ -13112,18 +13124,16 @@
 
     if (tie(%bighash,'GDBM_File',$env{'request.course.fn'}.'.db',
                             &GDBM_READER(),0640)) {
-        my $noclutter;
         if (($thisurl =~ m{^/adm/wrapper/ext/}) || ($thisurl =~ m{^ext/})) {
             $thisurl =~ s/\?.+$//;
             if ($map =~ m{^uploaded/.+\.page$}) {
                 $thisurl =~ s{^(/adm/wrapper|)/ext/}{http://};
                 $thisurl =~ s{^\Qhttp://https://\E}{https://};
-                $noclutter = 1;
             }
         }
         my $ids;
-        if ($noclutter) {
-            $ids=$bighash{'ids_'.$thisurl};
+        if ($map =~ m{^uploaded/.+\.page$}) {
+            $ids=$bighash{'ids_'.&clutter_with_no_wrapper($thisurl)};
         } else {
             $ids=$bighash{'ids_'.&clutter($thisurl)};
         }


More information about the LON-CAPA-cvs mailing list