Skip to content

Commit e2c8748

Browse files
committed
First commit
0 parents  commit e2c8748

25 files changed

+3248
-0
lines changed

IssuesDiff.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
# IssuesDiff - a MantisBT plugin that adds a visual diff between revisions
4+
#
5+
# You should have received a copy of the GNU General Public License
6+
# along with IssuesDiff. If not, see <http://www.gnu.org/licenses/>.
7+
8+
/**
9+
* @copyright Copyright (C) 2017 Samir Aguiar for Intra2net AG - www.intra2net.com
10+
*/
11+
12+
class IssuesDiffPlugin extends MantisPlugin {
13+
14+
public function register() {
15+
$this->name = plugin_lang_get("title");
16+
$this->description = plugin_lang_get("description");
17+
$this->page = '';
18+
19+
$this->version = "0.1";
20+
$this->requires = array(
21+
"MantisCore" => "1.2.9",
22+
);
23+
24+
$this->author = "Samir Aguiar";
25+
$this->contact = "[email protected]";
26+
$this->url = "https://github.com/samiraguiar/issues-diff";
27+
}
28+
29+
public function hooks() {
30+
return array(
31+
"EVENT_MENU_ISSUE" => "get_menu_option",
32+
"EVENT_VIEW_BUG_DETAILS" => "inject_script"
33+
);
34+
}
35+
36+
public function inject_script() {
37+
$plugin_basename = plugin_get_current();
38+
$script_path = plugin_file_path('js/add_diff_view_link.js', $plugin_basename);
39+
$script_contents = file_get_contents($script_path);
40+
41+
$menu_title = plugin_lang_get("menu_title");
42+
$diff_page_url = plugin_page("bug_revision_diff_page", true);
43+
44+
$script = "(function() {" .
45+
"var linkText = '$menu_title';" .
46+
"var diffPageUrl = '$diff_page_url';" .
47+
$script_contents .
48+
"})();";
49+
50+
echo "<script> $script </script>";
51+
}
52+
}

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# MantisBT Issues Diff
2+
MantisBT Plugin to get a visual diff between issues revisions.
3+
4+
![issues diff plugin](http://i.imgur.com/STu5oHB.png)
5+
6+
Copyright (C) 2017 Samir Aguiar for Intra2net AG - www.intra2net.com

files/css/diff_style.css

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
form.diff-form select {
2+
position: relative;
3+
top: 1;
4+
}
5+
6+
form.diff-form input.diff-form-submit {
7+
position: relative;
8+
}
9+
10+
.issue-diff-area {
11+
background-color: #E8E8E8;
12+
}
13+
14+
form.diff-form .issue-diff-separator {
15+
font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace;
16+
padding: 10% 0;
17+
left: 2;
18+
position: relative;
19+
}
20+
21+
.issue-diff-area tr td.Right {
22+
text-align: left;
23+
}
24+
25+
.Differences {
26+
width: 100%;
27+
border-collapse: collapse;
28+
border-spacing: 0;
29+
empty-cells: show;
30+
}
31+
32+
.Differences thead th {
33+
display: none;
34+
}
35+
.Differences tbody th {
36+
display: none;
37+
}
38+
39+
.Differences td {
40+
padding: 1px 2px;
41+
font-family: Consolas, monospace;
42+
font-size: 13px;
43+
}
44+
45+
.DifferencesSideBySide .ChangeInsert td.Left {
46+
background: #dfd;
47+
}
48+
49+
.DifferencesSideBySide .ChangeInsert td.Right {
50+
background: #cfc;
51+
}
52+
53+
.DifferencesSideBySide .ChangeDelete td.Left {
54+
background: #f88;
55+
}
56+
57+
.DifferencesSideBySide .ChangeDelete td.Right {
58+
background: #faa;
59+
}
60+
61+
.DifferencesSideBySide .ChangeReplace .Left {
62+
background: #fe9;
63+
}
64+
65+
.DifferencesSideBySide .ChangeReplace .Right {
66+
background: #fd8;
67+
}
68+
69+
.Differences ins, .Differences del {
70+
text-decoration: none;
71+
}
72+
73+
.DifferencesSideBySide .ChangeReplace ins, .DifferencesSideBySide .ChangeReplace del {
74+
background: #fc0;
75+
}
76+
77+
.Differences .Skipped {
78+
background: #f7f7f7;
79+
}
80+
81+
.DifferencesInline .ChangeReplace .Left,
82+
.DifferencesInline .ChangeDelete .Left {
83+
background: #fdd;
84+
}
85+
86+
.DifferencesInline .ChangeReplace .Right,
87+
.DifferencesInline .ChangeInsert .Right {
88+
background: #dfd;
89+
}
90+
91+
.DifferencesInline .ChangeReplace ins {
92+
background: #9e9;
93+
}
94+
95+
.DifferencesInline .ChangeReplace del {
96+
background: #e99;
97+
}

files/js/add_diff_view_link.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
function appendAnchor(cellElement, bug_view_link) {
2+
var anchor = document.createElement("A");
3+
anchor.text = linkText;
4+
anchor.href = bug_view_link;
5+
6+
cellElement.appendChild(getSplitter());
7+
cellElement.appendChild(anchor);
8+
}
9+
10+
function getSplitter() {
11+
var span = document.createElement("SPAN");
12+
span.innerHTML = " | "
13+
14+
return span;
15+
}
16+
17+
function getQueryString(url) {
18+
var questionMarkIndex = url.indexOf('?');
19+
20+
if (questionMarkIndex === -1) return '';
21+
22+
var newUrl = url.slice(questionMarkIndex + 1).replace("#r", "&last=");
23+
24+
return '&' + newUrl;
25+
}
26+
27+
function addDiffViewLink() {
28+
var issueHistory = document.getElementById("history_open");
29+
30+
var rows = issueHistory.getElementsByTagName("tr");
31+
32+
for (var i = 0; i < rows.length; i++) {
33+
var changeCell = rows[i].lastElementChild;
34+
35+
if (!changeCell) continue;
36+
37+
var cellAnchor = changeCell.getElementsByTagName("a");
38+
39+
if (!cellAnchor.length) continue;
40+
41+
var revisionUrl = cellAnchor[0].getAttribute("href");
42+
43+
if (revisionUrl.indexOf("bug_revision_view_page") === -1) {
44+
continue;
45+
}
46+
47+
var queryString = getQueryString(revisionUrl);
48+
49+
appendAnchor(changeCell, diffPageUrl + queryString);
50+
}
51+
}
52+
53+
if (window.addEventListener){
54+
window.addEventListener('load', addDiffViewLink)
55+
} else{
56+
window.attachEvent('onload', addDiffViewLink)
57+
}

files/vendor/php-diff/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/nbproject/

files/vendor/php-diff/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
PHP Diff Class
2+
--------------
3+
4+
Introduction
5+
------------
6+
A comprehensive library for generating differences between
7+
two hashable objects (strings or arrays). Generated differences can be
8+
rendered in all of the standard formats including:
9+
* Unified
10+
* Context
11+
* Inline HTML
12+
* Side by Side HTML
13+
14+
The logic behind the core of the diff engine (ie, the sequence matcher)
15+
is primarily based on the Python difflib package. The reason for doing
16+
so is primarily because of its high degree of accuracy.
17+
18+
Example Use
19+
-----------
20+
A quick usage example can be found in the example/ directory and under
21+
example.php.
22+
23+
More complete documentation will be available shortly.
24+
25+
Merge files using jQuery
26+
------------------------
27+
Xiphe has build a jQuery plugin with that you can merge the compared
28+
files. Have a look at [jQuery-Merge-for-php-diff](https://github.com/Xiphe/jQuery-Merge-for-php-diff).
29+
30+
Todo
31+
----
32+
* Ability to ignore blank line changes
33+
* 3 way diff support
34+
* Performance optimizations
35+
36+
License (BSD License)
37+
---------------------
38+
Copyright (c) 2009 Chris Boulton <[email protected]>
39+
All rights reserved.
40+
41+
Redistribution and use in source and binary forms, with or without
42+
modification, are permitted provided that the following conditions are met:
43+
44+
- Redistributions of source code must retain the above copyright notice,
45+
this list of conditions and the following disclaimer.
46+
- Redistributions in binary form must reproduce the above copyright notice,
47+
this list of conditions and the following disclaimer in the documentation
48+
and/or other materials provided with the distribution.
49+
- Neither the name of the Chris Boulton nor the names of its contributors
50+
may be used to endorse or promote products derived from this software
51+
without specific prior written permission.
52+
53+
```
54+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
55+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
56+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
57+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
58+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
59+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
60+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
61+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
62+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
63+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
64+
POSSIBILITY OF SUCH DAMAGE.
65+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "chrisboulton/php-diff",
3+
"type": "library",
4+
"description": "A comprehensive library for generating differences between two hashable objects (strings or arrays).",
5+
"authors": [
6+
{
7+
"name": "Chris Boulton",
8+
"email": "@chrisboulton"
9+
}
10+
],
11+
"autoload": {
12+
"psr-0": {
13+
"Diff": "lib/"
14+
}
15+
},
16+
"require-dev": {
17+
"phpunit/phpunit": "~5.5"
18+
}
19+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
4+
<title>Hello World!</title>
5+
</head>
6+
<body>
7+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
8+
9+
<h2>A heading we'll be removing</h2>
10+
11+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
12+
</body>
13+
</html>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<html>
2+
<head>
3+
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
4+
<title>Goodbye Cruel World!</title>
5+
</head>
6+
<body>
7+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
8+
9+
10+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
11+
12+
<p>Just a small amount of new text...</p>
13+
</body>
14+
</html>

0 commit comments

Comments
 (0)