diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 3c3629e..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules diff --git a/README.md b/README.md deleted file mode 100644 index 185fe75..0000000 --- a/README.md +++ /dev/null @@ -1,36 +0,0 @@ -# ![Diff Parser for Node](http://agate.github.com/node-diff-parser/images/logo.svg) - -## Installation - -via npm: - -```bash -$ npm install diff-parser # use -g if you want to use diff2html -``` - -## Usage - -### Command Line - -```bash -$ git diff [file|dir] > filename.diff -$ diff2html path/to/filename.diff > filename.html -``` - -### Node - -```javascript -var diffParser = require("diff-parser"); -var diffFiles = diffParser.parse(diffString); -console.log(diffFiles); // here have all info you need. -``` - -## TODO - -* Right now it only support git diff. So the next improvement should be - support more type of diffs. -* Let user customize their styles for the diff html page. - -## License - -MIT diff --git a/bin/diff2html b/bin/diff2html deleted file mode 100755 index 5f9f5e3..0000000 --- a/bin/diff2html +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/env node - -require('coffee-script'); - -var fs = require('fs'); -var jade = require('jade'); -var parser = require(__dirname + '/../lib/diff_parser'); - -var diffFile = process.argv[2]; -var diffStr = fs.readFileSync(diffFile).toString(); -var parsedFiles = parser.parse(diffStr); - -var html = jade.renderFile(__dirname + '/../templates/simple.jade', { - parsedFiles: parsedFiles -}); - -console.log(html); diff --git a/images/checker.png b/images/checker.png new file mode 100644 index 0000000..ab14540 Binary files /dev/null and b/images/checker.png differ diff --git a/images/logo.svg b/images/logo.svg new file mode 100644 index 0000000..345613b --- /dev/null +++ b/images/logo.svg @@ -0,0 +1,10 @@ + + + +Layer 1 + + +PARSER + + + diff --git a/index.html b/index.html new file mode 100644 index 0000000..c7d9ece --- /dev/null +++ b/index.html @@ -0,0 +1,80 @@ + + + + + + node-diff-parser by agate + + + + + + + + + +
+
+

node-diff-parser

+

Node DIff Parser

+

View the Project on GitHub agate/node-diff-parser

+ +
+
+

+Diff Parser for Node +

+ +

+Installation

+ +

via npm:

+ +
$ npm install diff-parser # use -g if you want to use diff2html
+
+ +

+Usage

+ +

+Command Line

+ +
$ git diff [file|dir] > filename.diff
+$ diff2html path/to/filename.diff > filename.html
+
+ +

+Node

+ +
var diffParser = require("diff-parser");
+var diffFiles = diffParser.parse(diffString);
+console.log(diffFiles); // here have all info you need.
+
+ +

+TODO

+ +

+License

+ +

MIT

