[LON-CAPA-cvs] cvs: doc /loncapafiles loncapafiles.lpml loncom loncapa_apache.conf loncom/auth localstudentphoto.pm lonuploadedacc.pm loncom/homework outputtags.pm loncom/lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 26 Oct 2004 15:03:09 -0000
This is a MIME encoded message
--albertel1098802989
Content-Type: text/plain
albertel Tue Oct 26 11:03:09 2004 EDT
Added files:
/loncom/auth localstudentphoto.pm
Modified files:
/loncom/lonnet/perl lonnet.pm
/loncom loncapa_apache.conf
/loncom/auth lonuploadedacc.pm
/loncom/homework outputtags.pm
/doc/loncapafiles loncapafiles.lpml
Log:
- student photo support
--albertel1098802989
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20041026110309.txt"
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.551 loncom/lonnet/perl/lonnet.pm:1.552
--- loncom/lonnet/perl/lonnet.pm:1.551 Tue Oct 12 16:51:54 2004
+++ loncom/lonnet/perl/lonnet.pm Tue Oct 26 11:03:08 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.551 2004/10/12 20:51:54 albertel Exp $
+# $Id: lonnet.pm,v 1.552 2004/10/26 15:03:08 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -853,7 +853,7 @@
}
-my $disk_caching_disabled=0;
+my $disk_caching_disabled=1;
sub devalidate_cache {
my ($cache,$id,$name) = @_;
@@ -5091,13 +5091,15 @@
sub tokenwrapper {
my $uri=shift;
- $uri=~s/^http\:\/\/([^\/]+)//;
- $uri=~s/^\///;
+ $uri=~s|^http\://([^/]+)||;
+ $uri=~s|^/||;
$ENV{'user.environment'}=~/\/([^\/]+)\.id/;
my $token=$1;
- if ($uri=~/^uploaded\/([^\/]+)\/([^\/]+)\/([^\/]+)(\?\.*)*$/) {
- &appenv('userfile.'.$1.'/'.$2.'/'.$3 => $ENV{'request.course.id'});
- return 'http://'.$hostname{ &homeserver($2,$1)}.'/'.$uri.
+ my (undef,$udom,$uname,$file)=split('/',$uri,4);
+ if ($udom && $uname && $file) {
+ $file=~s|(\?\.*)*$||;
+ &appenv("userfile.$udom/$uname/$file" => $ENV{'request.course.id'});
+ return 'http://'.$hostname{ &homeserver($uname,$udom)}.'/'.$uri.
(($uri=~/\?/)?'&':'?').'token='.$token.
'&tokenissued='.$perlvar{'lonHostID'};
} else {
Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.97 loncom/loncapa_apache.conf:1.98
--- loncom/loncapa_apache.conf:1.97 Tue Sep 28 17:36:27 2004
+++ loncom/loncapa_apache.conf Tue Oct 26 11:03:08 2004
@@ -1,7 +1,7 @@
##
## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
##
-## $Id: loncapa_apache.conf,v 1.97 2004/09/28 21:36:27 www Exp $
+## $Id: loncapa_apache.conf,v 1.98 2004/10/26 15:03:08 albertel Exp $
##
#
@@ -90,6 +90,11 @@
ErrorDocument 500 /adm/errorhandler
</LocationMatch>
+<LocationMatch "^/+uploaded/.*/.*/internal/.*">
+PerlAccessHandler Apache::lonuploadedacc
+</LocationMatch>
+
+
<LocationMatch "^/+uploaded/.*\.page$">
SetHandler perl-script
PerlHandler Apache::lonpage
@@ -950,6 +955,7 @@
PerlSetVar lonDaemons /home/httpd/perl
PerlSetVar lonSockDir /home/httpd/sockets
PerlSetVar lonDocRoot /home/httpd/html
+PerlSetVar lonPrtDir /home/httpd/prtspool
PerlSetVar lonIncludes /home/httpd/html/res/adm/includes
PerlSetVar lonBrowsDet explorer:msie:netscape:msie\s(\d+\.\d+)\;:9999:9999&mozilla:mozilla\/[5-9]:msie:mozilla\/(\d+\.\d+)\s:9999:1&netscape:netscape:msie:netscape\/(\d+\.\d+):9999:7&amaya:amaya:mozilla:V(\d+\.\d+)\s:1:1&safari:safari:msie:safari\/(\d+\.\d+):9999:9999
PerlSetVar lonTextBrowsers opera:windows\s+ce:lynx
Index: loncom/auth/lonuploadedacc.pm
diff -u loncom/auth/lonuploadedacc.pm:1.10 loncom/auth/lonuploadedacc.pm:1.11
--- loncom/auth/lonuploadedacc.pm:1.10 Tue Feb 10 19:10:02 2004
+++ loncom/auth/lonuploadedacc.pm Tue Oct 26 11:03:08 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Access Handler for User Files
#
-# $Id: lonuploadedacc.pm,v 1.10 2004/02/11 00:10:02 albertel Exp $
+# $Id: lonuploadedacc.pm,v 1.11 2004/10/26 15:03:08 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -50,7 +50,7 @@
my $r = shift;
my $args=$r->args;
&Apache::loncommon::get_unprocessed_cgi($args,['token','tokenissued']);
- my (undef,undef,$udom,$uname,$ufile)=split(/\//,$r->uri);
+ my (undef,undef,$udom,$uname,$ufile)=split(/\//,$r->uri,5);
$ufile=~s/^[\~\.]+//;
my $remoteserver=$ENV{'form.tokenissued'};
my $reply=&Apache::lonnet::reply('tokenauthuserfile:'.
Index: loncom/homework/outputtags.pm
diff -u loncom/homework/outputtags.pm:1.34 loncom/homework/outputtags.pm:1.35
--- loncom/homework/outputtags.pm:1.34 Mon Oct 13 15:32:31 2003
+++ loncom/homework/outputtags.pm Tue Oct 26 11:03:08 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# tags that create controlled output
#
-# $Id: outputtags.pm,v 1.34 2003/10/13 19:32:31 albertel Exp $
+# $Id: outputtags.pm,v 1.35 2004/10/26 15:03:08 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,7 +33,7 @@
use POSIX qw(strftime);
BEGIN {
- &Apache::lonxml::register('Apache::outputtags',('displayduedate','displaytitle','displayweight'));
+ &Apache::lonxml::register('Apache::outputtags',('displayduedate','displaytitle','displayweight','displaystudentphoto'));
}
sub initialize_outputtags {
@@ -181,5 +181,47 @@
return @result;
}
+sub start_displaystudentphoto {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my $result;
+ my (undef,undef,$domain,$user) = &Apache::lonxml::whichuser();
+ if ($target eq 'web' && $user eq $ENV{'user.name'}) {
+ my $ret=&Apache::lonnet::reply("studentphoto:$domain:$user:gif",&Apache::lonnet::homeserver($user,$domain));
+ my $url="/uploaded/$domain/$user/internal/studentphoto.gif";
+ my $tokenurl=&Apache::lonnet::tokenwrapper($url);
+ my $args;
+ my $width=&Apache::lonxml::get_param('width',$parstack,$safeeval);
+ if ($width) { $args.=" width=\"$width\" "; }
+ my $height=&Apache::lonxml::get_param('heigth',$parstack,$safeeval);
+ if ($height) { $args.=" height=\"$height\" "; }
+ $result.=" <img $args src=\"$tokenurl\" alt=\"$user\@$domain\" />";
+ }
+ if ($target eq 'tex' && $ENV{'request.role'} =~ /^cc/) {
+ my $ret=&Apache::lonnet::reply("studentphoto:$domain:$user:eps",&Apache::lonnet::homeserver($user,$domain));
+ my $url="/uploaded/$domain/$user/internal/studentphoto.eps";
+ my $tokenurl=&Apache::lonnet::tokenwrapper($url);
+ my $ua=new LWP::UserAgent;
+ my $request=new HTTP::Request('GET',$tokenurl);
+ my $response=$ua->request($request);
+ if ($response->is_success) {
+ my $file=$user."_".$domain."_studentphoto.eps";
+ open(FILE,">".$Apache::lonnet::perlvar{'lonPrtDir'}."/$file");
+ print FILE $response->content;
+ close(FILE);
+ my $width_param=&Apache::londefdef::image_size($Apache::lonnet::perlvar{'lonPrtDir'}."/$file",'0.3',$parstack,$safeeval);
+ $result.=' \graphicspath{{'.$Apache::lonnet::perlvar{'lonPrtDir'}.
+ '}}\includegraphics[width='.$width_param.' mm]{'.$file.'} ';
+ }
+ }
+ return $result;
+}
+
+sub end_displaystudentphoto {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
+ my @result;
+ if ($target eq 'edit') { $result[1]='no'; }
+ return @result;
+}
+
1;
__END__
Index: doc/loncapafiles/loncapafiles.lpml
diff -u doc/loncapafiles/loncapafiles.lpml:1.394 doc/loncapafiles/loncapafiles.lpml:1.395
--- doc/loncapafiles/loncapafiles.lpml:1.394 Tue Sep 28 16:58:51 2004
+++ doc/loncapafiles/loncapafiles.lpml Tue Oct 26 11:03:08 2004
@@ -2,7 +2,7 @@
"http://lpml.sourceforge.net/DTD/lpml.dtd">
<!-- loncapafiles.lpml -->
-<!-- $Id: loncapafiles.lpml,v 1.394 2004/09/28 20:58:51 matthew Exp $ -->
+<!-- $Id: loncapafiles.lpml,v 1.395 2004/10/26 15:03:08 albertel Exp $ -->
<!--
@@ -5859,5 +5859,21 @@
Local handler for automated enrollment, standard version.
</description>
</file>
+<file>
+ <source>loncom/auth/localstudentphoto.pm</source>
+ <target dist='default'>home/httpd/lib/perl/localstudentphoto.pm</target>
+ <categoryname>conf</categoryname>
+ <description>
+ Local handler for automated enrollment.
+ </description>
+</file>
+<file>
+ <source>loncom/auth/localstudentphoto.pm</source>
+ <target dist='default'>home/httpd/lib/perl/localstudentphoto-std.pm</target>
+ <categoryname>handler</categoryname>
+ <description>
+ Local handler for automated enrollment, standard version.
+ </description>
+</file>
</files>
</lpml>
Index: loncom/auth/localstudentphoto.pm
+++ loncom/auth/localstudentphoto.pm
# The LON-CAPA dummy student photo fetch mechnism
#
# $Id: localstudentphoto.pm,v 1.1 2004/10/26 15:03:08 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
# 8/24 Guy Albertelli
package localstudentphoto;
use lib '/home/httpd/lib/perl/';
use LONCAPA::Configuration;
use Apache::loncommon;
sub fetch {
my ($domain,$user)=@_;
return &Apache::loncommon::propath($domain,$user).
'/userfiles/internal/studentphoto.jpg';
}
1;
__END__
--albertel1098802989--