Permalink
Browse files

first commit

  • Loading branch information...
frozzare committed Aug 9, 2012
0 parents commit df3718e565894fda767f361a4b864513b6f2f540
Showing with 29,706 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +3 −0 .npmignore
  3. +20 −0 MIT-LICENSE
  4. +6 −0 Makefile
  5. +28 −0 README.md
  6. +77 −0 index.js
  7. +1 −0 node_modules/.bin/_mocha
  8. +1 −0 node_modules/.bin/mocha
  9. +6 −0 node_modules/mocha/.npmignore
  10. +5 −0 node_modules/mocha/.travis.yml
  11. +407 −0 node_modules/mocha/History.md
  12. +22 −0 node_modules/mocha/LICENSE
  13. +120 −0 node_modules/mocha/Makefile
  14. +41 −0 node_modules/mocha/Readme.md
  15. +4,444 −0 node_modules/mocha/_mocha.js
  16. +415 −0 node_modules/mocha/bin/_mocha
  17. +36 −0 node_modules/mocha/bin/mocha
  18. BIN node_modules/mocha/images/error.png
  19. BIN node_modules/mocha/images/ok.png
  20. +4 −0 node_modules/mocha/index.js
  21. +6 −0 node_modules/mocha/lib/browser/debug.js
  22. 0 node_modules/mocha/lib/browser/diff.js
  23. +178 −0 node_modules/mocha/lib/browser/events.js
  24. 0 node_modules/mocha/lib/browser/fs.js
  25. 0 node_modules/mocha/lib/browser/path.js
  26. +125 −0 node_modules/mocha/lib/browser/progress.js
  27. +8 −0 node_modules/mocha/lib/browser/tty.js
  28. +56 −0 node_modules/mocha/lib/context.js
  29. +50 −0 node_modules/mocha/lib/hook.js
  30. +108 −0 node_modules/mocha/lib/interfaces/bdd.js
  31. +60 −0 node_modules/mocha/lib/interfaces/exports.js
  32. +5 −0 node_modules/mocha/lib/interfaces/index.js
  33. +91 −0 node_modules/mocha/lib/interfaces/qunit.js
  34. +94 −0 node_modules/mocha/lib/interfaces/tdd.js
  35. +238 −0 node_modules/mocha/lib/mocha.js
  36. +355 −0 node_modules/mocha/lib/reporters/base.js
  37. +56 −0 node_modules/mocha/lib/reporters/doc.js
  38. +63 −0 node_modules/mocha/lib/reporters/dot.js
  39. +51 −0 node_modules/mocha/lib/reporters/html-cov.js
  40. +219 −0 node_modules/mocha/lib/reporters/html.js
  41. +18 −0 node_modules/mocha/lib/reporters/index.js
  42. +149 −0 node_modules/mocha/lib/reporters/json-cov.js
  43. +61 −0 node_modules/mocha/lib/reporters/json-stream.js
  44. +70 −0 node_modules/mocha/lib/reporters/json.js
  45. +97 −0 node_modules/mocha/lib/reporters/landing.js
  46. +64 −0 node_modules/mocha/lib/reporters/list.js
  47. +92 −0 node_modules/mocha/lib/reporters/markdown.js
  48. +38 −0 node_modules/mocha/lib/reporters/min.js
  49. +259 −0 node_modules/mocha/lib/reporters/nyan.js
  50. +86 −0 node_modules/mocha/lib/reporters/progress.js
  51. +87 −0 node_modules/mocha/lib/reporters/spec.js
  52. +63 −0 node_modules/mocha/lib/reporters/tap.js
  53. +65 −0 node_modules/mocha/lib/reporters/teamcity.js
  54. +50 −0 node_modules/mocha/lib/reporters/templates/coverage.jade
  55. +13 −0 node_modules/mocha/lib/reporters/templates/menu.jade
  56. +34 −0 node_modules/mocha/lib/reporters/templates/script.html
  57. +301 −0 node_modules/mocha/lib/reporters/templates/style.html
  58. +115 −0 node_modules/mocha/lib/reporters/xunit.js
  59. +190 −0 node_modules/mocha/lib/runnable.js
  60. +488 −0 node_modules/mocha/lib/runner.js
  61. +271 −0 node_modules/mocha/lib/suite.js
  62. +32 −0 node_modules/mocha/lib/test.js
  63. +220 −0 node_modules/mocha/lib/utils.js
  64. +199 −0 node_modules/mocha/mocha.css
  65. +4,597 −0 node_modules/mocha/mocha.js
  66. +23 −0 node_modules/mocha/my-reporter.js
  67. +1 −0 node_modules/mocha/node_modules/.bin/jade
  68. +4 −0 node_modules/mocha/node_modules/commander/.npmignore
  69. +4 −0 node_modules/mocha/node_modules/commander/.travis.yml
  70. +107 −0 node_modules/mocha/node_modules/commander/History.md
  71. +7 −0 node_modules/mocha/node_modules/commander/Makefile
  72. +262 −0 node_modules/mocha/node_modules/commander/Readme.md
  73. +2 −0 node_modules/mocha/node_modules/commander/index.js
  74. +1,026 −0 node_modules/mocha/node_modules/commander/lib/commander.js
  75. +45 −0 node_modules/mocha/node_modules/commander/package.json
  76. +4 −0 node_modules/mocha/node_modules/debug/.npmignore
  77. +47 −0 node_modules/mocha/node_modules/debug/History.md
  78. +4 −0 node_modules/mocha/node_modules/debug/Makefile
  79. +130 −0 node_modules/mocha/node_modules/debug/Readme.md
  80. +120 −0 node_modules/mocha/node_modules/debug/debug.component.js
  81. +116 −0 node_modules/mocha/node_modules/debug/debug.js
  82. +19 −0 node_modules/mocha/node_modules/debug/example/app.js
  83. +24 −0 node_modules/mocha/node_modules/debug/example/browser.html
  84. +10 −0 node_modules/mocha/node_modules/debug/example/wildcards.js
  85. +22 −0 node_modules/mocha/node_modules/debug/example/worker.js
  86. +1 −0 node_modules/mocha/node_modules/debug/head.js
  87. +2 −0 node_modules/mocha/node_modules/debug/index.js
  88. +135 −0 node_modules/mocha/node_modules/debug/lib/debug.js
  89. +38 −0 node_modules/mocha/node_modules/debug/package.json
  90. +4 −0 node_modules/mocha/node_modules/debug/tail.js
  91. +31 −0 node_modules/mocha/node_modules/diff/LICENSE
  92. +94 −0 node_modules/mocha/node_modules/diff/README.md
  93. +287 −0 node_modules/mocha/node_modules/diff/diff.js
  94. +89 −0 node_modules/mocha/node_modules/diff/index.html
  95. +53 −0 node_modules/mocha/node_modules/diff/package.json
  96. +81 −0 node_modules/mocha/node_modules/diff/style.css
  97. +616 −0 node_modules/mocha/node_modules/diff/test/diffTest.js
  98. +48 −0 node_modules/mocha/node_modules/growl/History.md
  99. +93 −0 node_modules/mocha/node_modules/growl/Readme.md
  100. +188 −0 node_modules/mocha/node_modules/growl/lib/growl.js
  101. +26 −0 node_modules/mocha/node_modules/growl/package.json
  102. +16 −0 node_modules/mocha/node_modules/growl/test.js
  103. +15 −0 node_modules/mocha/node_modules/jade/.npmignore
  104. +22 −0 node_modules/mocha/node_modules/jade/LICENSE
  105. +147 −0 node_modules/mocha/node_modules/jade/bin/jade
  106. +4 −0 node_modules/mocha/node_modules/jade/index.js
  107. +3,586 −0 node_modules/mocha/node_modules/jade/jade.js
  108. +510 −0 node_modules/mocha/node_modules/jade/jade.md
  109. +2 −0 node_modules/mocha/node_modules/jade/jade.min.js
  110. +642 −0 node_modules/mocha/node_modules/jade/lib/compiler.js
  111. +18 −0 node_modules/mocha/node_modules/jade/lib/doctypes.js
  112. +97 −0 node_modules/mocha/node_modules/jade/lib/filters.js
  113. +28 −0 node_modules/mocha/node_modules/jade/lib/inline-tags.js
  114. +237 −0 node_modules/mocha/node_modules/jade/lib/jade.js
  115. +771 −0 node_modules/mocha/node_modules/jade/lib/lexer.js
  116. +77 −0 node_modules/mocha/node_modules/jade/lib/nodes/attrs.js
  117. +33 −0 node_modules/mocha/node_modules/jade/lib/nodes/block-comment.js
  118. +121 −0 node_modules/mocha/node_modules/jade/lib/nodes/block.js
  119. +43 −0 node_modules/mocha/node_modules/jade/lib/nodes/case.js
  120. +35 −0 node_modules/mocha/node_modules/jade/lib/nodes/code.js
  121. +32 −0 node_modules/mocha/node_modules/jade/lib/nodes/comment.js
  122. +29 −0 node_modules/mocha/node_modules/jade/lib/nodes/doctype.js
  123. +35 −0 node_modules/mocha/node_modules/jade/lib/nodes/each.js
  124. +35 −0 node_modules/mocha/node_modules/jade/lib/nodes/filter.js
  125. +20 −0 node_modules/mocha/node_modules/jade/lib/nodes/index.js
  126. +32 −0 node_modules/mocha/node_modules/jade/lib/nodes/literal.js
  127. +36 −0 node_modules/mocha/node_modules/jade/lib/nodes/mixin.js
  128. +25 −0 node_modules/mocha/node_modules/jade/lib/nodes/node.js
  129. +95 −0 node_modules/mocha/node_modules/jade/lib/nodes/tag.js
  130. +36 −0 node_modules/mocha/node_modules/jade/lib/nodes/text.js
  131. +710 −0 node_modules/mocha/node_modules/jade/lib/parser.js
  132. +174 −0 node_modules/mocha/node_modules/jade/lib/runtime.js
  133. +19 −0 node_modules/mocha/node_modules/jade/lib/self-closing.js
  134. +49 −0 node_modules/mocha/node_modules/jade/lib/utils.js
  135. +2 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/.gitignore.orig
  136. +5 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/.gitignore.rej
  137. +2 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/.npmignore
  138. +21 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/LICENSE
  139. +54 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/README.markdown
  140. +6 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/examples/pow.js
  141. +6 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/examples/pow.js.orig
  142. +19 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/examples/pow.js.rej
  143. +79 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/index.js
  144. +44 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/package.json
  145. +38 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/chmod.js
  146. +37 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/clobber.js
  147. +28 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/mkdirp.js
  148. +32 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/perm.js
  149. +39 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/perm_sync.js
  150. +41 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/race.js
  151. +32 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/rel.js
  152. +27 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/sync.js
  153. +28 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/umask.js
  154. +27 −0 node_modules/mocha/node_modules/jade/node_modules/mkdirp/test/umask_sync.js
  155. +58 −0 node_modules/mocha/node_modules/jade/package.json
  156. +179 −0 node_modules/mocha/node_modules/jade/runtime.js
  157. +1 −0 node_modules/mocha/node_modules/jade/runtime.min.js
  158. +7 −0 node_modules/mocha/node_modules/jade/test.jade
  159. +5 −0 node_modules/mocha/node_modules/jade/testing/head.jade
  160. +22 −0 node_modules/mocha/node_modules/jade/testing/index.jade
  161. +11 −0 node_modules/mocha/node_modules/jade/testing/index.js
  162. +6 −0 node_modules/mocha/node_modules/jade/testing/layout.jade
  163. +7 −0 node_modules/mocha/node_modules/jade/testing/user.jade
  164. +27 −0 node_modules/mocha/node_modules/jade/testing/user.js
  165. +55 −0 node_modules/mocha/package.json
  166. +8 −0 node_modules/mocha/test.js
  167. +3 −0 node_modules/should/.gitmodules
  168. +1 −0 node_modules/should/.npmignore
  169. +128 −0 node_modules/should/History.md
  170. +6 −0 node_modules/should/Makefile
  171. +390 −0 node_modules/should/Readme.md
  172. +53 −0 node_modules/should/examples/runner.js
  173. +2 −0 node_modules/should/index.js
  174. +91 −0 node_modules/should/lib/eql.js
  175. +718 −0 node_modules/should/lib/should.js
  176. +47 −0 node_modules/should/package.json
  177. +96 −0 node_modules/should/test/exist.test.js
  178. +641 −0 node_modules/should/test/should.test.js
  179. +13 −0 package.json
  180. +11 −0 test/index.js
