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
* 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;
}
#wrapper {
#d2h-wrapper {
display: inline-block;
margin-top: 1em;
text-align: left;
width: 920px;
}
.file-wrapper {
.d2h-file-wrapper {
border: 1px solid #ddd;
border-radius: 3px;
margin-bottom: 1em;
}
.file-header {
.d2h-file-header {
padding: 5px 10px;
text-shadow: 0 1px 0 #fff;
border-bottom: 1px solid #d8d8d8;
background-color: #f7f7f7;
border-top-left-radius: 4px;
border-top-right-radius: 4px;
box-sizing: border-box;
}
.file-name {
display: inline-block;
font: 13px Helvetica, arial, freesans, clean, sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
height: 33px;
line-height: 33px;
}
.file-stats {
.d2h-file-stats {
display: inline-block;
font-family: monospace, monospace;
font-size: 12px;
vertical-align: middle;
}
.lines-added {
.d2h-lines-added {
background-color: #ceffce;
border: 1px solid #b4e2b4;
color: #399839;
@ -56,7 +43,7 @@ body {
padding: 5px;
}
.lines-deleted {
.d2h-lines-deleted {
background-color: #f7c8c8;
border: 1px solid #e9aeae;
color: #c33;
@ -64,111 +51,42 @@ body {
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;
}
.file-diff > div {
.d2h-file-diff > div {
width: 100%;
}
pre {
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 {
.d2h-code-wrapper {
overflow-x: auto;
overflow-y: hidden;
border-bottom-left-radius: 3px;
border-bottom-right-radius: 3px;
}
.diff-table {
border-collapse: separate;
}
table {
.d2h-diff-table {
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-size: 12px;
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 {
position: relative;
.d2h-code-line {
overflow: scroll;
white-space: pre;
padding-left: 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 {
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 {
.d2h-code-line del {
display: inline-block;
margin-top: -1px;
text-decoration: none;
@ -176,10 +94,42 @@ pre {
font-weight: 700;
}
.code-line ins {
.d2h-code-line ins {
display: inline-block;
margin-top: -1px;
text-decoration: none;
background-color: #97f295;
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)
* Author: rtfpessoa
* Date: Friday 29 August 2014
* Last Update: Saturday 30 August 2014
* Last Update: Friday 6 September 2014
*
* Diff command:
* git diff --word-diff-regex=. HEAD~1
@ -15,10 +15,10 @@
ClassVariable = (function () {
var CSS_STYLES = {
INFO: "info",
CONTEXT: "context",
NEW: "insert",
DELETED: "delete"
INFO: "d2h-info",
CONTEXT: "d2h-context",
NEW: "d2h-insert",
DELETED: "d2h-delete"
};
var BLOCK_HEADER_LINE = "...";
@ -189,20 +189,20 @@
};
var generateJsonHtml = function (diffFiles) {
return "<div id=\"wrapper\">\n" +
return "<div id=\"d2h-wrapper\">\n" +
diffFiles.map(function (file) {
return "<div class=\"file-wrapper\">\n" +
" <div class=\"file-header\">\n" +
" <div class=\"file-stats\">\n" +
" <span class=\"lines-added\">+" + file.addedLines + "</span>\n" +
" <span class=\"lines-deleted\">-" + file.deletedLines + "</span>\n" +
return "<div class=\"d2h-file-wrapper\">\n" +
" <div class=\"d2h-file-header\">\n" +
" <div class=\"d2h-file-stats\">\n" +
" <span class=\"d2h-lines-added\">+" + file.addedLines + "</span>\n" +
" <span class=\"d2h-lines-deleted\">-" + file.deletedLines + "</span>\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 class=\"file-diff\">\n" +
" <div class=\"code-wrapper\">\n" +
" <table class=\"diff-table\">\n" +
" <tbody>\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" +
" " + generateFileHtml(file) +
" </tbody>\n" +
" </table>\n" +
@ -233,9 +233,9 @@
}
return "<tr>\n" +
" <td class=\"code-linenumber " + line.type + "\">" + oldLine + "</td>\n" +
" <td class=\"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-linenumber " + line.type + "\">" + oldLine + "</td>\n" +
" <td class=\"d2h-code-linenumber " + line.type + "\">" + newLine + "</td>\n" +
" <td class=\"d2h-code-line " + line.type + "\"><div class=\"" + line.type + "\">" + escapedLine + "</pre></td>\n" +
"</tr>\n";
}).join("\n");
}).join("\n");

View file

@ -8,10 +8,10 @@
Diff to HTML (template.html)
Author: rtfpessoa
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>