Skip to content

Commit

Permalink
jQuery isn't required
Browse files Browse the repository at this point in the history
  • Loading branch information
chriso committed Mar 8, 2011
1 parent 296ebca commit 1c37147
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
9 changes: 3 additions & 6 deletions .gitmodules
@@ -1,12 +1,9 @@
[submodule "vendor/jquery"]
path = vendor/jquery
url = https://github.com/coolaj86/node-jquery.git
[submodule "vendor/htmlparser"]
path = vendor/htmlparser
url = https://github.com/tautologistics/node-htmlparser.git
[submodule "vendor/jsdom"]
path = vendor/jsdom
url = https://github.com/tmpvar/jsdom.git
[submodule "vendor/validator"]
path = vendor/validator
url = https://chriso@github.com/chriso/node-validator.git
[submodule "vendor/soupselect"]
path = vendor/soupselect
url = https://github.com/harryf/node-soupselect.git
15 changes: 11 additions & 4 deletions lib/node.io/dom.js
Expand Up @@ -4,7 +4,9 @@
* MIT Licensed
*/

var Job = require('./job').JobProto, soupselect;
var Job = require('./job').JobProto,
utils = require('./utils'),
soupselect;

/**
* The CSS selector function. See the documentation for usage examples.
Expand Down Expand Up @@ -47,12 +49,17 @@ Job.prototype.parseHtml = function (data, callback, response) {
ProcessExternalResources: false,
QuerySelector: false
};
var $, window = require('../../vendor/jsdom/lib/jsdom').jsdom(data, null, {features:features}).createWindow(),
jquery = require('../../vendor/jquery/lib/jquery-1.5'),
default_$ = jquery.create(window);
try {
var $, window = require('jsdom').jsdom(data, null, {features:features}).createWindow(),
jquery = require('jquery'),
default_$ = jquery.create(window);
} catch (e) {
utils.fatal('jQuery is not installed. Run `npm install jquery`');
}
$ = function (selector, context) {
return context ? jquery.create(context) : default_$(selector);
};
console.log(e);process.exit();
callback.apply(this, [null, $, data, headers, response]);
} else {
var self = this, handler, parser, $, htmlparser = require('../../vendor/htmlparser/lib/htmlparser');
Expand Down
4 changes: 2 additions & 2 deletions lib/node.io/index.js
Expand Up @@ -28,11 +28,11 @@ exports.create = function (obj) {
obj = {run: obj};
}
var options = obj.options || {};
utils.put(options, {
options = utils.put({
timeout: 10,
auto_retry: true,
spoof: true
});
}, options);
return new job.Job(options, obj);
};

Expand Down
2 changes: 1 addition & 1 deletion lib/node.io/processor.js
Expand Up @@ -265,7 +265,7 @@ Processor.prototype.loadJob = function (job, callback) {
//Check if the job is a builtin
var builtins = ['digest','eval','pagerank','query','resolve','statuscode','validate','word_count'];
if (builtins.indexOf(job) !== -1) {
callback(null, job, require(__dirname + '/../../builtin/' + job + '.coffee'));
callback(null, job, require(__dirname + '/../../builtin/' + job + '.js'));
}

//Jobs in the current working directory are given top priority
Expand Down
1 change: 0 additions & 1 deletion vendor/jquery
Submodule jquery deleted from ffd339
1 change: 0 additions & 1 deletion vendor/jsdom
Submodule jsdom deleted from f39bec
1 change: 1 addition & 0 deletions vendor/soupselect
Submodule soupselect added at 2de253

0 comments on commit 1c37147

Please sign in to comment.