+
+
+ + + + + \ No newline at end of file diff --git a/index.js b/index.js deleted file mode 100644 index 0ce7d93..0000000 --- a/index.js +++ /dev/null @@ -1,2 +0,0 @@ -require('coffee-script'); -module.exports = require('./lib/diff_parser'); diff --git a/javascripts/scale.fix.js b/javascripts/scale.fix.js new file mode 100644 index 0000000..08716c0 --- /dev/null +++ b/javascripts/scale.fix.js @@ -0,0 +1,20 @@ +fixScale = function(doc) { + + var addEvent = 'addEventListener', + type = 'gesturestart', + qsa = 'querySelectorAll', + scales = [1, 1], + meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : []; + + function fix() { + meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1]; + doc.removeEventListener(type, fix, true); + } + + if ((meta = meta[meta.length - 1]) && addEvent in doc) { + fix(); + scales = [.25, 1.6]; + doc[addEvent](type, fix, true); + } + +}; \ No newline at end of file diff --git a/lib/diff_file.coffee b/lib/diff_file.coffee deleted file mode 100644 index 7fc3177..0000000 --- a/lib/diff_file.coffee +++ /dev/null @@ -1,32 +0,0 @@ -module.exports = class DiffFile - constructor: (firstLine) -> - temp = firstLine.replace(/diff --git a/, 'b') - temp = temp.slice(0, (temp.length - 1) / 2) - @name = temp.replace(/^b\//, '') - @lines = [] - - setIndex: (indexLine) -> - match = indexLine.match(/^index\s+([^. ]+)\.\.([^. ]+)/) - @from = match[1] - @to = match[2] - - finishHeaderParse: -> - @headerParsed = true - - appendLine: (line) -> - @lines.push(line) - - if line.type == 'chunk' - match = line.content.match(/^@@\s+\-([^\s]+)\s+\+([^\s]+)/) - @deletionLineNum = match[1].split(',')[0] - @additionLineNum = match[2].split(',')[0] - - else if line.type == 'normal' - line.deletionLineNum = @deletionLineNum++ - line.additionLineNum = @additionLineNum++ - - else if line.type == 'deletion' - line.deletionLineNum = @deletionLineNum++ - - else if line.type == 'addition' - line.additionLineNum = @additionLineNum++ diff --git a/lib/diff_parser.coffee b/lib/diff_parser.coffee deleted file mode 100644 index 343dfb9..0000000 --- a/lib/diff_parser.coffee +++ /dev/null @@ -1,35 +0,0 @@ -DiffFile = require('./diff_file') - -module.exports.parse = (diffStr) -> - files = [] - currentFile = null - - lines = diffStr.split("\n") - lines.pop(); - lines.forEach (line) -> - if line.match(/^diff/) - currentFile = new DiffFile(line) - files.push(currentFile) - else - unless currentFile.headerParsed - currentFile.setIndex(line) if line.match(/^index/) - currentFile.finishHeaderParse() if line.match(/^\+\+\+/) - else - if line.match(/^@@/) - currentFile.appendLine - content: line - type: 'chunk' - else if line.match(/^-/) - currentFile.appendLine - content: line - type: 'deletion' - else if line.match(/^\+/) - currentFile.appendLine - content: line - type: 'addition' - else - currentFile.appendLine - content: line - type: 'normal' - - return files diff --git a/package.json b/package.json deleted file mode 100644 index 5810f78..0000000 --- a/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "diff-parser", - "description": "Diff Parser", - "author": "Hao Hong ", - "version": "0.0.1", - "keywords": [ "diff", "parser", "render" ], - "licenses": [ { "type": "MIT" } ], - "engines": { "node": ">=0.10.0" }, - "dependencies": { - "jade": ">=0.34.1", - "coffee-script": ">=1.6.3" - }, - "bin": { "diff2html": "./bin/diff2html" }, - "repository": { - "type": "git", - "url": "git://github.com/agate/node-diff-parser.git" - } -} diff --git a/params.json b/params.json new file mode 100644 index 0000000..b829eaf --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"name":"node-diff-parser","tagline":"Node DIff Parser","body":"# ![Diff Parser for Node](http://agate.github.com/node-diff-parser/images/logo.svg)\r\n\r\n## Installation\r\n\r\nvia npm:\r\n\r\n```bash\r\n$ npm install diff-parser # use -g if you want to use diff2html\r\n```\r\n\r\n## Usage\r\n\r\n### Command Line\r\n\r\n```bash\r\n$ git diff [file|dir] > filename.diff\r\n$ diff2html path/to/filename.diff > filename.html\r\n```\r\n\r\n### Node\r\n\r\n```javascript\r\nvar diffParser = require(\"diff-parser\");\r\nvar diffFiles = diffParser.parse(diffString);\r\nconsole.log(diffFiles); // here have all info you need.\r\n```\r\n\r\n## TODO\r\n\r\n* Right now it only support git diff. So the next improvement should be\r\n support more type of diffs.\r\n* Let user customize their styles for the diff html page.\r\n\r\n## License\r\n\r\nMIT\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/stylesheets/pygment_trac.css b/stylesheets/pygment_trac.css new file mode 100644 index 0000000..1926cfd --- /dev/null +++ b/stylesheets/pygment_trac.css @@ -0,0 +1,60 @@ +.highlight .hll { background-color: #49483e } +.highlight { background: #3A3C42; color: #f8f8f2 } +.highlight .c { color: #75715e } /* Comment */ +.highlight .err { color: #960050; background-color: #1e0010 } /* Error */ +.highlight .k { color: #66d9ef } /* Keyword */ +.highlight .l { color: #ae81ff } /* Literal */ +.highlight .n { color: #f8f8f2 } /* Name */ +.highlight .o { color: #f92672 } /* Operator */ +.highlight .p { color: #f8f8f2 } /* Punctuation */ +.highlight .cm { color: #75715e } /* Comment.Multiline */ +.highlight .cp { color: #75715e } /* Comment.Preproc */ +.highlight .c1 { color: #75715e } /* Comment.Single */ +.highlight .cs { color: #75715e } /* Comment.Special */ +.highlight .ge { font-style: italic } /* Generic.Emph */ +.highlight .gs { font-weight: bold } /* Generic.Strong */ +.highlight .kc { color: #66d9ef } /* Keyword.Constant */ +.highlight .kd { color: #66d9ef } /* Keyword.Declaration */ +.highlight .kn { color: #f92672 } /* Keyword.Namespace */ +.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */ +.highlight .kr { color: #66d9ef } /* Keyword.Reserved */ +.highlight .kt { color: #66d9ef } /* Keyword.Type */ +.highlight .ld { color: #e6db74 } /* Literal.Date */ +.highlight .m { color: #ae81ff } /* Literal.Number */ +.highlight .s { color: #e6db74 } /* Literal.String */ +.highlight .na { color: #a6e22e } /* Name.Attribute */ +.highlight .nb { color: #f8f8f2 } /* Name.Builtin */ +.highlight .nc { color: #a6e22e } /* Name.Class */ +.highlight .no { color: #66d9ef } /* Name.Constant */ +.highlight .nd { color: #a6e22e } /* Name.Decorator */ +.highlight .ni { color: #f8f8f2 } /* Name.Entity */ +.highlight .ne { color: #a6e22e } /* Name.Exception */ +.highlight .nf { color: #a6e22e } /* Name.Function */ +.highlight .nl { color: #f8f8f2 } /* Name.Label */ +.highlight .nn { color: #f8f8f2 } /* Name.Namespace */ +.highlight .nx { color: #a6e22e } /* Name.Other */ +.highlight .py { color: #f8f8f2 } /* Name.Property */ +.highlight .nt { color: #f92672 } /* Name.Tag */ +.highlight .nv { color: #f8f8f2 } /* Name.Variable */ +.highlight .ow { color: #f92672 } /* Operator.Word */ +.highlight .w { color: #f8f8f2 } /* Text.Whitespace */ +.highlight .mf { color: #ae81ff } /* Literal.Number.Float */ +.highlight .mh { color: #ae81ff } /* Literal.Number.Hex */ +.highlight .mi { color: #ae81ff } /* Literal.Number.Integer */ +.highlight .mo { color: #ae81ff } /* Literal.Number.Oct */ +.highlight .sb { color: #e6db74 } /* Literal.String.Backtick */ +.highlight .sc { color: #e6db74 } /* Literal.String.Char */ +.highlight .sd { color: #e6db74 } /* Literal.String.Doc */ +.highlight .s2 { color: #e6db74 } /* Literal.String.Double */ +.highlight .se { color: #ae81ff } /* Literal.String.Escape */ +.highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */ +.highlight .si { color: #e6db74 } /* Literal.String.Interpol */ +.highlight .sx { color: #e6db74 } /* Literal.String.Other */ +.highlight .sr { color: #e6db74 } /* Literal.String.Regex */ +.highlight .s1 { color: #e6db74 } /* Literal.String.Single */ +.highlight .ss { color: #e6db74 } /* Literal.String.Symbol */ +.highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */ +.highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */ +.highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */ +.highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */ +.highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */ \ No newline at end of file diff --git a/stylesheets/styles.css b/stylesheets/styles.css new file mode 100644 index 0000000..466b9d6 --- /dev/null +++ b/stylesheets/styles.css @@ -0,0 +1,356 @@ +@import url(https://fonts.googleapis.com/css?family=Lato:300italic,700italic,300,700); +html { + background: #6C7989; + background: #6c7989 -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #6c7989), color-stop(100%, #434b55)) fixed; + background: #6c7989 -webkit-linear-gradient(#6c7989, #434b55) fixed; + background: #6c7989 -moz-linear-gradient(#6c7989, #434b55) fixed; + background: #6c7989 -o-linear-gradient(#6c7989, #434b55) fixed; + background: #6c7989 -ms-linear-gradient(#6c7989, #434b55) fixed; + background: #6c7989 linear-gradient(#6c7989, #434b55) fixed; +} + +body { + padding: 50px 0; + margin: 0; + font: 14px/1.5 Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; + color: #555; + font-weight: 300; + background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAeCAYAAABNChwpAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNXG14zYAAAAUdEVYdENyZWF0aW9uIFRpbWUAMy82LzEygrTcTAAAAFRJREFUSIljfPDggZRf5RIGGNjUHsNATz6jXmSL1Kb2GLiAX+USBnrymRgGGDCORgFmoNAXjEbBaBSMRsFoFIxGwWgUjEbBaBSMRsFoFIxGwWgUAABYNujumib3wAAAAABJRU5ErkJggg==') fixed; +} + +.wrapper { + width: 640px; + margin: 0 auto; + background: #DEDEDE; + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + -ms-border-radius: 8px; + -o-border-radius: 8px; + border-radius: 8px; + -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 0, 0, 0.45) 0 3px 10px; + -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 0, 0, 0.45) 0 3px 10px; + box-shadow: rgba(0, 0, 0, 0.2) 0 0 0 1px, rgba(0, 0, 0, 0.45) 0 3px 10px; +} + +header, section, footer { + display: block; +} + +a { + color: #069; + text-decoration: none; +} + +p { + margin: 0 0 20px; + padding: 0; +} + +strong { + color: #222; + font-weight: 700; +} + +header { + -webkit-border-radius: 8px 8px 0 0; + -moz-border-radius: 8px 8px 0 0; + -ms-border-radius: 8px 8px 0 0; + -o-border-radius: 8px 8px 0 0; + border-radius: 8px 8px 0 0; + background: #C6EAFA; + background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #ddfbfc), color-stop(100%, #c6eafa)); + background: -webkit-linear-gradient(#ddfbfc, #c6eafa); + background: -moz-linear-gradient(#ddfbfc, #c6eafa); + background: -o-linear-gradient(#ddfbfc, #c6eafa); + background: -ms-linear-gradient(#ddfbfc, #c6eafa); + background: linear-gradient(#ddfbfc, #c6eafa); + position: relative; + padding: 15px 20px; + border-bottom: 1px solid #B2D2E1; +} +header h1 { + margin: 0; + padding: 0; + font-size: 24px; + line-height: 1.2; + color: #069; + text-shadow: rgba(255, 255, 255, 0.9) 0 1px 0; +} +header.without-description h1 { + margin: 10px 0; +} +header p { + margin: 0; + color: #61778B; + width: 300px; + font-size: 13px; +} +header p.view { + display: none; + font-weight: 700; + text-shadow: rgba(255, 255, 255, 0.9) 0 1px 0; + -webkit-font-smoothing: antialiased; +} +header p.view a { + color: #06c; +} +header p.view small { + font-weight: 400; +} +header ul { + margin: 0; + padding: 0; + list-style: none; + position: absolute; + z-index: 1; + right: 20px; + top: 20px; + height: 38px; + padding: 1px 0; + background: #5198DF; + background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #77b9fb), color-stop(100%, #3782cd)); + background: -webkit-linear-gradient(#77b9fb, #3782cd); + background: -moz-linear-gradient(#77b9fb, #3782cd); + background: -o-linear-gradient(#77b9fb, #3782cd); + background: -ms-linear-gradient(#77b9fb, #3782cd); + background: linear-gradient(#77b9fb, #3782cd); + border-radius: 5px; + -webkit-box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0; + -moz-box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0; + box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0; + width: auto; +} +header ul:before { + content: ''; + position: absolute; + z-index: -1; + left: -5px; + top: -4px; + right: -5px; + bottom: -6px; + background: rgba(0, 0, 0, 0.1); + -webkit-border-radius: 8px; + -moz-border-radius: 8px; + -ms-border-radius: 8px; + -o-border-radius: 8px; + border-radius: 8px; + -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0; + -moz-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0; + box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0; +} +header ul li { + width: 79px; + float: left; + border-right: 1px solid #3A7CBE; + height: 38px; +} +header ul li.single { + border: none; +} +header ul li + li { + width: 78px; + border-left: 1px solid #8BBEF3; +} +header ul li + li + li { + border-right: none; + width: 79px; +} +header ul a { + line-height: 1; + font-size: 11px; + color: #fff; + color: rgba(255, 255, 255, 0.8); + display: block; + text-align: center; + font-weight: 400; + padding-top: 6px; + height: 40px; + text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 0; +} +header ul a strong { + font-size: 14px; + display: block; + color: #fff; + -webkit-font-smoothing: antialiased; +} + +section { + padding: 15px 20px; + font-size: 15px; + border-top: 1px solid #fff; + background: -webkit-gradient(linear, 50% 0%, 50% 700, color-stop(0%, #fafafa), color-stop(100%, #dedede)); + background: -webkit-linear-gradient(#fafafa, #dedede 700px); + background: -moz-linear-gradient(#fafafa, #dedede 700px); + background: -o-linear-gradient(#fafafa, #dedede 700px); + background: -ms-linear-gradient(#fafafa, #dedede 700px); + background: linear-gradient(#fafafa, #dedede 700px); + -webkit-border-radius: 0 0 8px 8px; + -moz-border-radius: 0 0 8px 8px; + -ms-border-radius: 0 0 8px 8px; + -o-border-radius: 0 0 8px 8px; + border-radius: 0 0 8px 8px; + position: relative; +} + +h1, h2, h3, h4, h5, h6 { + color: #222; + padding: 0; + margin: 0 0 20px; + line-height: 1.2; +} + +p, ul, ol, table, pre, dl { + margin: 0 0 20px; +} + +h1, h2, h3 { + line-height: 1.1; +} + +h1 { + font-size: 28px; +} + +h2 { + color: #393939; +} + +h3, h4, h5, h6 { + color: #494949; +} + +blockquote { + margin: 0 -20px 20px; + padding: 15px 20px 1px 40px; + font-style: italic; + background: #ccc; + background: rgba(0, 0, 0, 0.06); + color: #222; +} + +img { + max-width: 100%; +} + +code, pre { + font-family: Monaco, Bitstream Vera Sans Mono, Lucida Console, Terminal; + color: #333; + font-size: 12px; + overflow-x: auto; +} + +pre { + padding: 20px; + background: #3A3C42; + color: #f8f8f2; + margin: 0 -20px 20px; +} +pre code { + color: #f8f8f2; +} +li pre { + margin-left: -60px; + padding-left: 60px; +} + +table { + width: 100%; + border-collapse: collapse; +} + +th, td { + text-align: left; + padding: 5px 10px; + border-bottom: 1px solid #aaa; +} + +dt { + color: #222; + font-weight: 700; +} + +th { + color: #222; +} + +small { + font-size: 11px; +} + +hr { + border: 0; + background: #aaa; + height: 1px; + margin: 0 0 20px; +} + +footer { + width: 640px; + margin: 0 auto; + padding: 20px 0 0; + color: #ccc; + overflow: hidden; +} +footer a { + color: #fff; + font-weight: bold; +} +footer p { + float: left; +} +footer p + p { + float: right; +} + +@media print, screen and (max-width: 740px) { + body { + padding: 0; + } + + .wrapper { + -webkit-border-radius: 0; + -moz-border-radius: 0; + -ms-border-radius: 0; + -o-border-radius: 0; + border-radius: 0; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + width: 100%; + } + + footer { + -webkit-border-radius: 0; + -moz-border-radius: 0; + -ms-border-radius: 0; + -o-border-radius: 0; + border-radius: 0; + padding: 20px; + width: auto; + } + footer p { + float: none; + margin: 0; + } + footer p + p { + float: none; + } +} +@media print, screen and (max-width:580px) { + header ul { + display: none; + } + + header p.view { + display: block; + } + + header p { + width: 100%; + } +} +@media print { + header p.view a small:before { + content: 'at http://github.com/'; + } +} diff --git a/templates/simple.jade b/templates/simple.jade deleted file mode 100644 index 085702b..0000000 --- a/templates/simple.jade +++ /dev/null @@ -1,49 +0,0 @@ -doctype 5 -html(lang="en") - head - style(type="text/css"). - body { - font-family: "Lucida Sans Typewriter", "Lucida Console", Monaco, "Bitstream Vera Sans Mono", monospace; - font-size: 11px; - color: #4a4a4a - } - .git-chunk { - background-color: #ececec; - } - .git-deletion { - background-color: #ffc4b4; - } - .git-insertion { - background-color: #d4ffb4; - } - - body - #files.diff-view - each file in parsedFiles - .file - .meta= file.name - .data - table.file-code.file-diff - each line in file.lines - if (line.type == 'chunk') - tr.file-diff-line.git-chunk - td.diff-line-num ... - td.diff-line-num ... - td.diff-line-code= line.content - else if (line.type == 'normal') - tr.file-diff-line - td.diff-line-num= line.deletionLineNum - td.diff-line-num= line.additionLineNum - td.diff-line-code= line.content - else if (line.type == 'deletion') - tr.file-diff-line.git-deletion - td.diff-line-num= line.deletionLineNum - td.diff-line-num.empty-cell - span.line-num-content   - td.diff-line-code= line.content - else if (line.type == 'addition') - tr.file-diff-line.git-insertion - td.diff-line-num.empty-cell - span.line-num-content   - td.diff-line-num= line.additionLineNum - td.diff-line-code= line.content