@@ -0,0 +1 @@
+.DS_Store
@@ -0,0 +1,3 @@
+.DS_Store
+test
+*.sock
@@ -0,0 +1,20 @@
+Copyright (c) 2012 Fredrik Forsmo <fredrik.forsmo@gmail.com>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
+test:
+ @./node_modules/.bin/mocha \
+ --require should \
+ --reporter spec
+
+.PHONY: test
@@ -0,0 +1,28 @@
+# json-to-html
+
+Convert JSON Object to HTML. This will work in the browser too.
+
+## Installation
+
+ npm install json-to-html
+
+## Example
+
+ var json2html = require('json-to-html')
+ , html = json2html({ 'hello': 'world' });
+
+ console.log(html);
+
+output:
+
+ {
+ <span class="string">"hello"</span>: <span class="string">"world"</span>
+ }
+
+Every operand has a span added around it self with different classnames.
+
+`string`, `boolean`, `number` or `null`.
+
+## License
+
+See [MIT-LICENSE](https://github.com/frozzare/json-to-html/blob/master/MIT-LICENSE)
@@ -0,0 +1,77 @@
+var indents = 0
+ , size = 2;
+
+/**
+ * Escape the given string of `html`.
+ *
+ * @param {String} html
+ * @return {String} Escaped HTML
+ */
+
+function escape (html) {
+ return String(html)
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+}
+
+/**
+ * Add indentation to `html` string.
+ *
+ * @param {String} html
+ * @return {String} HTML with indentation
+ */
+
+function indent (html) {
+ return Array(indents * size).join(' ') + (html || '');
+}
+
+/**
+ * Convert JSON Object to html
+ *
+ * @param {Object} obj JSON Object to convert
+ * @return {String} html output
+ */
+
+function to_html (obj) {
+ if (typeof obj === 'string') {
+ return '<span class="string">"' + escape(obj) + '"</span>';
+ } else if (typeof obj === 'number') {
+ return '<span class="number">' + obj.toString() + '</span>';
+ } else if (obj === true || obj === false) {
+ return '<span class="boolean">' + obj.toString() + '</span>';
+ } else if (obj === null) {
+ return '<span class="null">null</span>';
+ } else if ((obj instanceof Array && !obj.length) || (!Object.keys(obj).length)) {
+ return '<span class="array">' + (obj instanceof Array ? '[]' : '{}') + '</span>';
+ } else {
+ var arr = obj instanceof Array
+ , str = (arr ? '[' : '{') + '\n'
+ , res = [];
+
+ indents++;
+
+ if (arr) {
+ for (var i = 0; i < obj.length; i++) {
+ res.push(indent(to_html(obj[i])));
+ }
+ } else {
+ for (var k in obj) {
+ if (obj.hasOwnProperty(k)) {
+ res.push(indent(to_html(k) + ': ' + to_html(obj[k])));
+ }
+ }
+ }
+
+ str += res.join(',\n') + '\n';
+ indents--;
+ str += indent(arr ? ']' : '}');
+ return str;
+ }
+}
+
+module.exports = function (obj, ind) {
+ size = ind || size;
+ return to_html(obj);
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit df3718e

Please sign in to comment.