Permalink
Browse files

start on web support

  • Loading branch information...
1 parent dfd4619 commit 6499a96084fbcbe41a3f4094ec5a7d88e7cf14ea @crcn crcn committed Feb 28, 2012
Showing with 17,697 additions and 4 deletions.
  1. 0 lib/{ → node}/eachCssRule.js
  2. 0 lib/{ → node}/index.js
  3. 0 lib/{ → node}/jquery-1.5.js
  4. +26 −0 lib/node/package.json
  5. 0 lib/{ → node}/test/compatibility/test-android.js
  6. 0 lib/{ → node}/test/compatibility/test-apple-mail-4.js
  7. 0 lib/{ → node}/test/compatibility/test-gmail.js
  8. 0 lib/{ → node}/test/compatibility/test-hotmail.js
  9. 0 lib/{ → node}/test/compatibility/test-iphone-ipad.js
  10. 0 lib/{ → node}/test/compatibility/test-outlook-2003.js
  11. 0 lib/{ → node}/test/compatibility/test-outlook-2010-2010.js
  12. 0 lib/{ → node}/test/compatibility/test-yahoo-mail.js
  13. +10 −2 lib/{ → node}/test/index.js
  14. 0 lib/{ → node}/test/selectors/test-selectors.js
  15. 0 lib/{ → node}/test/suite.js
  16. +9 −0 lib/web/eachCssRule.js
  17. +141 −0 lib/web/index.js
  18. +8,176 −0 lib/web/jquery-1.5.js
  19. +31 −0 lib/web/mesh.json
  20. +26 −0 lib/web/package.json
  21. +49 −0 lib/web/test/compatibility/test-android.js
  22. +17 −0 lib/web/test/compatibility/test-apple-mail-4.js
  23. +48 −0 lib/web/test/compatibility/test-gmail.js
  24. +30 −0 lib/web/test/compatibility/test-hotmail.js
  25. +17 −0 lib/web/test/compatibility/test-iphone-ipad.js
  26. +33 −0 lib/web/test/compatibility/test-outlook-2003.js
  27. +60 −0 lib/web/test/compatibility/test-outlook-2010-2010.js
  28. +34 −0 lib/web/test/compatibility/test-yahoo-mail.js
  29. +47 −0 lib/web/test/index.js
  30. +25 −0 lib/web/test/selectors/test-selectors.js
  31. +96 −0 lib/web/test/suite.js
  32. +8 −1 makefile
  33. +1 −1 package.json
  34. +9 −0 src/node web/eachCssRule.js
  35. +141 −0 src/node web/index.js
  36. +8,176 −0 src/node web/jquery-1.5.js
  37. +49 −0 src/node web/test/compatibility/test-android.js
  38. +17 −0 src/node web/test/compatibility/test-apple-mail-4.js
  39. +48 −0 src/node web/test/compatibility/test-gmail.js
  40. +30 −0 src/node web/test/compatibility/test-hotmail.js
  41. +17 −0 src/node web/test/compatibility/test-iphone-ipad.js
  42. +33 −0 src/node web/test/compatibility/test-outlook-2003.js
  43. +60 −0 src/node web/test/compatibility/test-outlook-2010-2010.js
  44. +34 −0 src/node web/test/compatibility/test-yahoo-mail.js
  45. +47 −0 src/node web/test/index.js
  46. +25 −0 src/node web/test/selectors/test-selectors.js
  47. +96 −0 src/node web/test/suite.js
  48. +31 −0 src/web/mesh.merge.json
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,26 @@
+{
+ "author": "Craig Condon",
+ "name": "emailify",
+ "description": "Make HTML pages email-safe",
+ "version": "0.0.1",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/crcn/emailify.git"
+ },
+ "main": "./lib/node/index.js",
+ "dependencies": {
+ "outcome": "0.0.x",
+ "jsdom": "0.2.10",
+ "optimist": "0.3.x",
+ "vows": "0.6.x",
+ "plugin": "0.0.x",
+ "step": "0.0.x",
+ "colors": "0.6.x",
+ "sprintf": "0.1.x"
+ },
+ "devDependencies": {},
+ "bin": {
+ "emailify": "./bin/emailify"
+ },
+ "directories": {}
+}
@@ -1,3 +1,5 @@
+
+
var plugin = require('plugin'),
loader = plugin.loader(),
suite = require('./suite');
@@ -7,6 +9,7 @@ require('colors');
module.exports = function(window, options, callback) {
var subject = suite(window);
+ try {
loader.
factory(function(plugin) {
@@ -23,16 +26,21 @@ module.exports = function(window, options, callback) {
}
+
+
subject.add(module);
}).
- require(__dirname + "/selectors/**/test-*").
- require(__dirname + "/compatibility/**/test-*").
+ require(__dirname + "/selectors/**/test").
+ require(__dirname + "/compatibility/**/test").
load(function() {
subject.run(callback);
});
+}catch(e) {
+ console.log(e.stack)
+}
};
File renamed without changes.
@@ -0,0 +1,9 @@
+module.exports = function(topic, callback) {
+
+ topic.$('link, style').each(function(index, element) {
+
+ element.sheet.cssRules.forEach(callback)
+
+ });
+
+};
View
@@ -0,0 +1,141 @@
+var fs = require('fs'),
+jsdom = require('jsdom'),
+outcome = require('outcome'),
+test = require('./test'),
+step = require('step'),
+eachCssRule = require('./eachCssRule');
+
+function _copyStyles(window) {
+
+ eachCssRule(window, function(rule) {
+ try {
+ window.$(rule.selectorText).each(function(index, element) {
+
+ element.style.cssText += rule.style.cssText;
+ element.cssText = element.style.cssText;
+
+ });
+ } catch(e) {
+
+ }
+
+ });
+
+}
+
+/**
+ * parses content into email-safe HTML
+ */
+
+function _parse(content, options, callback) {
+
+ if(typeof options == 'function') {
+
+ callback = options;
+ options.test = false;
+
+ }
+
+
+ var on = outcome.error(callback),
+ warnings,
+ window;
+
+ step(
+
+ /**
+ * load it.
+ */
+
+ function() {
+
+ jsdom.env({
+ html: content,
+ scripts: [
+ __dirname + "/jquery-1.5.js"
+ ],
+ done: this
+ });
+
+ },
+
+
+ /**
+ * set it.
+ */
+
+ on.success(function(win) {
+
+
+ window = win;
+ _copyStyles(window);
+ this();
+
+ }),
+
+ /**
+ * test it.
+ */
+
+ on.success(function() {
+
+ if(!options.test) {
+
+ return this();
+
+ }
+
+ test(window, {}, this);
+
+ }),
+
+ /**
+ * clean it.
+ */
+
+ on.success(function(warn) {
+
+ warnings = warn;
+
+ window.$('script, link, style').remove();
+ this();
+
+ }),
+
+
+ /**
+ * finish it.
+ */
+
+ function() {
+
+ callback(null, window.document.innerHTML, warnings || []);
+
+ }
+ );
+
+
+}
+
+/**
+ */
+
+function _load(file, options, callback) {
+
+ if(typeof options == 'function') {
+
+ callback = options;
+ options = {};
+
+ }
+
+ fs.readFile(file, "utf8", outcome.error(callback).success(function(content) {
+
+ _parse(content, options, callback);
+
+ }));
+
+}
+
+exports.parse = _parse;
+exports.load = _load;
Oops, something went wrong.

0 comments on commit 6499a96

Please sign in to comment.