event-history.cgi: use diff for event history
This commit is contained in:
@@ -8,9 +8,6 @@ use URI::Escape();
|
|||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use MIME::Base64();
|
use MIME::Base64();
|
||||||
|
|
||||||
#use Text::Diff::FormattedHTML();
|
|
||||||
use Text::Diff::Unified::XS;
|
|
||||||
|
|
||||||
use params();
|
use params();
|
||||||
use config();
|
use config();
|
||||||
use entry();
|
use entry();
|
||||||
@@ -26,8 +23,8 @@ use event_history();
|
|||||||
use events();
|
use events();
|
||||||
use series_events();
|
use series_events();
|
||||||
use localization();
|
use localization();
|
||||||
|
use utf8;
|
||||||
#binmode STDOUT, ":utf8";
|
binmode STDOUT, ":utf8";
|
||||||
|
|
||||||
my $r = shift;
|
my $r = shift;
|
||||||
( my $cgi, my $params, my $error ) = params::get($r);
|
( my $cgi, my $params, my $error ) = params::get($r);
|
||||||
@@ -36,10 +33,17 @@ my $config = config::get('../config/config.cgi');
|
|||||||
my $debug = $config->{system}->{debug};
|
my $debug = $config->{system}->{debug};
|
||||||
my ( $user, $expires ) = auth::get_user( $config, $params, $cgi );
|
my ( $user, $expires ) = auth::get_user( $config, $params, $cgi );
|
||||||
return if ( ( !defined $user ) || ( $user eq '' ) );
|
return if ( ( !defined $user ) || ( $user eq '' ) );
|
||||||
|
my $user_presets = uac::get_user_presets(
|
||||||
my $user_presets = uac::get_user_presets( $config, { user => $user, studio_id => $params->{studio_id} } );
|
$config,
|
||||||
|
{
|
||||||
|
user => $user,
|
||||||
|
project_id => $params->{project_id},
|
||||||
|
studio_id => $params->{studio_id}
|
||||||
|
}
|
||||||
|
);
|
||||||
$params->{default_studio_id} = $user_presets->{studio_id};
|
$params->{default_studio_id} = $user_presets->{studio_id};
|
||||||
$params = uac::setDefaultStudio( $params, $user_presets );
|
$params = uac::setDefaultStudio( $params, $user_presets );
|
||||||
|
$params = uac::setDefaultProject( $params, $user_presets );
|
||||||
|
|
||||||
my $request = {
|
my $request = {
|
||||||
url => $ENV{QUERY_STRING} || '',
|
url => $ENV{QUERY_STRING} || '',
|
||||||
@@ -61,12 +65,16 @@ template::process( $config, 'print', template::check( $config, 'default.html' ),
|
|||||||
return unless uac::check( $config, $params, $user_presets ) == 1;
|
return unless uac::check( $config, $params, $user_presets ) == 1;
|
||||||
|
|
||||||
print q{
|
print q{
|
||||||
<script src="js/datetime.js" type="text/javascript"></script>
|
<style>
|
||||||
<script src="js/event.js" type="text/javascript"></script>
|
pre{
|
||||||
<link rel="stylesheet" href="css/event.css" type="text/css" />
|
font-family:monospace;
|
||||||
|
}
|
||||||
<script src="js/diff2html.min.js" type="text/javascript"></script>
|
textarea{
|
||||||
<link rel="stylesheet" href="css/diff2html.min.css" type="text/css" />
|
height:fit-content;
|
||||||
|
min-height:500px;
|
||||||
|
width:50%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
};
|
};
|
||||||
|
|
||||||
$config->{access}->{write} = 0;
|
$config->{access}->{write} = 0;
|
||||||
@@ -135,8 +143,6 @@ sub compare {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
print qq{<link href="css/diff.css" rel="stylesheet">} . "\n";
|
|
||||||
|
|
||||||
if ( $params->{v1} > $params->{v2} ) {
|
if ( $params->{v1} > $params->{v2} ) {
|
||||||
my $t = $params->{v1};
|
my $t = $params->{v1};
|
||||||
$params->{v1} = $params->{v2};
|
$params->{v1} = $params->{v2};
|
||||||
@@ -172,58 +178,59 @@ sub compare {
|
|||||||
print '<textarea>' . $t1 . '</textarea>';
|
print '<textarea>' . $t1 . '</textarea>';
|
||||||
print '<textarea>' . $t2 . '</textarea>';
|
print '<textarea>' . $t2 . '</textarea>';
|
||||||
|
|
||||||
#log::save_file('/tmp/diff-a.txt', $t1);
|
my $cmd="/usr/bin/colordiff /tmp/diff-a.txt /tmp/diff-b.txt | ansi2html";
|
||||||
#log::save_file('/tmp/diff-b.txt', $t2);
|
#print "$cmd\n";
|
||||||
#my $diff=`/usr/bin/diff /tmp/diff-a.txt /tmp/diff-b.txt`;
|
log::save_file('/tmp/diff-a.txt', $t1);
|
||||||
|
log::save_file('/tmp/diff-b.txt', $t2);
|
||||||
my $diff = diff( \$t1, \$t2 );
|
print qq{
|
||||||
|
<style>
|
||||||
#$diff=~s/\&/\&/g;
|
pre {
|
||||||
#$diff=~s/\</\</g;
|
font-weight: normal;
|
||||||
#$diff=~s/\>/\>/g;
|
color: #bbb;
|
||||||
#$diff=~s/\"/\"/g;
|
white-space: -moz-pre-wrap;
|
||||||
#$diff=~s/\'/\'/g;
|
white-space: -o-pre-wrap;
|
||||||
$diff =~ s/\'/\\\'/g;
|
white-space: -pre-wrap;
|
||||||
|
white-space: pre-wrap;
|
||||||
#$diff=~s/\n/\'+\'/g;
|
word-wrap: break-word;
|
||||||
$diff = join( qq{\\n' + '}, split( /\r?\n/, $diff ) );
|
overflow-wrap: break-word;
|
||||||
|
}
|
||||||
#<pre id="diff">$diff</pre>
|
b {font-weight: normal}
|
||||||
print qq!
|
b.BOLD {color: #fff}
|
||||||
<div id="result"></div>
|
b.ITA {font-style: italic}
|
||||||
<script>
|
b.UND {text-decoration: underline}
|
||||||
var diff='$diff';
|
b.STR {text-decoration: line-through}
|
||||||
\$(document).ready(function(){
|
b.UNDSTR {text-decoration: underline line-through}
|
||||||
//var diff=\$('#diff').html();
|
b.BLK {color: #000000}
|
||||||
console.log(diff)
|
b.RED {color: #aa0000}
|
||||||
var diffHtml = Diff2Html.getPrettyHtml(
|
b.GRN {color: #00aa00}
|
||||||
diff,
|
b.YEL {color: #aa5500}
|
||||||
{
|
b.BLU {color: #0000aa}
|
||||||
inputFormat: 'diff',
|
b.MAG {color: #aa00aa}
|
||||||
showFiles: true,
|
b.CYN {color: #00aaaa}
|
||||||
matching: 'words',
|
b.WHI {color: #aaaaaa}
|
||||||
outputFormat: 'side-by-side'
|
b.HIK {color: #555555}
|
||||||
}
|
b.HIR {color: #ff5555}
|
||||||
);
|
b.HIG {color: #55ff55}
|
||||||
document.getElementById("result").innerHTML = diffHtml;
|
b.HIY {color: #ffff55}
|
||||||
});
|
b.HIB {color: #5555ff}
|
||||||
</script>
|
b.HIM {color: #ff55ff}
|
||||||
</div>
|
b.HIC {color: #55ffff}
|
||||||
</body>
|
b.HIW {color: #ffffff}
|
||||||
!;
|
b.BBLK {background-color: #000000}
|
||||||
|
b.BRED {background-color: #aa0000}
|
||||||
#print '<script>var a="'.$diff.'";</script>';
|
b.BGRN {background-color: #00aa00}
|
||||||
|
b.BYEL {background-color: #aa5500}
|
||||||
#print "<style>".diff_css."</style>";
|
b.BBLU {background-color: #0000aa}
|
||||||
#print '<pre>';
|
b.BMAG {background-color: #aa00aa}
|
||||||
#my $diff=diff_strings( { vertical => 1 }, $t1, $t2);
|
b.BCYN {background-color: #00aaaa}
|
||||||
#my $diff = Text::Diff::FormattedHTML::diff_strings( {}, $t1, $t2 );
|
b.BWHI {background-color: #aaaaaa}
|
||||||
|
</style>
|
||||||
#print Text::Diff::diff(\$t1, \$t2, { STYLE => "Table" });
|
};
|
||||||
#print Text::Diff::diff($v1, $v2, { STYLE => "Table" });
|
my $diff = qx{$cmd};
|
||||||
#print $diff;
|
$diff = substr($diff, index($diff, "<body>")+6);
|
||||||
|
$diff = substr($diff, 0, index($diff, "</body>"));
|
||||||
#print '</pre>';
|
print "$diff\n";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub eventToText {
|
sub eventToText {
|
||||||
|
|||||||
Reference in New Issue
Block a user