--- loncom/publisher/londiff.pm 2006/04/06 22:15:18 1.18 +++ loncom/publisher/londiff.pm 2006/09/13 21:43:26 1.20 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to show differences between file versions # -# $Id: londiff.pm,v 1.18 2006/04/06 22:15:18 albertel Exp $ +# $Id: londiff.pm,v 1.20 2006/09/13 21:43:26 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,11 +32,13 @@ package Apache::londiff; use strict; use Apache::File; use File::Copy; +use File::Compare; use Algorithm::Diff qw(diff); use Apache::Constants qw(:common :http :methods); -use Apache::loncacc; +use Apache::loncacc(); use Apache::lonnet; use Apache::loncommon(); +use Apache::lonretrieve(); use Apache::lonlocal; @@ -44,7 +46,7 @@ sub get_split_file { my ($fn,$style)=@_; my $f1; my @f1; - if ($style='local') { + if ($style eq 'local') { if (-e $fn) { my $fh=Apache::File->new($fn); my $line; @@ -66,10 +68,14 @@ sub get_split_file { return @f1; } +sub are_different_files { + my ($fileone,$filetwo)=@_; + return &compare($fileone,$filetwo); +} + sub handler { my $r=shift; - # Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, @@ -116,7 +122,8 @@ sub handler { } - if (&Apache::loncommon::fileembstyle(($efn=~/\.(\w+)$/)) eq 'ssi') { + if (&Apache::loncommon::fileembstyle(($efn=~/\.(\w+)$/)) eq 'ssi' + || $efn =~ /\.meta$/) { $r->print('

'); if ($env{'form.versionone'} eq 'priv') { my $fn='/home/'.$cuname.'/public_html/'.$efn; @@ -124,9 +131,13 @@ sub handler { $r->print(''.&mt('Construction Space Version').''); } else { my $fn= - '/home/httpd/html//res/'.$cudom.'/'.$cuname.'/'; + '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/'; if ($env{'form.versionone'}) { - my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/); + my ($main,$suffix,$is_meta)= + &Apache::lonretrieve::get_file_info($efn); + + $fn.=($efn =~m|(.*/)[^/]+|)[0]; + # add on to $fn the path information in $efn $fn.=$main.'.'.$env{'form.versionone'}.'.'.$suffix; $r->print(''.&mt('Version').' '.$env{'form.versionone'}.''); } else { @@ -152,7 +163,10 @@ sub handler { my $fn= '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/'; if ($env{'form.versiontwo'}) { - my ($main,$suffix)=($efn=~/^(.+)\.(\w+)$/); + my ($main,$suffix,$is_meta)= + &Apache::lonretrieve::get_file_info($efn); + # add on to $fn the path information in $efn + $fn.=($efn =~m|(.*/)[^/]+|)[0]; $fn.=$main.'.'.$env{'form.versiontwo'}.'.'.$suffix; $r->print(''.&mt('Version').' '.$env{'form.versiontwo'}.''); } else {