Skip to content

Commit be02eba

Browse files
committed
Initial use of diff2html
1 parent 4fa8259 commit be02eba

File tree

750 files changed

+119611
-7425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

750 files changed

+119611
-7425
lines changed

app/app.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.1/css/materialize.min.css">
77
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
88
<link href="https://cdnjs.cloudflare.com/ajax/libs/loaders.css/0.1.2/loaders.min.css" rel="stylesheet" />
9+
<link href="https://cdnjs.cloudflare.com/ajax/libs/react-datepicker/0.47.0/react-datepicker.min.css" rel="stylesheet" />
10+
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/styles/github.min.css" type="text/css" />
11+
<link href="https://cdnjs.cloudflare.com/ajax/libs/diff2html/2.3.0/diff2html.min.js" type="text/css" />
912
<script>
1013
(function() {
1114
if (!process.env.HOT) {
@@ -45,5 +48,9 @@
4548
);
4649
}
4750
</script>
51+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.js"></script>
52+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/highlight.min.js"></script>
53+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.6.0/languages/scala.min.js"></script>
54+
<script src="https://cdnjs.cloudflare.com/ajax/libs/diff2html/2.3.0/diff2html.min.js"></script>
4855
</body>
4956
</html>

app/components/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default class Home extends Component {
1111
loading: boolean
1212
};
1313

14-
constructor(props) {
14+
constructor(props: any) {
1515
super(props);
1616
this.state = {
1717
loading: true

app/components/SvnRevisionList.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474

7575
div {
7676
text-align: left !important;
77+
cursor: pointer;
7778
}
7879

7980
i {

app/components/SvnRevisionList.js

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import _ from 'lodash';
77
import dateFormat from 'dateformat';
88
import DatePicker from 'react-datepicker';
99
import moment from 'moment';
10-
import { func, array, date } from 'prop-types';
10+
import { Diff2Html, Diff2HtmlUI } from 'diff2html';
1111
import DiffSvn2Git from 'diffsvn2git';
12+
import ReactHtmlParser from 'react-html-parser';
13+
import { array, boolean, func, date } from 'prop-types';
1214
import 'react-datepicker/dist/react-datepicker.css';
1315
import styles from './SvnRevisionList.css';
1416

@@ -25,43 +27,61 @@ export default class SvnRevisionList extends Component {
2527
revisions: array,
2628
revisionDate: date,
2729
onRevisionDateChanged: func.isRequired,
28-
startRevisionLoading: func.isRequired
30+
startRevisionLoading: func.isRequired,
31+
prettyDiffHtml: string
2932
};
3033

3134
constructor(props) {
3235
super(props);
3336
this.state = {
3437
revisions: [],
35-
revisionDate: moment('15/04/2011', 'DD/MM/YYYY')
38+
revisionDate: moment('13/04/2015', 'DD/MM/YYYY'),
39+
prettyDiffHtml: ''
3640
};
3741
}
3842

3943
componentWillMount() {
40-
this.fetchRevisionList();
44+
this.fetchRevisionList(this.state.revisionDate);
4145
}
4246

43-
fetchRevisionList() {
44-
if (moment(this.state.revisionDate, 'DD/MM/YYYY').isValid()) {
47+
fetchRevisionList(dateChanged: date) {
48+
if (moment(dateChanged, 'DD/MM/YYYY').isValid()) {
4549
this.setState({ revisions: [] });
4650

4751
this.props.startRevisionLoading(true);
4852
const self = this;
49-
console.log('revisionDate: ', moment(this.state.revisionDate, 'DD/MM/YYYY'));
5053

51-
const revisionDateFormated = this.state.revisionDate.format('YYYY-MM-DD');
52-
console.log('revisionDateFormated: ', revisionDateFormated);
54+
const revisionDateFormated = dateChanged.format('YYYY-MM-DD');
5355

5456
diffSvn2Git.listRevisionsByDate(revisionDateFormated).then((loadedRevisions) => {
55-
self.setState({ revisions: loadedRevisions });
57+
self.setState({ revisions: loadedRevisions, prettyDiffHtml: '' });
5658
this.props.startRevisionLoading(false);
5759
});
60+
self.setState({ revisionDate: dateChanged });
5861
}
5962
}
6063

64+
generateDiffTest(revisionSelected) {
65+
console.log('revisionSelected: ', revisionSelected);
66+
diffSvn2Git.parse(revisionSelected).then((patch) => {
67+
console.log('Patch result: ');
68+
69+
console.log('Diff2Html result: ');
70+
const diff2HtmlResult = Diff2Html.getPrettyHtml(patch);
71+
console.log(diff2HtmlResult);
72+
73+
this.setState({ prettyDiffHtml: diff2HtmlResult });
74+
});
75+
}
76+
6177
createItem(rows: Array<any>, revision: Object) {
6278
rows.push(
6379
<li key={revision.$.revision}>
64-
<div style={styles.fileName}>
80+
<div
81+
role="button"
82+
style={styles.fileName}
83+
onClick={this.generateDiffTest(revision.$.revision)}
84+
>
6585
<i className="material-icons">label</i>
6686
<p>{`r${revision.$.revision} | ${dateFormat(revision.date, 'dd/mm/yyyy HH:MM:ss')} | ${revision.author} | ${revision.msg}`}</p>
6787
</div>
@@ -89,10 +109,14 @@ export default class SvnRevisionList extends Component {
89109
dateFormat="DD/MM/YYYY"
90110
selected={this.state.revisionDate}
91111
onChange={this.fetchRevisionList.bind(this)}
112+
isClearable
92113
/>
93114
<ul className="video-list">
94115
{rows}
95116
</ul>
117+
<div>
118+
{ ReactHtmlParser(this.state.prettyDiffHtml) }
119+
</div>
96120
</div>
97121
);
98122
}

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"license": "MIT",
1616
"dependencies": {
1717
"dateformat": "^2.0.0",
18+
"diff2html": "^2.3.0",
1819
"diffsvn2git": "^0.0.25",
1920
"loaders.css": "^0.1.2",
2021
"moment": "^2.18.1",

app/yarn.lock

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# yarn lockfile v1
33

44

5+
abbrev@1:
6+
version "1.1.0"
7+
resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f"
8+
59
asap@~2.0.3:
610
version "2.0.5"
711
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.5.tgz#522765b50c3510490e52d7dcfe085ef9ba96958f"
@@ -40,6 +44,18 @@ dateformat@^2.0.0:
4044
version "2.0.0"
4145
resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.0.0.tgz#2743e3abb5c3fc2462e527dca445e04e9f4dee17"
4246

47+
diff2html@^2.3.0:
48+
version "2.3.0"
49+
resolved "https://registry.yarnpkg.com/diff2html/-/diff2html-2.3.0.tgz#375fb0783ca8fa90307749399bc9c75eb7cf6580"
50+
dependencies:
51+
diff "^3.2.0"
52+
hogan.js "^3.0.2"
53+
whatwg-fetch "^2.0.3"
54+
55+
diff@^3.2.0:
56+
version "3.2.0"
57+
resolved "https://registry.yarnpkg.com/diff/-/diff-3.2.0.tgz#c9ce393a4b7cbd0b058a725c93df299027868ff9"
58+
4359
diffsvn2git@^0.0.25:
4460
version "0.0.25"
4561
resolved "https://registry.yarnpkg.com/diffsvn2git/-/diffsvn2git-0.0.25.tgz#92b8168569369cf4a156759db3170a77be6bd716"
@@ -74,6 +90,13 @@ fbjs@^0.8.9:
7490
setimmediate "^1.0.5"
7591
ua-parser-js "^0.7.9"
7692

93+
hogan.js@^3.0.2:
94+
version "3.0.2"
95+
resolved "https://registry.yarnpkg.com/hogan.js/-/hogan.js-3.0.2.tgz#4cd9e1abd4294146e7679e41d7898732b02c7bfd"
96+
dependencies:
97+
mkdirp "0.3.0"
98+
nopt "1.0.10"
99+
77100
iconv-lite@~0.4.13:
78101
version "0.4.18"
79102
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2"
@@ -107,6 +130,10 @@ loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
107130
dependencies:
108131
js-tokens "^3.0.0"
109132

133+
mkdirp@0.3.0:
134+
version "0.3.0"
135+
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.3.0.tgz#1bbf5ab1ba827af23575143490426455f481fe1e"
136+
110137
moment@^2.17.1, moment@^2.18.1:
111138
version "2.18.1"
112139
resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f"
@@ -118,6 +145,12 @@ node-fetch@^1.0.1:
118145
encoding "^0.1.11"
119146
is-stream "^1.0.1"
120147

148+
nopt@1.0.10:
149+
version "1.0.10"
150+
resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee"
151+
dependencies:
152+
abbrev "1"
153+
121154
object-assign@^4.1.0, object-assign@^4.1.1:
122155
version "4.1.1"
123156
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
@@ -145,15 +178,6 @@ react-datepicker@^0.47.0:
145178
react-onclickoutside "^5.11.1"
146179
tether "^1.4.0"
147180

148-
react-dom@^15.6.1:
149-
version "15.6.1"
150-
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.6.1.tgz#2cb0ed4191038e53c209eb3a79a23e2a4cf99470"
151-
dependencies:
152-
fbjs "^0.8.9"
153-
loose-envify "^1.1.0"
154-
object-assign "^4.1.0"
155-
prop-types "^15.5.10"
156-
157181
react-loaders@^2.5.0:
158182
version "2.5.0"
159183
resolved "https://registry.yarnpkg.com/react-loaders/-/react-loaders-2.5.0.tgz#fb23e9545995a403f8214e893037549aae5088c8"
@@ -206,7 +230,7 @@ ua-parser-js@^0.7.9:
206230
version "0.7.12"
207231
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.12.tgz#04c81a99bdd5dc52263ea29d24c6bf8d4818a4bb"
208232

209-
whatwg-fetch@>=0.10.0:
233+
whatwg-fetch@>=0.10.0, whatwg-fetch@^2.0.3:
210234
version "2.0.3"
211235
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
212236

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,18 @@
189189
"extract-text-webpack-plugin": "^2.1.0",
190190
"font-awesome": "^4.7.0",
191191
"history": "^4.6.1",
192+
"prop-types": "^15.5.10",
192193
"react": "^15.5.4",
193194
"react-datepicker": "^0.47.0",
194195
"react-dom": "^15.5.4",
195196
"react-hot-loader": "3.0.0-beta.6",
197+
"react-html-parser": "^1.0.3",
196198
"react-redux": "^5.0.4",
197199
"react-router": "^4.1.1",
198200
"react-router-dom": "^4.1.1",
199201
"react-router-redux": "^5.0.0-alpha.6",
200202
"redux": "^3.6.0",
201203
"redux-thunk": "^2.2.0",
202-
"prop-types": "^15.5.10",
203204
"source-map-support": "^0.4.14"
204205
},
205206
"devEngines": {

0 commit comments

Comments
 (0)