tag CSS classes to avoid naming conflicts

This commit is contained in:
Rodrigo Fernandes 2014-09-06 02:39:36 +01:00
parent 05dbc0ec30
commit 7688c9e08f
3 changed files with 78 additions and 128 deletions

View file

@ -1,9 +1,9 @@
/* /*
* *
* Diff to HTML (style.css) * Diff to HTML (diff2html.css)
* Author: rtfpessoa * Author: rtfpessoa
* Date: Friday 29 August 2014 * Date: Friday 29 August 2014
* Last Update: Saturday 30 August 2014 * Last Update: Friday 6 September 2014
* *
*/ */
@ -11,44 +11,31 @@ body {
text-align: center; text-align: center;
} }
#wrapper { #d2h-wrapper {
display: inline-block; display: inline-block;
margin-top: 1em;
text-align: left; text-align: left;
width: 920px; width: 920px;
} }
.file-wrapper { .d2h-file-wrapper {
border: 1px solid #ddd; border: 1px solid #ddd;
border-radius: 3px; border-radius: 3px;
margin-bottom: 1em; margin-bottom: 1em;
} }
.file-header { .d2h-file-header {
padding: 5px 10px; padding: 5px 10px;
text-shadow: 0 1px 0 #fff;
border-bottom: 1px solid #d8d8d8; border-bottom: 1px solid #d8d8d8;
background-color: #f7f7f7; background-color: #f7f7f7;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
box-sizing: border-box;
} }
.file-name { .d2h-file-stats {
display: inline-block;
font: 13px Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
height: 33px;
line-height: 33px;
}
.file-stats {
display: inline-block; display: inline-block;
font-family: monospace, monospace; font-family: monospace, monospace;
font-size: 12px; font-size: 12px;
vertical-align: middle;
} }
.lines-added { .d2h-lines-added {
background-color: #ceffce; background-color: #ceffce;
border: 1px solid #b4e2b4; border: 1px solid #b4e2b4;
color: #399839; color: #399839;
@ -56,7 +43,7 @@ body {
padding: 5px; padding: 5px;
} }
.lines-deleted { .d2h-lines-deleted {
background-color: #f7c8c8; background-color: #f7c8c8;
border: 1px solid #e9aeae; border: 1px solid #e9aeae;
color: #c33; color: #c33;
@ -64,111 +51,42 @@ body {
padding: 5px; padding: 5px;
} }
.file-diff { .d2h-file-name {
display: inline-block;
font: 13px Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
height: 33px;
line-height: 33px;
}
.d2h-file-diff {
overflow: auto; overflow: auto;
} }
.file-diff > div { .d2h-file-diff > div {
width: 100%; width: 100%;
} }
pre { .d2h-code-wrapper {
margin: 0;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 12px;
line-height: 18px;
text-indent: 5px;
color: #333;
border: solid #eeeeee;
border-width: 0 1px 0 0;
cursor: pointer;
}
.code-wrapper {
overflow-x: auto; overflow-x: auto;
overflow-y: hidden; overflow-y: hidden;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
} }
.diff-table { .d2h-diff-table {
border-collapse: separate;
}
table {
border-collapse: collapse; border-collapse: collapse;
border-spacing: 0;
}
tbody {
display: table-row-group;
vertical-align: middle;
border-color: inherit;
}
tr {
display: table-row;
vertical-align: inherit;
border-color: inherit;
}
td, th {
padding: 0;
}
pre {
text-indent: 0;
border: none;
}
.code-linenumber {
width: 1%;
min-width: 25px;
padding-left: 10px;
padding-right: 10px;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace; font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 12px; font-size: 12px;
height: 18px;
line-height: 18px; line-height: 18px;
color: rgba(0, 0, 0, 0.3);
vertical-align: top;
text-align: right;
border: solid #eeeeee;
border-width: 0 1px 0 0;
cursor: pointer;
} }
.code-line { .d2h-code-line {
position: relative; overflow: scroll;
white-space: pre;
padding-left: 10px; padding-left: 10px;
padding-right: 10px; padding-right: 10px;
font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
font-size: 12px;
color: #333;
vertical-align: top;
white-space: pre;
overflow: visible;
} }
.delete { .d2h-code-line del {
vertical-align: middle;
background-color: #f7c8c8;
border-color: #e9aeae;
}
.insert {
vertical-align: middle;
background-color: #ceffce;
border-color: #b4e2b4;
}
.info {
background-color: #f8fafd;
vertical-align: middle;
color: rgba(0, 0, 0, 0.3);
border-color: #d5e4f2;
}
.code-line del {
display: inline-block; display: inline-block;
margin-top: -1px; margin-top: -1px;
text-decoration: none; text-decoration: none;
@ -176,10 +94,42 @@ pre {
font-weight: 700; font-weight: 700;
} }
.code-line ins { .d2h-code-line ins {
display: inline-block; display: inline-block;
margin-top: -1px; margin-top: -1px;
text-decoration: none; text-decoration: none;
background-color: #97f295; background-color: #97f295;
font-weight: 700; font-weight: 700;
} }
.d2h-code-linenumber {
width: 1%;
min-width: 25px;
padding-left: 10px;
padding-right: 10px;
color: rgba(0, 0, 0, 0.3);
text-align: right;
border: solid #eeeeee;
border-width: 0 1px 0 0;
cursor: pointer;
}
.d2h-delete {
vertical-align: middle;
background-color: #f7c8c8;
border-color: #e9aeae;
}
.d2h-insert {
vertical-align: middle;
background-color: #ceffce;
border-color: #b4e2b4;
}
.d2h-info {
background-color: #f8fafd;
vertical-align: middle;
color: rgba(0, 0, 0, 0.3);
border-color: #d5e4f2;
}

View file

@ -3,7 +3,7 @@
* Diff to HTML (diff2html.js) * Diff to HTML (diff2html.js)
* Author: rtfpessoa * Author: rtfpessoa
* Date: Friday 29 August 2014 * Date: Friday 29 August 2014
* Last Update: Saturday 30 August 2014 * Last Update: Friday 6 September 2014
* *
* Diff command: * Diff command:
* git diff --word-diff-regex=. HEAD~1 * git diff --word-diff-regex=. HEAD~1
@ -15,10 +15,10 @@
ClassVariable = (function () { ClassVariable = (function () {
var CSS_STYLES = { var CSS_STYLES = {
INFO: "info", INFO: "d2h-info",
CONTEXT: "context", CONTEXT: "d2h-context",
NEW: "insert", NEW: "d2h-insert",
DELETED: "delete" DELETED: "d2h-delete"
}; };
var BLOCK_HEADER_LINE = "..."; var BLOCK_HEADER_LINE = "...";
@ -189,20 +189,20 @@
}; };
var generateJsonHtml = function (diffFiles) { var generateJsonHtml = function (diffFiles) {
return "<div id=\"wrapper\">\n" + return "<div id=\"d2h-wrapper\">\n" +
diffFiles.map(function (file) { diffFiles.map(function (file) {
return "<div class=\"file-wrapper\">\n" + return "<div class=\"d2h-file-wrapper\">\n" +
" <div class=\"file-header\">\n" + " <div class=\"d2h-file-header\">\n" +
" <div class=\"file-stats\">\n" + " <div class=\"d2h-file-stats\">\n" +
" <span class=\"lines-added\">+" + file.addedLines + "</span>\n" + " <span class=\"d2h-lines-added\">+" + file.addedLines + "</span>\n" +
" <span class=\"lines-deleted\">-" + file.deletedLines + "</span>\n" + " <span class=\"d2h-lines-deleted\">-" + file.deletedLines + "</span>\n" +
" </div>\n" + " </div>\n" +
" <div class=\"file-name\">" + getDiffName(file.oldName, file.newName) + "</div>\n" + " <div class=\"d2h-file-name\">" + getDiffName(file.oldName, file.newName) + "</div>\n" +
" </div>\n" + " </div>\n" +
" <div class=\"file-diff\">\n" + " <div class=\"d2h-file-diff\">\n" +
" <div class=\"code-wrapper\">\n" + " <div class=\"d2h-code-wrapper\">\n" +
" <table class=\"diff-table\">\n" + " <table class=\"d2h-diff-table\">\n" +
" <tbody>\n" + " <tbody class=\"d2h-diff-tbody\">\n" +
" " + generateFileHtml(file) + " " + generateFileHtml(file) +
" </tbody>\n" + " </tbody>\n" +
" </table>\n" + " </table>\n" +
@ -233,9 +233,9 @@
} }
return "<tr>\n" + return "<tr>\n" +
" <td class=\"code-linenumber " + line.type + "\">" + oldLine + "</td>\n" + " <td class=\"d2h-code-linenumber " + line.type + "\">" + oldLine + "</td>\n" +
" <td class=\"code-linenumber " + line.type + "\">" + newLine + "</td>\n" + " <td class=\"d2h-code-linenumber " + line.type + "\">" + newLine + "</td>\n" +
" <td class=\"code-line " + line.type + "\"><pre class=\"" + line.type + "\">" + escapedLine + "</pre></td>\n" + " <td class=\"d2h-code-line " + line.type + "\"><div class=\"" + line.type + "\">" + escapedLine + "</pre></td>\n" +
"</tr>\n"; "</tr>\n";
}).join("\n"); }).join("\n");
}).join("\n"); }).join("\n");

View file

@ -8,10 +8,10 @@
Diff to HTML (template.html) Diff to HTML (template.html)
Author: rtfpessoa Author: rtfpessoa
Date: Friday 29 August 2014 Date: Friday 29 August 2014
Last Update: Saturday 30 August 2014 Last Update: Friday 6 September 2014
--> -->
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="diff2html.css">
<script type="text/javascript" src="diff2html.js"></script> <script type="text/javascript" src="diff2html.js"></script>
<script> <script>