reverting back to online jQuery. Closes #7

This commit is contained in:
remy 2011-05-19 20:23:54 +01:00
parent cc29085553
commit a7696dc7b6
2 changed files with 16 additions and 17 deletions

View File

@ -8,14 +8,21 @@ var URL = require('url'),
https: require('https')
};
function get(url, rules, callback) {
function makeRequest(url) {
console.error('GET ' + url);
var oURL = URL.parse(url),
options = {
host: oURL.hostname,
port: oURL.port === undefined ? (oURL.protocol+'').indexOf('https') === 0 ? 443 : 80 : oURL.port,
path: oURL.pathname,
method: 'GET'
},
};
return http[oURL.protocol.slice(0, -1) || 'http'].request(options);
}
function get(url, rules, callback) {
var request = makeRequest(url),
body = '';
if (typeof rules == 'function') {
@ -23,10 +30,7 @@ function get(url, rules, callback) {
rules = {};
}
// console.log(oURL, options);
http[oURL.protocol.slice(0, -1) || 'http'].request(options, function (res) {
request.on('response', function (res) {
res.on('data', function (chunk) {
if (res.statusCode == 200) body += chunk;
});
@ -48,15 +52,10 @@ function get(url, rules, callback) {
}
function img2base64(url, callback) {
var oURL = URL.parse(url),
options = {
host: oURL.host,
port: oURL.port === undefined ? (oURL.protocol+'').indexOf('https') === 0 ? 443 : 80 : oURL.port,
path: oURL.pathname,
method: 'GET'
};
var request = makeRequest(url),
body = '';
http[oURL.protocol.slice(0, -1) || 'http'].request(options, function (res) {
request.on('response', function (res) {
var type = res.headers['content-type'],
prefix = 'data:' + type + ';base64,',
body = '';
@ -146,7 +145,7 @@ var inliner = module.exports = function (url, options, callback) {
get(url, function (html) {
// console.log(html.replace(/^\s*/g, ''), 'test');
jsdom.env(html, '', [
'jquery.min.js'
'http://code.jquery.com/jquery.min.js'
], function(errors, window) {
// remove jQuery that was included with jsdom
window.$('script:last').remove();
@ -353,4 +352,4 @@ if (!module.parent) {
inliner(process.argv[2], function (html) {
console.log(html);
});
}
}

View File

@ -1,6 +1,6 @@
{
"name": "inliner",
"version": "0.0.7",
"version": "0.0.8",
"description": "Utility to inline images, CSS and JavaScript for a web page - useful for mobile sites",
"homepage": "http://github.com/remy/inliner",
"main": "inliner",