[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm /publisher londiff.pm lonretrieve.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Tue, 19 Sep 2006 21:47:33 -0000
This is a MIME encoded message
--albertel1158702453
Content-Type: text/plain
albertel Tue Sep 19 17:47:33 2006 EDT
Modified files:
/loncom/publisher londiff.pm lonretrieve.pm
/loncom/interface loncommon.pm
Log:
- cleanup londiff/lonretrieve (style tabination xhtml css)
--albertel1158702453
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060919174733.txt"
Index: loncom/publisher/londiff.pm
diff -u loncom/publisher/londiff.pm:1.20 loncom/publisher/londiff.pm:1.21
--- loncom/publisher/londiff.pm:1.20 Wed Sep 13 17:43:26 2006
+++ loncom/publisher/londiff.pm Tue Sep 19 17:47:29 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to show differences between file versions
#
-# $Id: londiff.pm,v 1.20 2006/09/13 21:43:26 albertel Exp $
+# $Id: londiff.pm,v 1.21 2006/09/19 21:47:29 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -75,138 +75,139 @@
sub handler {
- my $r=shift;
+ my $r=shift;
# Get query string for limited number of parameters
- &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['filename','versiontwo','versionone','filetwo']);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['filename','versiontwo',
+ 'versionone','filetwo']);
# Get the files
- my $cuname=$env{'user.name'};
- my $cudom=$env{'user.domain'};
+ my $cuname=$env{'user.name'};
+ my $cudom=$env{'user.domain'};
- if ($env{'form.filename'}=~/^\/res\//) {
- ($cudom,$cuname,$env{'form.filename'})=
- ($env{'form.filename'}=~/^\/res\/(\w+)\/(\w+)\/(.*)$/);
- } else {
- unless (($cuname,$cudom)=
- &Apache::loncacc::constructaccess($env{'form.filename'},
- $r->dir_config('lonDefDomain'))) {
- $r->log_reason($cuname.' at '.$cudom.
- ' trying to get diffs file '.$env{'form.filename'}.
- ' - not authorized',
- $r->filename);
- return HTTP_NOT_ACCEPTABLE;
- }
- }
+ if ($env{'form.filename'}=~/^\/res\//) {
+ ($cudom,$cuname,$env{'form.filename'})=
+ ($env{'form.filename'}=~/^\/res\/(\w+)\/(\w+)\/(.*)$/);
+ } else {
+ unless (($cuname,$cudom)=
+ &Apache::loncacc::constructaccess($env{'form.filename'},
+ $r->dir_config('lonDefDomain'))) {
+ $r->log_reason($cuname.' at '.$cudom.
+ ' trying to get diffs file '.$env{'form.filename'}.
+ ' - not authorized',
+ $r->filename);
+ return HTTP_NOT_ACCEPTABLE;
+ }
+ }
- my $efn=$env{'form.filename'};
+ my $efn=$env{'form.filename'};
- $efn=~s/\/\~(\w+)//g;
+ $efn=~s/\/\~(\w+)//g;
- my @f1=();
- my @f2=();
+ my @f1=();
+ my @f2=();
- &Apache::loncommon::content_type($r,'text/html');
- $r->send_http_header;
+ &Apache::loncommon::content_type($r,'text/html');
+ $r->send_http_header;
- $r->print(&Apache::loncommon::start_page('Resource Differences'));
+ $r->print(&Apache::loncommon::start_page('Resource Differences'));
- $r->print('<h1>'.($env{'form.filetwo'}?'':&mt('Compare versions of')).
- ' <tt>'.$efn.'</tt></h1>');
+ $r->print('<h1>'.($env{'form.filetwo'}?'':&mt('Compare versions of')).
+ ' <tt>'.$efn.'</tt></h1>');
- if (($cuname ne $env{'user.name'}) || ($cudom ne $env{'user.domain'})) {
- $r->print('<h3><font color=red>Co-Author: '.$cuname.' at '.$cudom.
- '</font></h3>');
- }
-
-
- if (&Apache::loncommon::fileembstyle(($efn=~/\.(\w+)$/)) eq 'ssi'
- || $efn =~ /\.meta$/) {
- $r->print('<p><font color="red">');
- if ($env{'form.versionone'} eq 'priv') {
- my $fn='/home/'.$cuname.'/public_html/'.$efn;
- @f1=&get_split_file($fn,'local');
- $r->print('<b>'.&mt('Construction Space Version').'</b>');
- } else {
- my $fn=
- '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';
- if ($env{'form.versionone'}) {
- 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('<b>'.&mt('Version').' '.$env{'form.versionone'}.'</b>');
- } else {
- $fn.=$efn;
- $r->print('<b>'.&mt('Current Version').'</b>');
- }
- @f1=&get_split_file($fn,'remote');
- }
-
- $r->print('</font><br />'.&mt('versus').'<br /><font color="green">');
-
- if ($env{'form.filetwo'}) {
- my $efn2=$env{'form.filetwo'};
- $efn2=~s/\/\~(\w+)//g;
- my $fn='/home/'.$cuname.'/public_html/'.$efn2;
- @f2=&get_split_file($fn,'local');
- $r->print('<tt>'.$efn2.'</tt>');
- } elsif ($env{'form.versiontwo'} eq 'priv') {
- my $fn='/home/'.$cuname.'/public_html/'.$efn;
- @f2=&get_split_file($fn,'local');
- $r->print('<b>'.&mt('Construction Space Version').'</b>');
- } else {
- my $fn=
- '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';
- if ($env{'form.versiontwo'}) {
- 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('<b>'.&mt('Version').' '.$env{'form.versiontwo'}.'</b>');
- } else {
- $fn.=$efn;
- $r->print('<b>'.&mt('Current Version').'</b>');
- }
- @f2=&get_split_file($fn,'remote');
- }
- $r->print('</font></p>');
-# Run diff
+ if (($cuname ne $env{'user.name'}) || ($cudom ne $env{'user.domain'})) {
+ $r->print('<h3><span class="LC_diff_coauthor">Co-Author: '.$cuname.' at '.$cudom.
+ '</span></h3>');
+ }
- my $diffs = diff(\@f1, \@f2);
-# Start page output
+ if (&Apache::loncommon::fileembstyle(($efn=~/\.(\w+)$/)) eq 'ssi'
+ || $efn =~ /\.meta$/) {
+ $r->print('<p><span class="LC_diff_removed">');
+ if ($env{'form.versionone'} eq 'priv') {
+ my $fn='/home/'.$cuname.'/public_html/'.$efn;
+ @f1=&get_split_file($fn,'local');
+ $r->print('<b>'.&mt('Construction Space Version').'</b>');
+ } else {
+ my $fn=
+ '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';
+ if ($env{'form.versionone'}) {
+ 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('<b>'.&mt('Version').' '.$env{'form.versionone'}.'</b>');
+ } else {
+ $fn.=$efn;
+ $r->print('<b>'.&mt('Current Version').'</b>');
+ }
+ @f1=&get_split_file($fn,'remote');
+ }
+
+ $r->print('</span><br />'.&mt('versus').'<br /><span class="LC_diff_added">');
- my $chunk;
- my $line;
+ if ($env{'form.filetwo'}) {
+ my $efn2=$env{'form.filetwo'};
+ $efn2=~s/\/\~(\w+)//g;
+ my $fn='/home/'.$cuname.'/public_html/'.$efn2;
+ @f2=&get_split_file($fn,'local');
+ $r->print('<tt>'.$efn2.'</tt>');
+ } elsif ($env{'form.versiontwo'} eq 'priv') {
+ my $fn='/home/'.$cuname.'/public_html/'.$efn;
+ @f2=&get_split_file($fn,'local');
+ $r->print('<b>'.&mt('Construction Space Version').'</b>');
+ } else {
+ my $fn=
+ '/home/httpd/html/res/'.$cudom.'/'.$cuname.'/';
+ if ($env{'form.versiontwo'}) {
+ 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('<b>'.&mt('Version').' '.$env{'form.versiontwo'}.'</b>');
+ } else {
+ $fn.=$efn;
+ $r->print('<b>'.&mt('Current Version').'</b>');
+ }
+ @f2=&get_split_file($fn,'remote');
+ }
+ $r->print('</span></p>');
+# Run diff
+
+ my $diffs = diff(\@f1, \@f2);
+
+# Start page output
- $r->print('<pre>');
+ my $chunk;
+ my $line;
- foreach $chunk (@$diffs) {
+ $r->print('<pre>');
+
+ foreach $chunk (@$diffs) {
- foreach $line (@$chunk) {
- my ($sign, $lineno, $text) = @$line;
- $text=~s/\</\<\;/g;
- $text=~s/\>/\>\;/g;
- $lineno=substr($lineno.' ',0,7);
- $r->print('<font color='.(($sign eq '+')?'green':'red').'>'.
- $sign.' '.$lineno.' '.$text."</font>\n");
- }
- $r->print("<hr>\n");
- }
- $r->print('</pre>');
-
- } else {
- $r->print('<h1><font color=red>'.&mt('Binary File').'</font></h1>');
- }
- $r->print('<center><a href="javascript:window.close();">'.&mt('Close This Window').'</a></center>');
- $r->print(&Apache::loncommon::end_page());
- return OK;
+ foreach $line (@$chunk) {
+ my ($sign, $lineno, $text) = @$line;
+ $text=&HTML::Entities::encode($text,'<>&"');
+ $lineno=substr($lineno.' ',0,7);
+ $r->print('<span class="'.(($sign eq '+')?'LC_diff_added'
+ :'LC_diff_removed').'">'.
+ $sign.' '.$lineno.' '.$text."</span>\n");
+ }
+ $r->print("</pre><hr /><pre>\n");
+ }
+ $r->print('</pre>');
+
+ } else {
+ $r->print('<h1><span class="LC_warning">'.&mt('Binary File').'</span></h1>');
+ }
+ $r->print('<center><a href="javascript:window.close();">'.&mt('Close This Window').'</a></center>');
+ $r->print(&Apache::loncommon::end_page());
+ return OK;
}
Index: loncom/publisher/lonretrieve.pm
diff -u loncom/publisher/lonretrieve.pm:1.31 loncom/publisher/lonretrieve.pm:1.32
--- loncom/publisher/lonretrieve.pm:1.31 Wed Sep 13 17:43:26 2006
+++ loncom/publisher/lonretrieve.pm Tue Sep 19 17:47:29 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Handler to retrieve an old version of a file
#
-# $Id: lonretrieve.pm,v 1.31 2006/09/13 21:43:26 albertel Exp $
+# $Id: lonretrieve.pm,v 1.32 2006/09/19 21:47:29 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -54,78 +54,84 @@
my ($main,$suffix,$is_meta) = &get_file_info($fn);
if (-e $resfn) {
- $r->print('<form action=/adm/retrieve method=post>'.
- '<input type=hidden name=filename value="/~'.$uname.$fn.'">'.
- '<input type=hidden name=phase value=two>'.
- '<table border=2><tr><th>'.&mt('Select').'</th><th>'.
- &mt('Version').'</th>'.
- '<th>'.&mt('Published on ...').'</th>');
- if (!$is_meta) {
- $r->print('<th>'.&mt('Metadata').'</th>');
- }
- if ($is_meta
- || &Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
- $r->print('<th>'.&mt('Diffs').'</th>');
- }
- $r->print('</tr>');
-
- opendir(DIR,$resdir);
- my @files = grep(/^\Q$main\E\.(\d+)\.\Q$suffix\E$/,readdir(DIR));
- @files = sort {
- my ($aver) = ($a=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/);
- my ($bver) = ($b=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/);
- return $aver <=> $bver;
- } (@files);
- closedir(DIR);
-
- foreach my $filename (@files) {
- if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
- my $version=$1;
- my $rmtime=&Apache::lonnet::metadata($resdir.'/'.$filename,'lastrevisiondate');
- $r->print('<tr><td><input type=radio name=version value="'.
- $version.'"></td><td>'.&mt('Previously published version').' '.$version.'</td><td>'.
- localtime($rmtime).'</td>');
-
- if (!$is_meta) {
- $r->print('<td><a href="'.$urldir.$filename.'.meta" target=cat>'.
- &mt('Metadata Version').' '.$version.'</a></td>');
- }
- if ($is_meta
- || &Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
- $r->print(
- '<td><a target=cat href="/adm/diff?filename=/~'.
- $uname.$fn.
- '&versiontwo=priv&versionone='.$version.
- '">'.&mt('Diffs with Version').' '.$version.
- '</a></td>');
- }
- $r->print('</tr>');
- }
- }
- closedir(DIR);
- my $rmtime=&Apache::lonnet::metadata($resfn,'lastrevisiondate');
- $r->print('<tr><td><input type=radio name=version value="new"></td>'.
- '<th>'.&mt('Currently published version').'</th><td>'.localtime($rmtime).
- '</td>');
- if (!$is_meta) {
- $r->print('<td><a href="'.$urldir.$main.'.'.$suffix.'.meta" target=cat>'.
- &mt('Metadata current version').'</a></td>');
+ $r->print('<form action="/adm/retrieve" method="POST">'.
+ '<input type="hidden" name="filename" value="/~'.$uname.$fn.'" />'.
+ '<input type="hidden" name="phase" value="two" />'.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '<th>'.&mt('Select').'</th>'.
+ '<th>'.&mt('Version').'</th>'.
+ '<th>'.&mt('Published on ...').'</th>');
+ if (!$is_meta) {
+ $r->print('<th>'.&mt('Metadata').'</th>');
+ }
+ if ($is_meta
+ || &Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
+ $r->print('<th>'.&mt('Diffs').'</th>');
+ }
+ $r->print(&Apache::loncommon::end_data_table_header_row());
+
+ opendir(DIR,$resdir);
+ my @files = grep(/^\Q$main\E\.(\d+)\.\Q$suffix\E$/,readdir(DIR));
+ @files = sort {
+ my ($aver) = ($a=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/);
+ my ($bver) = ($b=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/);
+ return $aver <=> $bver;
+ } (@files);
+ closedir(DIR);
+
+ foreach my $filename (@files) {
+ if ($filename=~/^\Q$main\E\.(\d+)\.\Q$suffix\E$/) {
+ my $version=$1;
+ my $rmtime=&Apache::lonnet::metadata($resdir.'/'.$filename,'lastrevisiondate');
+ $r->print(&Apache::loncommon::start_data_table_row().
+ '<td><input type="radio" name="version" value="'.
+ $version.'" /></td><td>'.&mt('Previously published version').' '.$version.'</td><td>'.
+ localtime($rmtime).'</td>');
+
+ if (!$is_meta) {
+ $r->print('<td><a href="'.$urldir.$filename.'.meta" target=cat>'.
+ &mt('Metadata Version').' '.$version.'</a></td>');
+ }
+ if ($is_meta
+ || &Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
+ $r->print(
+ '<td><a target="cat" href="/adm/diff?filename=/~'.
+ $uname.$fn.
+ '&versiontwo=priv&versionone='.$version.
+ '">'.&mt('Diffs with Version').' '.$version.
+ '</a></td>');
+ }
+ $r->print(&Apache::loncommon::end_data_table_row());
+ }
+ }
+ closedir(DIR);
+ my $rmtime=&Apache::lonnet::metadata($resfn,'lastrevisiondate');
+ $r->print(&Apache::loncommon::start_data_table_row().
+ '<td><input type="radio" name="version" value="new" /></td>'.
+ '<td><b>'.&mt('Currently published version').'</b></td><td>'.localtime($rmtime).
+ '</td>');
+ if (!$is_meta) {
+ $r->print('<td><a href="'.$urldir.$main.'.'.$suffix.'.meta" target=cat>'.
+ &mt('Metadata current version').'</a></td>');
+ }
+ if ($is_meta
+ || &Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
+ $r->print(
+ '<td><a target="cat" href="/adm/diff?filename=/~'.
+ $uname.$fn.
+ '&versiontwo=priv'.
+ '">'.&mt('Diffs with current Version').'</a></td>');
+ }
+ $r->print(&Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table().
+ '<p>'.
+ '<span class="LC_error">'.
+ &mt('Retrieval of an old version will overwrite the file currently in construction space').'</span><p>'.
+ '<input type="submit" value="'.&mt('Retrieve version').'" /></form>');
+ } else {
+ $r->print('<h3>'.&mt('No previous versions published.').'</h3>');
}
- if ($is_meta
- || &Apache::loncommon::fileembstyle($suffix) eq 'ssi') {
- $r->print(
- '<td><a target=cat href="/adm/diff?filename=/~'.
- $uname.$fn.
- '&versiontwo=priv'.
- '">'.&mt('Diffs with current Version').'</a></td>');
- }
- $r->print('</tr></table><p>'.
- '<font size=+1 color=red>'.
-&mt('Retrieval of an old version will overwrite the file currently in construction space').'</font><p>'.
- '<input type=submit value="'.&mt('Retrieve version').'"></form>');
-} else {
- $r->print('<h3>'.&mt('No previous versions published.').'</h3>');
-}
$r->print('<p><a href="/priv/'.$uname.$fn.'">'.&mt('Back to').' '.$fn.
'</a></p>');
}
@@ -173,8 +179,7 @@
$r->print('<font size=+2><a href="/priv/'.$uname.$fn.
'">'.&mt('Back to').' '.$fn.'</a></font>');
} else {
- $r->print(
- '<font size=+1 color=red>'.&mt('Please pick a version to retrieve').'</font><p>');
+ $r->print('<span class="LC_warning">'.&mt('Please pick a version to retrieve').'</span><p>');
&phaseone($r,$fn,$uname,$udom);
}
}
@@ -244,9 +249,9 @@
$r->print('<h1>'.&mt('Retrieve previous versions of').' <tt>'.$fn.'</tt></h1>');
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) {
- $r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname.
+ $r->print('<h3><span class="LC_diff_coauthor">'.&mt('Co-Author').': '.$uname.
&mt(' at ').$udom.
- '</font></h3>');
+ '</span></h3>');
}
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.456 loncom/interface/loncommon.pm:1.457
--- loncom/interface/loncommon.pm:1.456 Tue Sep 19 15:03:22 2006
+++ loncom/interface/loncommon.pm Tue Sep 19 17:47:32 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.456 2006/09/19 19:03:22 albertel Exp $
+# $Id: loncommon.pm,v 1.457 2006/09/19 21:47:32 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -3199,10 +3199,12 @@
color: red;
font-size: larger;
}
-.LC_warning {
+.LC_warning,
+.LC_diff_removed {
color: red;
}
-.LC_success {
+.LC_success,
+.LC_diff_added {
color: green;
}
.LC_icon {
--albertel1158702453--