mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-01-03 20:29:34 -05:00
ConfigDiff: Utilize new php-diff library
This commit is contained in:
parent
ad2ea6f8c5
commit
dde924e2b4
2 changed files with 11 additions and 144 deletions
|
|
@ -2,12 +2,9 @@
|
|||
|
||||
namespace Icinga\Module\Businessprocess\Storage;
|
||||
|
||||
use Diff;
|
||||
use Diff_Renderer_Html_Inline;
|
||||
use Diff_Renderer_Html_SideBySide;
|
||||
use Diff_Renderer_Text_Context;
|
||||
use Diff_Renderer_Text_Unified;
|
||||
use ipl\Html\ValidHtml;
|
||||
use Jfcherng\Diff\Differ;
|
||||
use Jfcherng\Diff\Factory\RendererFactory;
|
||||
|
||||
class ConfigDiff implements ValidHtml
|
||||
{
|
||||
|
|
@ -20,8 +17,6 @@ class ConfigDiff implements ValidHtml
|
|||
|
||||
protected function __construct($a, $b)
|
||||
{
|
||||
$this->requireVendorLib('Diff.php');
|
||||
|
||||
if (empty($a)) {
|
||||
$this->a = array();
|
||||
} else {
|
||||
|
|
@ -39,7 +34,7 @@ class ConfigDiff implements ValidHtml
|
|||
// 'ignoreWhitespace' => true,
|
||||
// 'ignoreCase' => true,
|
||||
);
|
||||
$this->diff = new Diff($this->a, $this->b, $options);
|
||||
$this->diff = new Differ($this->a, $this->b, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -52,35 +47,26 @@ class ConfigDiff implements ValidHtml
|
|||
|
||||
public function renderHtmlSideBySide()
|
||||
{
|
||||
$this->requireVendorLib('Diff/Renderer/Html/SideBySide.php');
|
||||
$renderer = new Diff_Renderer_Html_SideBySide;
|
||||
return $this->diff->render($renderer);
|
||||
$renderer = RendererFactory::make('SideBySide');
|
||||
return $renderer->render($this->diff);
|
||||
}
|
||||
|
||||
public function renderHtmlInline()
|
||||
{
|
||||
$this->requireVendorLib('Diff/Renderer/Html/Inline.php');
|
||||
$renderer = new Diff_Renderer_Html_Inline;
|
||||
return $this->diff->render($renderer);
|
||||
$renderer = RendererFactory::make('Inline');
|
||||
return $renderer->render($this->diff);
|
||||
}
|
||||
|
||||
public function renderTextContext()
|
||||
{
|
||||
$this->requireVendorLib('Diff/Renderer/Text/Context.php');
|
||||
$renderer = new Diff_Renderer_Text_Context;
|
||||
return $this->diff->render($renderer);
|
||||
$renderer = RendererFactory::make('Context');
|
||||
return $renderer->render($this->diff);
|
||||
}
|
||||
|
||||
public function renderTextUnified()
|
||||
{
|
||||
$this->requireVendorLib('Diff/Renderer/Text/Unified.php');
|
||||
$renderer = new Diff_Renderer_Text_Unified;
|
||||
return $this->diff->render($renderer);
|
||||
}
|
||||
|
||||
protected function requireVendorLib($file)
|
||||
{
|
||||
require_once dirname(dirname(__DIR__)) . '/vendor/php-diff/lib/' . $file;
|
||||
$renderer = RendererFactory::make('Unified');
|
||||
return $renderer->render($this->diff);
|
||||
}
|
||||
|
||||
public static function create($a, $b)
|
||||
|
|
|
|||
|
|
@ -768,25 +768,6 @@ table.sourcecode {
|
|||
}
|
||||
}
|
||||
|
||||
.diff {
|
||||
font-family: monospace;
|
||||
white-space: pre-wrap;
|
||||
|
||||
del, ins {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
del {
|
||||
color: @colorCritical;
|
||||
background-color: #fdd;
|
||||
}
|
||||
|
||||
ins {
|
||||
color: @colorOk;
|
||||
background-color: #dfd;
|
||||
}
|
||||
}
|
||||
|
||||
/** Forms stolen from director **/
|
||||
.content form {
|
||||
margin-bottom: 2em;
|
||||
|
|
@ -1096,106 +1077,6 @@ form {
|
|||
|
||||
/** END of forms **/
|
||||
|
||||
/** php-diff **/
|
||||
.Differences {
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
empty-cells: show;
|
||||
}
|
||||
|
||||
.Differences thead {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.Differences thead th {
|
||||
text-align: left;
|
||||
padding-left: 4 / 14 * 16em;
|
||||
}
|
||||
.Differences tbody th {
|
||||
text-align: right;
|
||||
width: 4em;
|
||||
padding: 1px 2px;
|
||||
border-right: 1px solid @gray-light;
|
||||
background: @gray-lightest;
|
||||
font-weight: normal;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.Differences tbody td {
|
||||
width: 50%;
|
||||
.preformatted();
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
@color-diff-ins: #bfb;
|
||||
@color-diff-del: #faa;
|
||||
@color-diff-changed-old: #fdd;
|
||||
@color-diff-changed-new: #efe;
|
||||
|
||||
.DifferencesSideBySide {
|
||||
ins, del {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.ChangeInsert {
|
||||
td.Left {
|
||||
background: @gray-lighter;
|
||||
}
|
||||
td.Right {
|
||||
background: @color-diff-ins;
|
||||
}
|
||||
}
|
||||
|
||||
.ChangeDelete {
|
||||
td.Left {
|
||||
background: @color-diff-del;
|
||||
}
|
||||
td.Right {
|
||||
background: @gray-lighter;
|
||||
}
|
||||
}
|
||||
|
||||
.ChangeReplace {
|
||||
td.Left {
|
||||
background: @color-diff-changed-old;
|
||||
del {
|
||||
background: @color-diff-del;
|
||||
}
|
||||
}
|
||||
|
||||
td.Right {
|
||||
background: @color-diff-changed-new;
|
||||
ins {
|
||||
background: @color-diff-ins;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
.Differences .Skipped {
|
||||
background: @gray-lightest;
|
||||
}
|
||||
|
||||
.DifferencesInline .ChangeReplace .Left,
|
||||
.DifferencesInline .ChangeDelete .Left {
|
||||
background: #fdd;
|
||||
}
|
||||
|
||||
.DifferencesInline .ChangeReplace .Right,
|
||||
.DifferencesInline .ChangeInsert .Right {
|
||||
background: #dfd;
|
||||
}
|
||||
|
||||
.DifferencesInline .ChangeReplace ins {
|
||||
background: #9e9;
|
||||
}
|
||||
|
||||
.DifferencesInline .ChangeReplace del {
|
||||
background: #e99;
|
||||
}
|
||||
/** END of php-diff **/
|
||||
|
||||
/** Custom font styling **/
|
||||
textarea.smaller {
|
||||
font-size: 0.833em;
|
||||
|
|
|
|||
Loading…
Reference in a new issue