Fix nunjucks in the browser
This commit is contained in:
parent
e15cde2d6f
commit
7638fbba52
12 changed files with 3286 additions and 123 deletions
24
dist/diff2html.css
vendored
24
dist/diff2html.css
vendored
|
|
@ -244,7 +244,7 @@
|
|||
}
|
||||
|
||||
.d2h-file-list {
|
||||
display: block;
|
||||
display: none;
|
||||
}
|
||||
|
||||
.d2h-clear {
|
||||
|
|
@ -268,10 +268,24 @@ ins.d2h-change, del.d2h-change {
|
|||
background-color: #ded;
|
||||
}
|
||||
|
||||
.d2h-file-switch {
|
||||
/* CSS only show/hide */
|
||||
.d2h-show {
|
||||
display: none;
|
||||
float: left;
|
||||
font-size: 10px;
|
||||
cursor: pointer;
|
||||
margin-top: 3px;
|
||||
}
|
||||
|
||||
.d2h-hide {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.d2h-hide:target + .d2h-show {
|
||||
display: inline;
|
||||
}
|
||||
|
||||
.d2h-hide:target {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.d2h-hide:target ~ .d2h-file-list {
|
||||
display: block;
|
||||
}
|
||||
|
|
|
|||
3066
dist/diff2html.js
vendored
3066
dist/diff2html.js
vendored
File diff suppressed because it is too large
Load diff
2
dist/diff2html.min.css
vendored
2
dist/diff2html.min.css
vendored
|
|
@ -1 +1 @@
|
|||
.d2h-code-line-prefix,.line-num1{float:left}.d2h-wrapper{display:block;margin:0 auto;text-align:left;width:100%}.d2h-file-wrapper{border:1px solid #ddd;border-radius:3px;margin-bottom:1em}.d2h-file-header{padding:5px 10px;border-bottom:1px solid #d8d8d8;background-color:#f7f7f7;font:13px Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol"}.d2h-file-stats{display:inline;font-size:12px;text-align:center;max-width:15%}.d2h-lines-added{text-align:right}.d2h-lines-added>*{background-color:#ceffce;border:1px solid #b4e2b4;color:#399839;border-radius:5px 0 0 5px;padding:2px}.d2h-lines-deleted{text-align:left}.d2h-lines-deleted>*{background-color:#f7c8c8;border:1px solid #e9aeae;color:#c33;border-radius:0 5px 5px 0;padding:2px}.d2h-file-name{display:inline;line-height:33px;max-width:80%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.d2h-file-diff,.d2h-file-side-diff{overflow-x:scroll;overflow-y:hidden}.d2h-diff-table{border-collapse:collapse;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;height:18px;line-height:18px;width:100%}.d2h-files-diff{width:100%}.d2h-file-side-diff{display:inline-block;width:50%;margin-right:-4px}.d2h-code-line,.d2h-code-side-line{white-space:pre;padding:0 10px;height:18px;line-height:18px;color:inherit;overflow-x:inherit;background:0 0;display:block}.d2h-code-line{margin-left:80px}.d2h-code-side-line{margin-left:50px}.d2h-code-line del,.d2h-code-side-line del{display:inline-block;margin-top:-1px;text-decoration:none;background-color:#ffb6ba;border-radius:.2em}.d2h-code-line ins,.d2h-code-side-line ins{display:inline-block;margin-top:-1px;text-decoration:none;background-color:#97f295;border-radius:.2em}.d2h-code-line-ctn,.d2h-code-line-prefix{background:0 0;padding:0}.d2h-code-linenumber,.d2h-code-side-linenumber{position:absolute;height:18px;line-height:18px;background-color:#fff;text-align:right;color:rgba(0,0,0,.3);cursor:pointer}.line-num1,.line-num2{width:32px;padding-left:3px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis}.line-num2{float:right}.d2h-code-linenumber{box-sizing:border-box;width:82px;padding-left:2px;padding-right:2px;border:solid #eee;border-width:0 1px}.d2h-code-side-linenumber{box-sizing:border-box;width:52px;padding-left:10px;padding-right:10px;border:solid #eee;border-width:0 1px;overflow:hidden;text-overflow:ellipsis}.d2h-del{background-color:#fee8e9;border-color:#e9aeae}.d2h-ins{background-color:#dfd;border-color:#b4e2b4}.d2h-info{background-color:#f8fafd;color:rgba(0,0,0,.3);border-color:#d5e4f2}.d2h-file-list-wrapper{margin-bottom:10px;padding:0 10px}.d2h-file-list-wrapper a{text-decoration:none;color:#3572b0}.d2h-file-list-wrapper a:visited{color:#3572b0}.d2h-file-list-header{font-weight:700;float:left}.d2h-file-list-line{text-align:left;font:13px Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol"}.d2h-file-list-line .d2h-file-name{line-height:21px}.d2h-file-list{display:block}.d2h-clear{display:block;clear:both}.d2h-del.d2h-change,.d2h-ins.d2h-change{background-color:#ffc}del.d2h-change,ins.d2h-change{background-color:#fad771}.d2h-file-diff .d2h-del.d2h-change{background-color:#fae1af}.d2h-file-diff .d2h-ins.d2h-change{background-color:#ded}.d2h-file-switch{display:none;float:left;font-size:10px;cursor:pointer;margin-top:3px}
|
||||
.d2h-code-line-prefix,.line-num1{float:left}.d2h-wrapper{display:block;margin:0 auto;text-align:left;width:100%}.d2h-file-wrapper{border:1px solid #ddd;border-radius:3px;margin-bottom:1em}.d2h-file-header{padding:5px 10px;border-bottom:1px solid #d8d8d8;background-color:#f7f7f7;font:13px Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol"}.d2h-file-stats{display:inline;font-size:12px;text-align:center;max-width:15%}.d2h-lines-added{text-align:right}.d2h-lines-added>*{background-color:#ceffce;border:1px solid #b4e2b4;color:#399839;border-radius:5px 0 0 5px;padding:2px}.d2h-lines-deleted{text-align:left}.d2h-lines-deleted>*{background-color:#f7c8c8;border:1px solid #e9aeae;color:#c33;border-radius:0 5px 5px 0;padding:2px}.d2h-file-name{display:inline;line-height:33px;max-width:80%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.d2h-file-diff,.d2h-file-side-diff{overflow-x:scroll;overflow-y:hidden}.d2h-diff-table{border-collapse:collapse;font-family:Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:12px;height:18px;line-height:18px;width:100%}.d2h-files-diff{width:100%}.d2h-file-side-diff{display:inline-block;width:50%;margin-right:-4px}.d2h-code-line,.d2h-code-side-line{display:block;padding:0 10px;height:18px;line-height:18px;color:inherit;overflow-x:inherit;background:0 0}.d2h-code-line{margin-left:80px}.d2h-code-side-line{white-space:pre;margin-left:50px}.d2h-code-line del,.d2h-code-side-line del{display:inline-block;margin-top:-1px;text-decoration:none;background-color:#ffb6ba;border-radius:.2em}.d2h-code-line ins,.d2h-code-side-line ins{display:inline-block;margin-top:-1px;text-decoration:none;background-color:#97f295;border-radius:.2em}.d2h-code-line-ctn,.d2h-code-line-prefix{background:0 0;padding:0}.d2h-code-linenumber,.d2h-code-side-linenumber{position:absolute;height:18px;line-height:18px;background-color:#fff;text-align:right;cursor:pointer;color:rgba(0,0,0,.3)}.line-num1,.line-num2{width:32px;padding-left:3px;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis}.line-num2{float:right}.d2h-hide,.d2h-show{float:left}.d2h-code-linenumber{box-sizing:border-box;width:82px;padding-left:2px;padding-right:2px;border:solid #eee;border-width:0 1px}.d2h-code-side-linenumber{box-sizing:border-box;width:52px;padding-left:10px;padding-right:10px;border:solid #eee;border-width:0 1px;overflow:hidden;text-overflow:ellipsis}.d2h-del{background-color:#fee8e9;border-color:#e9aeae}.d2h-ins{background-color:#dfd;border-color:#b4e2b4}.d2h-info{background-color:#f8fafd;color:rgba(0,0,0,.3);border-color:#d5e4f2}.d2h-file-list-wrapper{margin-bottom:10px;padding:0 10px}.d2h-file-list-wrapper a{text-decoration:none;color:#3572b0}.d2h-file-list-wrapper a:visited{color:#3572b0}.d2h-file-list-header{font-weight:700;float:left}.d2h-file-list-line{text-align:left;font:13px Helvetica,arial,freesans,clean,sans-serif,"Segoe UI Emoji","Segoe UI Symbol"}.d2h-file-list-line .d2h-file-name{line-height:21px}.d2h-file-list{display:none}.d2h-clear{display:block;clear:both}.d2h-del.d2h-change,.d2h-ins.d2h-change{background-color:#ffc}del.d2h-change,ins.d2h-change{background-color:#fad771}.d2h-file-diff .d2h-del.d2h-change{background-color:#fae1af}.d2h-file-diff .d2h-ins.d2h-change{background-color:#ded}.d2h-show{display:none}.d2h-hide:target+.d2h-show{display:inline}.d2h-hide:target{display:none}.d2h-hide:target~.d2h-file-list{display:block}
|
||||
6
dist/diff2html.min.js
vendored
6
dist/diff2html.min.js
vendored
File diff suppressed because one or more lines are too long
171
dist/templates.js
vendored
Normal file
171
dist/templates.js
vendored
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/column-line-number.html"] = (function() {
|
||||
function root(env, context, frame, runtime, cb) {
|
||||
var lineno = null;
|
||||
var colno = null;
|
||||
var output = "";
|
||||
try {
|
||||
var parentTemplate = null;
|
||||
output += "<tr>\n <td class=\"d2h-code-linenumber ";
|
||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
||||
output += "\"></td>\n <td class=\"";
|
||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
||||
output += "\">\n <div class=\"d2h-code-line ";
|
||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
||||
output += "\"> ";
|
||||
output += runtime.suppressValue((lineno = 3, colno = 73, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"escape"), "utils[\"escape\"]", context, [runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "block")),"header")])), env.opts.autoescape);
|
||||
output += " </div>\n </td>\n</tr>\n";
|
||||
if(parentTemplate) {
|
||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
||||
} else {
|
||||
cb(null, output);
|
||||
}
|
||||
;
|
||||
} catch (e) {
|
||||
cb(runtime.handleError(e, lineno, colno));
|
||||
}
|
||||
}
|
||||
return {
|
||||
root: root
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/empty-diff.html"] = (function() {
|
||||
function root(env, context, frame, runtime, cb) {
|
||||
var lineno = null;
|
||||
var colno = null;
|
||||
var output = "";
|
||||
try {
|
||||
var parentTemplate = null;
|
||||
output += "<tr>\n <td class=\"";
|
||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
||||
output += "\">\n <div class=\"d2h-code-line ";
|
||||
output += runtime.suppressValue(runtime.memberLookup((runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "diffParser")),"LINE_TYPE")),"INFO"), env.opts.autoescape);
|
||||
output += "\">\n File without changes\n </div>\n </td>\n</tr>\n";
|
||||
if(parentTemplate) {
|
||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
||||
} else {
|
||||
cb(null, output);
|
||||
}
|
||||
;
|
||||
} catch (e) {
|
||||
cb(runtime.handleError(e, lineno, colno));
|
||||
}
|
||||
}
|
||||
return {
|
||||
root: root
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/file-diff.html"] = (function() {
|
||||
function root(env, context, frame, runtime, cb) {
|
||||
var lineno = null;
|
||||
var colno = null;
|
||||
var output = "";
|
||||
try {
|
||||
var parentTemplate = null;
|
||||
output += "<div id=\"";
|
||||
output += runtime.suppressValue((lineno = 0, colno = 32, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "printerUtils")),"getHtmlId"), "printerUtils[\"getHtmlId\"]", context, [runtime.contextOrFrameLookup(context, frame, "file")])), env.opts.autoescape);
|
||||
output += "\" class=\"d2h-file-wrapper\" data-lang=\"";
|
||||
output += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "file")),"language"), env.opts.autoescape);
|
||||
output += "\">\n <div class=\"d2h-file-header\">\n <div class=\"d2h-file-stats\">\n <span class=\"d2h-lines-added\">\n <span>+";
|
||||
output += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "file")),"addedLines"), env.opts.autoescape);
|
||||
output += "</span>\n </span>\n <span class=\"d2h-lines-deleted\">\n <span>-";
|
||||
output += runtime.suppressValue(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "file")),"deletedLines"), env.opts.autoescape);
|
||||
output += "</span>\n </span>\n </div>\n <div class=\"d2h-file-name\"> ";
|
||||
output += runtime.suppressValue((lineno = 10, colno = 62, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "printerUtils")),"getDiffName"), "printerUtils[\"getDiffNam\"]", context, [runtime.contextOrFrameLookup(context, frame, "file")])), env.opts.autoescape);
|
||||
output += "</div>\n </div>\n <div class=\"d2h-file-diff\">\n <div class=\"d2h-code-wrapper\">\n <table class=\"d2h-diff-table\">\n <tbody class=\"d2h-diff-tbody\">\n ";
|
||||
output += runtime.suppressValue(env.getFilter("safe").call(context, runtime.contextOrFrameLookup(context, frame, "diffs")), env.opts.autoescape);
|
||||
output += "\n </tbody>\n </table>\n </div>\n </div>\n</div>\n";
|
||||
if(parentTemplate) {
|
||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
||||
} else {
|
||||
cb(null, output);
|
||||
}
|
||||
;
|
||||
} catch (e) {
|
||||
cb(runtime.handleError(e, lineno, colno));
|
||||
}
|
||||
}
|
||||
return {
|
||||
root: root
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/line.html"] = (function() {
|
||||
function root(env, context, frame, runtime, cb) {
|
||||
var lineno = null;
|
||||
var colno = null;
|
||||
var output = "";
|
||||
try {
|
||||
var parentTemplate = null;
|
||||
output += "<tr>\n <td class=\"d2h-code-linenumber ";
|
||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "type"), env.opts.autoescape);
|
||||
output += "\">\n <div class=\"line-num1\">";
|
||||
output += runtime.suppressValue(env.getFilter("safe").call(context, (lineno = 2, colno = 46, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"valueOrEmpty"), "utils[\"valueOrEmp\"]", context, [runtime.contextOrFrameLookup(context, frame, "oldNumber")]))), env.opts.autoescape);
|
||||
output += "</div>\n <div class=\"line-num2\">";
|
||||
output += runtime.suppressValue(env.getFilter("safe").call(context, (lineno = 3, colno = 46, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"valueOrEmpty"), "utils[\"valueOrEmp\"]", context, [runtime.contextOrFrameLookup(context, frame, "newNumber")]))), env.opts.autoescape);
|
||||
output += "</div>\n </td>\n <td class=\"";
|
||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "type"), env.opts.autoescape);
|
||||
output += "\">\n <div class=\"d2h-code-line ";
|
||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "type"), env.opts.autoescape);
|
||||
output += "\">\n";
|
||||
if(runtime.contextOrFrameLookup(context, frame, "prefix")) {
|
||||
output += "\n <span class=\"d2h-code-line-prefix\">";
|
||||
output += runtime.suppressValue(env.getFilter("safe").call(context, (lineno = 8, colno = 83, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"convertWhiteSpaceToNonBreakingSpace"), "utils[\"convertWhi\"]", context, [runtime.contextOrFrameLookup(context, frame, "prefix")]))), env.opts.autoescape);
|
||||
output += "</span>\n";
|
||||
;
|
||||
}
|
||||
output += "\n";
|
||||
if(runtime.contextOrFrameLookup(context, frame, "content")) {
|
||||
output += "\n <span class=\"d2h-code-line-ctn\">";
|
||||
output += runtime.suppressValue(env.getFilter("safe").call(context, (lineno = 11, colno = 80, runtime.callWrap(runtime.memberLookup((runtime.contextOrFrameLookup(context, frame, "utils")),"convertWhiteSpaceToNonBreakingSpace"), "utils[\"convertWhi\"]", context, [runtime.contextOrFrameLookup(context, frame, "content")]))), env.opts.autoescape);
|
||||
output += "</span>\n";
|
||||
;
|
||||
}
|
||||
output += "\n </div>\n </td>\n</tr>\n";
|
||||
if(parentTemplate) {
|
||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
||||
} else {
|
||||
cb(null, output);
|
||||
}
|
||||
;
|
||||
} catch (e) {
|
||||
cb(runtime.handleError(e, lineno, colno));
|
||||
}
|
||||
}
|
||||
return {
|
||||
root: root
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
(function() {(window.nunjucksPrecompiled = window.nunjucksPrecompiled || {})["line-by-line/wrapper.html"] = (function() {
|
||||
function root(env, context, frame, runtime, cb) {
|
||||
var lineno = null;
|
||||
var colno = null;
|
||||
var output = "";
|
||||
try {
|
||||
var parentTemplate = null;
|
||||
output += "<div class=\"d2h-wrapper\">\n ";
|
||||
output += runtime.suppressValue(runtime.contextOrFrameLookup(context, frame, "content"), env.opts.autoescape);
|
||||
output += "\n</div>\n";
|
||||
if(parentTemplate) {
|
||||
parentTemplate.rootRenderFunc(env, context, frame, runtime, cb);
|
||||
} else {
|
||||
cb(null, output);
|
||||
}
|
||||
;
|
||||
} catch (e) {
|
||||
cb(runtime.handleError(e, lineno, colno));
|
||||
}
|
||||
}
|
||||
return {
|
||||
root: root
|
||||
};
|
||||
|
||||
})();
|
||||
})();
|
||||
|
||||
1
dist/templates.min.js
vendored
Normal file
1
dist/templates.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
10
package.json
10
package.json
|
|
@ -43,18 +43,18 @@
|
|||
},
|
||||
"main": "./src/diff2html.js",
|
||||
"dependencies": {
|
||||
"diff": "^2.2.1"
|
||||
"diff": "^2.2.1",
|
||||
"nunjucks": "^2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"codacy-coverage": "^1.1.3",
|
||||
"clean-css": "^3.4.9",
|
||||
"codacy-coverage": "^1.1.3",
|
||||
"fast-html-parser": "^1.0.1",
|
||||
"istanbul": "^0.4.1",
|
||||
"istanbul": "^0.4.2",
|
||||
"jscs": "^2.9.0",
|
||||
"mocha": "^2.4.5",
|
||||
"uglifyjs": "^2.4.10",
|
||||
"webpack": "^1.12.9",
|
||||
"nunjucks": "^2.3.0"
|
||||
"webpack": "^1.12.12"
|
||||
},
|
||||
"license": "MIT",
|
||||
"files": [
|
||||
|
|
|
|||
16
release.sh
16
release.sh
|
|
@ -20,6 +20,10 @@ OUTPUT_JS_UI_FILE=${OUTPUT_DIR}/diff2html-ui.js
|
|||
OUTPUT_MIN_JS_UI_FILE=${OUTPUT_DIR}/diff2html-ui.min.js
|
||||
OUTPUT_CSS_FILE=${OUTPUT_DIR}/diff2html.css
|
||||
OUTPUT_MIN_CSS_FILE=${OUTPUT_DIR}/diff2html.min.css
|
||||
OUTPUT_TEMPLATES_FILE=${OUTPUT_DIR}/templates.js
|
||||
OUTPUT_MIN_TEMPLATES_FILE=${OUTPUT_DIR}/templates.min.js
|
||||
|
||||
TEMPLATES_DIR=src/templates
|
||||
|
||||
echo "Creating diff2html release ..."
|
||||
|
||||
|
|
@ -28,27 +32,27 @@ rm -rf ${OUTPUT_DIR}
|
|||
mkdir -p ${OUTPUT_DIR}
|
||||
|
||||
echo "Generating js aggregation file in ${OUTPUT_JS_FILE}"
|
||||
|
||||
webpack ${INPUT_JS_FILE} ${OUTPUT_JS_FILE}
|
||||
|
||||
echo "Minifying ${OUTPUT_JS_FILE} to ${OUTPUT_MIN_JS_FILE}"
|
||||
|
||||
uglifyjs ${OUTPUT_JS_FILE} -c -o ${OUTPUT_MIN_JS_FILE}
|
||||
|
||||
echo "Generating js ui aggregation file in ${OUTPUT_JS_UI_FILE}"
|
||||
|
||||
webpack ${INPUT_JS_UI_FILE} ${OUTPUT_JS_UI_FILE}
|
||||
|
||||
echo "Minifying ${OUTPUT_JS_UI_FILE} to ${OUTPUT_MIN_JS_UI_FILE}"
|
||||
|
||||
uglifyjs ${OUTPUT_JS_UI_FILE} -c -o ${OUTPUT_MIN_JS_UI_FILE}
|
||||
|
||||
echo "Copying css file to ${OUTPUT_CSS_FILE}"
|
||||
echo "Pre-compile nunjucks templates in ${TEMPLATES_DIR}"
|
||||
nunjucks-precompile ${TEMPLATES_DIR} > ${OUTPUT_TEMPLATES_FILE}
|
||||
|
||||
echo "Minifying ${OUTPUT_TEMPLATES_FILE} to ${OUTPUT_MIN_TEMPLATES_FILE}"
|
||||
uglifyjs ${OUTPUT_TEMPLATES_FILE} -c -o ${OUTPUT_MIN_TEMPLATES_FILE}
|
||||
|
||||
echo "Copying css file to ${OUTPUT_CSS_FILE}"
|
||||
cp -f ${INPUT_CSS_FILE} ${OUTPUT_CSS_FILE}
|
||||
|
||||
echo "Minifying ${OUTPUT_CSS_FILE} to ${OUTPUT_MIN_CSS_FILE}"
|
||||
|
||||
cleancss --advanced --compatibility=ie8 -o ${OUTPUT_MIN_CSS_FILE} ${OUTPUT_CSS_FILE}
|
||||
|
||||
echo "diff2html release created successfully!"
|
||||
|
|
|
|||
|
|
@ -9,15 +9,16 @@
|
|||
Author: rtfpessoa
|
||||
-->
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/styles/github.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/styles/github.min.css">
|
||||
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/languages/scala.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/highlight.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.1.0/languages/scala.min.js"></script>
|
||||
|
||||
<!-- diff2html -->
|
||||
<link rel="stylesheet" type="text/css" href="../dist/diff2html.min.css">
|
||||
<script type="text/javascript" src="../dist/templates.js"></script>
|
||||
<script type="text/javascript" src="../dist/diff2html.js"></script>
|
||||
<script type="text/javascript" src="../dist/diff2html-ui.js"></script>
|
||||
<!-- -->
|
||||
|
|
|
|||
|
|
@ -11,22 +11,20 @@
|
|||
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
||||
var utils = require('./utils.js').Utils;
|
||||
var Rematch = require('./rematch.js').Rematch;
|
||||
var nunjucks = require('nunjucks');
|
||||
var nunjucksEnv = nunjucks.configure(__dirname + '/templates/line-by-line/')
|
||||
.addGlobal('printerUtils', printerUtils)
|
||||
.addGlobal('utils', utils)
|
||||
.addGlobal('diffParser', diffParser);
|
||||
|
||||
var nunjucksUtils = require('./nunjucks-utils.js').NunjucksUtils;
|
||||
var baseTemplatesPath = 'line-by-line';
|
||||
|
||||
function LineByLinePrinter(config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
LineByLinePrinter.prototype.makeFileDiffHtml = function(file, diffs) {
|
||||
return nunjucksEnv.render('file-diff.html', {'file': file, 'diffs': diffs});
|
||||
return nunjucksUtils.render(baseTemplatesPath, 'file-diff.html', {'file': file, 'diffs': diffs});
|
||||
};
|
||||
|
||||
LineByLinePrinter.prototype.makeLineByLineHtmlWrapper = function(content) {
|
||||
return nunjucksEnv.render('wrapper.html', {'content': content});
|
||||
return nunjucksUtils.render(baseTemplatesPath, 'wrapper.html', {'content': content});
|
||||
};
|
||||
|
||||
LineByLinePrinter.prototype.generateLineByLineJsonHtml = function(diffFiles) {
|
||||
|
|
@ -52,7 +50,7 @@
|
|||
});
|
||||
|
||||
LineByLinePrinter.prototype.makeColumnLineNumberHtml = function(block) {
|
||||
return nunjucksEnv.render('column-line-number.html', {block: block});
|
||||
return nunjucksUtils.render(baseTemplatesPath, 'column-line-number.html', {block: block});
|
||||
};
|
||||
|
||||
LineByLinePrinter.prototype._generateFileHtml = function(file) {
|
||||
|
|
@ -161,16 +159,18 @@
|
|||
};
|
||||
|
||||
LineByLinePrinter.prototype.makeLineHtml = function(type, oldNumber, newNumber, content, prefix) {
|
||||
return nunjucksEnv.render('line.html',
|
||||
{type: type,
|
||||
return nunjucksUtils.render(baseTemplatesPath, 'line.html',
|
||||
{
|
||||
type: type,
|
||||
oldNumber: oldNumber,
|
||||
newNumber: newNumber,
|
||||
prefix: prefix,
|
||||
content: content});
|
||||
content: content
|
||||
});
|
||||
};
|
||||
|
||||
LineByLinePrinter.prototype._generateEmptyDiff = function() {
|
||||
return nunjucksEnv.render('empty-diff.html', {});
|
||||
return nunjucksUtils.render(baseTemplatesPath, 'empty-diff.html', {});
|
||||
};
|
||||
|
||||
module.exports.LineByLinePrinter = LineByLinePrinter;
|
||||
|
|
|
|||
34
src/nunjucks-utils.js
Normal file
34
src/nunjucks-utils.js
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
*
|
||||
* Utils (utils.js)
|
||||
* Author: rtfpessoa
|
||||
*
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
var path = require('path');
|
||||
|
||||
var nunjucks = require('nunjucks');
|
||||
var templatesPath = path.resolve(__dirname, 'templates');
|
||||
|
||||
var diffParser = require('./diff-parser.js').DiffParser;
|
||||
var printerUtils = require('./printer-utils.js').PrinterUtils;
|
||||
var utils = require('./utils.js').Utils;
|
||||
|
||||
var nunjucksEnv = nunjucks.configure(templatesPath, {"autoescape": false})
|
||||
.addGlobal('printerUtils', printerUtils)
|
||||
.addGlobal('utils', utils)
|
||||
.addGlobal('diffParser', diffParser);
|
||||
|
||||
function NunjucksUtils() {
|
||||
}
|
||||
|
||||
NunjucksUtils.prototype.render = function(namespace, view, params) {
|
||||
var viewPath = path.join(namespace, view);
|
||||
return nunjucksEnv.render(viewPath, params);
|
||||
};
|
||||
|
||||
module.exports.NunjucksUtils = new NunjucksUtils();
|
||||
|
||||
})();
|
||||
|
|
@ -5,6 +5,16 @@ module.exports = {
|
|||
|
||||
plugins: [
|
||||
|
||||
new webpack.NormalModuleReplacementPlugin(
|
||||
/(nunjucks)$/,
|
||||
'nunjucks/index'
|
||||
),
|
||||
|
||||
new webpack.NormalModuleReplacementPlugin(
|
||||
/(precompile|nodes|lexer|parser|transformer|compiler|loaders)$/,
|
||||
'node-libs-browser/mock/empty'
|
||||
),
|
||||
|
||||
new webpack.DefinePlugin({
|
||||
'process.env': {
|
||||
IS_BROWSER: true
|
||||
|
|
|
|||
Loading…
Reference in a new issue