[LON-CAPA-cvs] cvs: rat / lonwrapper.pm loncom/auth lonacc.pm loncom/interface lonsyllabus.pm loncom/xml londefdef.pm
raeburn
raeburn at source.lon-capa.org
Tue Jun 17 19:22:21 EDT 2014
raeburn Tue Jun 17 23:22:21 2014 EDT
Modified files:
/loncom/auth lonacc.pm
/loncom/interface lonsyllabus.pm
/loncom/xml londefdef.pm
/rat lonwrapper.pm
Log:
- On Apache/SSL servers syllabus should always be served by http:// to avoid
"mixed content" issue when syllabus is an external resource on http:// server).
- Set $env{'request.use_absolute'} and pass in args to start page so postdata
is preserved. (bug 6662).
- Code used for same purpose in rat/lonwrapper.pm rev. 1.44 for external
resources moved to lonacc.pm to facilitate re-use.
- Detect if syllabus template replaced with uploaded PDF or link to external
PDF file, and send as arg in call to lonwrapper.pm, to circumvent lack of
scrolling for multi-page PDFs in iframes on iOS.
-------------- next part --------------
Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.156 loncom/auth/lonacc.pm:1.157
--- loncom/auth/lonacc.pm:1.156 Sat May 17 21:43:55 2014
+++ loncom/auth/lonacc.pm Tue Jun 17 23:22:10 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Cookie Based Access Handler
#
-# $Id: lonacc.pm,v 1.156 2014/05/17 21:43:55 raeburn Exp $
+# $Id: lonacc.pm,v 1.157 2014/06/17 23:22:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -473,7 +473,7 @@
}
$env{'request.filename'} = $r->filename;
$env{'request.noversionuri'} = &Apache::lonnet::deversion($requrl);
- my $suppext;
+ my ($suppext,$checkabsolute);
if ($requrl =~ m{^/adm/wrapper/ext/}) {
my $query = $r->args;
if ($query) {
@@ -494,6 +494,9 @@
$env{'request.external.querystring'} = $preserved;
}
}
+ if ($env{'request.course.id'}) {
+ $checkabsolute = 1;
+ }
} elsif ($env{'request.course.id'} &&
(($requrl =~ m{^/adm/$match_domain/$match_username/aboutme$}) ||
($requrl =~ m{^/public/$cdom/$cnum/syllabus$}))) {
@@ -508,6 +511,20 @@
}
}
}
+ if ($requrl =~ m{^/public/$cdom/$cnum/syllabus$}) {
+ $checkabsolute = 1;
+ }
+ }
+ if ($checkabsolute) {
+ my $hostname = $r->hostname();
+ my $lonhost = &Apache::lonnet::host_from_dns($hostname);
+ if ($lonhost) {
+ my $actual = &Apache::lonnet::absolute_url($hostname);
+ my $expected = $Apache::lonnet::protocol{$lonhost}.'://'.$hostname;
+ unless ($actual eq $expected) {
+ $env{'request.use_absolute'} = $expected;
+ }
+ }
}
# -------------------------------------------------------- Load POST parameters
Index: loncom/interface/lonsyllabus.pm
diff -u loncom/interface/lonsyllabus.pm:1.136 loncom/interface/lonsyllabus.pm:1.137
--- loncom/interface/lonsyllabus.pm:1.136 Thu Jan 9 15:18:40 2014
+++ loncom/interface/lonsyllabus.pm Tue Jun 17 23:22:14 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Syllabus
#
-# $Id: lonsyllabus.pm,v 1.136 2014/01/09 15:18:40 raeburn Exp $
+# $Id: lonsyllabus.pm,v 1.137 2014/06/17 23:22:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -99,7 +99,7 @@
my $minimal=$courseenv{'minimalsyllabus'};
if (($minimal =~/\w/) || ($uploaded =~/\w/)) {
- my $item;
+ my ($item,$is_pdf);
if ($minimal =~/\w/) {
if ($external =~ m{\Q$minimal\E$}) {
undef($external);
@@ -110,6 +110,9 @@
undef($external);
}
$item = $uploaded;
+ if ($item =~ /\.pdf$/i) {
+ $is_pdf = 1;
+ }
}
unless ($allowed && $forceedit) {
my $file=&Apache::lonnet::filelocation("",$item);
@@ -129,6 +132,9 @@
if ($env{'form.only_body'}) {
$args{'only_body'} = 1;
}
+ if ($env{'request.use_absolute'}) {
+ $args{'use_absolute'} = $env{'request.use_absolute'};
+ }
$r->print(&Apache::loncommon::start_page("Syllabus",undef,\%args).
$result.
&Apache::loncommon::end_page());
@@ -157,7 +163,8 @@
&mt('Print the syllabus directly from your web browser').
'\end{document}');
} else {
- $r->print(&Apache::lonwrapper::wrapper($item));
+ $r->print(&Apache::lonwrapper::wrapper($item,undef,$env{'request.use_absolute'},
+ undef,$is_pdf,&mt('Syllabus')));
}
}
return OK;
@@ -170,7 +177,13 @@
' \strut \\\\ '.&mt('Print the syllabus directly from your web browser').
'\end{document}');
} else {
- $r->print(&Apache::lonwrapper::wrapper($external));
+ my $is_ext = 1;
+ my $is_pdf;
+ if ($external =~ /\.pdf$/i) {
+ $is_pdf = 1;
+ }
+ $r->print(&Apache::lonwrapper::wrapper($external,undef,$env{'request.use_absolute'},
+ $is_ext,$is_pdf,&mt('Syllabus')));
}
return OK;
}
@@ -695,6 +708,10 @@
onload => 'setTemplateBoxes();',
);
$args->{'add_entries'} = \%loaditem;
+ } else {
+ if ($env{'request.use_absolute'}) {
+ $args->{'use_absolute'} = $env{'request.use_absolute'};
+ }
}
if ($env{'form.only_body'}) {
$args->{'only_body'} = 1;
Index: loncom/xml/londefdef.pm
diff -u loncom/xml/londefdef.pm:1.451 loncom/xml/londefdef.pm:1.452
--- loncom/xml/londefdef.pm:1.451 Thu May 15 20:19:06 2014
+++ loncom/xml/londefdef.pm Tue Jun 17 23:22:17 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.451 2014/05/15 20:19:06 raeburn Exp $
+# $Id: londefdef.pm,v 1.452 2014/06/17 23:22:17 raeburn Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -589,6 +589,9 @@
'force_register' => 1,};
if ($target eq 'web') {
$args->{'print_suppress'} = 1;
+ if ($env{'request.use_absolute'}) {
+ $args->{'use_absolute'} = $env{'request.use_absolute'};
+ }
}
$currentstring =
&Apache::loncommon::start_page($Apache::londefdef::title,
Index: rat/lonwrapper.pm
diff -u rat/lonwrapper.pm:1.48 rat/lonwrapper.pm:1.49
--- rat/lonwrapper.pm:1.48 Tue Jun 17 23:01:21 2014
+++ rat/lonwrapper.pm Tue Jun 17 23:22:21 2014
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Wrapper for external and binary files as standalone resources
#
-# $Id: lonwrapper.pm,v 1.48 2014/06/17 23:01:21 raeburn Exp $
+# $Id: lonwrapper.pm,v 1.49 2014/06/17 23:22:21 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,7 +40,7 @@
# ================================================================ Main Handler
sub wrapper {
- my ($url,$brcrum,$absolute,$is_ext,$is_pdf) = @_;
+ my ($url,$brcrum,$absolute,$is_ext,$is_pdf,$title) = @_;
my $forcereg;
unless ($env{'form.folderpath'}) {
@@ -70,11 +70,13 @@
if ($env{'browser.mobile'}) {
my $output = $startpage;
if ($is_pdf) {
- my $title = $env{'form.title'};
if ($title eq '') {
- unless ($env{'request.enc'}) {
- ($title) = ($url =~ m{/([^/]+)$});
- $title =~ s/(\?[^\?]+)$//;
+ $title = $env{'form.title'};
+ if ($title eq '') {
+ unless ($env{'request.enc'}) {
+ ($title) = ($url =~ m{/([^/]+)$});
+ $title =~ s/(\?[^\?]+)$//;
+ }
}
}
unless ($title eq '') {
@@ -150,15 +152,6 @@
}
if ($is_ext) {
- my $hostname = $r->hostname();
- my $lonhost = &Apache::lonnet::host_from_dns($hostname);
- if ($lonhost) {
- my $actual = &Apache::lonnet::absolute_url($hostname);
- my $expected = $Apache::lonnet::protocol{$lonhost}.'://'.$hostname;
- unless ($actual eq $expected) {
- $absolute = $expected;
- }
- }
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['forceedit','register','folderpath','symb','idx','title']);
if (($env{'form.forceedit'}) &&
@@ -195,6 +188,7 @@
# This is not homework
#
if ($is_ext) {
+ $absolute = $env{'request.use_absolute'};
$ENV{'QUERY_STRING'} =~ s/(^|\&)symb=[^\&]*/$1/;
$ENV{'QUERY_STRING'} =~ s/\&$//;
}
@@ -233,7 +227,7 @@
=over
-=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf))
+=item wrapper($url,$brcrum,$absolute,$is_ext,$is_pdf,$title))
=over
@@ -258,7 +252,9 @@
That will be the case where an external resource has been
served from port 80, when the server customarily serves
requests using Apache/SSL (i.e., port 443). mod_rewrite
-is used to switch requests for external resources
+is used to switch requests for external resources and
+the syllabus: /public/<domain>/<courseid>/syllabus
+(which might also point at an external resource)
from https:// to http:// where the the URL of the remote site
specified in the resource itself is http://.
@@ -273,6 +269,14 @@
true if URL is for a PDF (based on file extension).
+=item $title
+
+optional. If wrapped item is a PDF, and $env{'browser.mobile'}
+is true, a link to a PDF is shown. The "title" will be displayed
+above the link, but if not provided as an arg, $env{'form.title'}
+will be used, otherwise, the filename will be displayed (unless
+hidden URL set for the resource).
+
=back
Returns markup for the entire page.
More information about the LON-CAPA-cvs
mailing list