version 1.1, 2001/05/02 21:01:47
|
version 1.4, 2001/05/03 11:04:07
|
Line 49 sub handler {
|
Line 49 sub handler {
|
my @f1=(); |
my @f1=(); |
my @f2=(); |
my @f2=(); |
|
|
|
$r->content_type('text/html'); |
|
$r->send_http_header; |
|
|
|
$r->print('<html><head><title>LON-CAPA Construction Diffs</title></head>'); |
|
|
|
$r->print('<body bgcolor="#FFFFFF">'); |
|
|
|
|
|
$r->print('<h1>Compare versions of <tt>'.$ENV{'form.filename'}.'</tt></h1>'); |
|
|
|
if (&Apache::lonnet::fileembstyle(($ENV{'form.filename'}=~/\.(\w+)$/)) eq |
|
'ssi') { |
if ($ENV{'form.versionone'} eq 'priv') { |
if ($ENV{'form.versionone'} eq 'priv') { |
my $fn='/home/'.$ENV{'user.name'}.'/public_html/'.$ENV{'form.filename'}; |
my $fn='/home/'.$ENV{'user.name'}.'/public_html/'.$ENV{'form.filename'}; |
if (-e $fn) { |
if (-e $fn) { |
Line 59 sub handler {
|
Line 71 sub handler {
|
$f1[$#f1+1]=$line; |
$f1[$#f1+1]=$line; |
} |
} |
} |
} |
|
$r->print('<h3>Construction Space Version</h3>'); |
} else { |
} else { |
my $fn= |
my $fn= |
'/home/httpd/html//res/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; |
'/home/httpd/html//res/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; |
if ($ENV{'form.versionone'}) { |
if ($ENV{'form.versionone'}) { |
my ($main,$suffix)=($ENV{'form.filename'}=~/^(.+)\.(\w+)$/); |
my ($main,$suffix)=($ENV{'form.filename'}=~/^(.+)\.(\w+)$/); |
$fn.=$main.'.'.$ENV{'form.versionone'}.'.'.$suffix; |
$fn.=$main.'.'.$ENV{'form.versionone'}.'.'.$suffix; |
|
$r->print('<h3>Version '.$ENV{'form.versionone'}.'</h3>'); |
} else { |
} else { |
$fn.=$ENV{'form.filename'}; |
$fn.=$ENV{'form.filename'}; |
|
$r->print('<h3>Current Version</h3>'); |
} |
} |
@f1=split(/\n/,&Apache::lonnet::getfile($fn)); |
@f1=split(/\n/,&Apache::lonnet::getfile($fn)); |
} |
} |
|
|
|
$r->print('versus'); |
|
|
if ($ENV{'form.versiontwo'} eq 'priv') { |
if ($ENV{'form.versiontwo'} eq 'priv') { |
my $fn='/home/'.$ENV{'user.name'}.'/public_html/'.$ENV{'form.filename'}; |
my $fn='/home/'.$ENV{'user.name'}.'/public_html/'.$ENV{'form.filename'}; |
Line 82 sub handler {
|
Line 98 sub handler {
|
$f2[$#f2+1]=$line; |
$f2[$#f2+1]=$line; |
} |
} |
} |
} |
|
$r->print('<h3>Construction Space Version</h3>'); |
} else { |
} else { |
my $fn= |
my $fn= |
'/home/httpd/html/res/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; |
'/home/httpd/html/res/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; |
if ($ENV{'form.versiontwo'}) { |
if ($ENV{'form.versiontwo'}) { |
my ($main,$suffix)=($ENV{'form.filename'}=~/^(.+)\.(\w+)$/); |
my ($main,$suffix)=($ENV{'form.filename'}=~/^(.+)\.(\w+)$/); |
$fn.=$main.'.'.$ENV{'form.versiontwo'}.'.'.$suffix; |
$fn.=$main.'.'.$ENV{'form.versiontwo'}.'.'.$suffix; |
|
$r->print('<h3>Version '.$ENV{'form.versiontwo'}.'</h3>'); |
} else { |
} else { |
$fn.=$ENV{'form.filename'}; |
$fn.=$ENV{'form.filename'}; |
|
$r->print('<h3>Current Version</h3>'); |
} |
} |
@f2=split(/\n/,&Apache::lonnet::getfile($fn)); |
@f2=split(/\n/,&Apache::lonnet::getfile($fn)); |
} |
} |
Line 100 sub handler {
|
Line 119 sub handler {
|
|
|
# Start page output |
# Start page output |
|
|
$r->content_type('text/html'); |
|
$r->send_http_header; |
|
|
|
$r->print('<html><head><title>LON-CAPA Construction Diffs</title></head>'); |
|
|
|
$r->print('<body bgcolor="#FFFFFF">'); |
|
|
|
|
|
$r->print('<h1>Compare versions of <tt>'.$ENV{'form.filename'}.'</tt></h1>'); |
|
|
|
my $chunk; |
my $chunk; |
my $line; |
my $line; |
|
|
$r->print('<table border=2><tr><th>Version '.$ENV{'form.versionone'}. |
$r->print('<pre>'); |
'</th><th>Version '.$ENV{'form.versiontwo'}.'</th>'); |
|
foreach $chunk (@$diffs) { |
foreach $chunk (@$diffs) { |
$r->print('</pre></tr><tr><td><pre>'); |
|
my $presign='-'; |
|
foreach $line (@$chunk) { |
foreach $line (@$chunk) { |
my ($sign, $lineno, $text) = @$line; |
my ($sign, $lineno, $text) = @$line; |
if ($sign ne $presign) { |
|
$r->print('</pre></td><td><pre>'); |
|
$presign=$sign; |
|
} |
|
$text=~s/\</\<\;/g; |
$text=~s/\</\<\;/g; |
$text=~s/\>/\>\;/g; |
$text=~s/\>/\>\;/g; |
$lineno=substr($lineno.' ',0,8); |
$lineno=substr($lineno.' ',0,7); |
$r->print($lineno.' '.$text."\n"); |
$r->print('<font color='.(($sign eq '+')?'green':'red').'>'. |
|
$sign.' '.$lineno.' '.$text."</font>\n"); |
} |
} |
|
$r->print("<hr>\n"); |
} |
} |
|
$r->print('</pre>'); |
|
|
$r->print('</tr></table>'); |
} else { |
|
$r->print('<h1><font color=red>Binary File</font></h1>'); |
|
} |
$r->print('</body></html>'); |
$r->print('</body></html>'); |
return OK; |
return OK; |
} |
} |
Line 143 __END__
|
Line 151 __END__
|
|
|
|
|
|
|
|
|