Permalink
Browse files

Moving to node 0.4.0, cleanup, and 'working' http module

  • Loading branch information...
1 parent bbf4739 commit 53591d93e7f50a3bdfabbbf6f58c1e24e58fbca8 @neyric committed Feb 22, 2011
View
@@ -1,6 +1,6 @@
{
"name": "webhookit-comment",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "Comment module for WebHookIt",
"author": "Eric Abouaf <eric.abouaf@gmail.com>",
"bugs": { "web" : "http://github.com/neyric/webhookit/issues" },
@@ -9,7 +9,7 @@
"Eric Abouaf <eric.abouaf@gmail.com> (http://neyric.com)"
],
"engines": {
- "node" : ">=0.2.5"
+ "node" : ">=0.4.0"
},
"directories": {
"lib" : "./lib"
@@ -20,6 +20,6 @@
"licenses":[ {"type" : "MIT"} ],
"repository": {
"type":"git",
- "url":"http://github.com/neyric/webhookit.git"
+ "url":"http://github.com/neyric/webhookit-packages.git"
}
}
@@ -23,12 +23,12 @@ exports.run = function(params, cb) {
exports.definition = {
- "name": "template",
+ "name": "ejs",
"category": "Templating",
"container": {
"icon": "/images/icons/script_edit.png",
"xtype": "WireIt.TextareaContainer",
- "title": "Liquid",
+ "title": "ejs",
"fields": [
{"type": "text", "name": "template", "wirable": false }
],
View
@@ -1,6 +1,6 @@
{
"name": "webhookit-ejs",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "EJS templating module for WebHookIt",
"author": "Eric Abouaf <eric.abouaf@gmail.com>",
"bugs": { "web" : "http://github.com/neyric/webhookit/issues" },
@@ -9,18 +9,18 @@
"Eric Abouaf <eric.abouaf@gmail.com> (http://neyric.com)"
],
"engines": {
- "node" : ">=0.2.5"
+ "node" : ">=0.4.0"
},
"directories": {
"lib" : "./lib"
},
"main": "./lib/webhookit-ejs",
"dependencies": {
- "ejs": ">=0.2.0"
+ "ejs": ">=0.3.0"
},
"licenses":[ {"type" : "MIT"} ],
"repository": {
"type":"git",
- "url":"http://github.com/neyric/webhookit.git"
+ "url":"http://github.com/neyric/webhookit-packages.git"
}
}
File renamed without changes.
View
@@ -1,6 +1,6 @@
{
"name": "webhookit-email",
- "version": "0.0.1",
+ "version": "0.0.2",
"description": "Email module for WebHookIt",
"author": "Eric Abouaf <eric.abouaf@gmail.com>",
"bugs": { "web" : "http://github.com/neyric/webhookit/issues" },
@@ -9,7 +9,7 @@
"Eric Abouaf <eric.abouaf@gmail.com> (http://neyric.com)"
],
"engines": {
- "node" : ">=0.2.5"
+ "node" : ">=0.4.0"
},
"directories": {
"lib" : "./lib"
@@ -21,6 +21,6 @@
"licenses":[ {"type" : "MIT"} ],
"repository": {
"type":"git",
- "url":"http://github.com/neyric/webhookit.git"
+ "url":"http://github.com/neyric/webhookit-packages.git"
}
}
View
@@ -0,0 +1,148 @@
+
+var http = require('http'),
+ querystring = require('querystring'),
+ URL = require('url'),
+ xml2js = require('xml2js-expat');
+
+
+exports.definition = {
+ "name": "http",
+ "category": "Sources",
+ "container": {
+ "icon": "/images/icons/arrow_right.png",
+ "xtype": "WireIt.FormContainer",
+ "title": "http",
+ "fields": [
+ {
+ "type": "string",
+ "name": "url",
+ "wirable": true,
+ label: "Url"
+ },
+ {
+ "type": "select",
+ "name": "method",
+ "wirable": false,
+ label: "Method",
+ choices: ["GET", "POST", "PUT", "DELETE", "HEAD"]
+ },
+ {
+ "type": "select",
+ label: "encoding",
+ "name": "encoding",
+ choices: ["application/x-www-form-urlencoded", "application/json", "application/xml"]
+ },
+ {
+ "type": "list",
+ "name": "urlparams",
+ listLabel: 'Parameters',
+ elementType: {
+ type: 'combine',
+ fields: [{typeInvite: 'field'},{ typeInvite: 'value',wirable: true}],
+ separators: [false, ":", false]
+ }
+ }
+ ],
+ "terminals": [
+ {
+ "name": "out",
+ "direction": [0, 1],
+ "offsetPosition": {
+ "left": 86,
+ "bottom": -15
+ },
+ "ddConfig": {
+ "type": "output",
+ "allowedTypes": ["input"]
+ }
+ }
+ ]
+ }
+};
+
+exports.run = function(params, cb) {
+
+ console.log("HTTP params ");
+ console.log(params);
+
+ var url = URL.parse(params["url"]);
+
+ var urlparams = {};
+ params["urlparams"].forEach(function(p) {
+ urlparams[p[0]] = p[1];
+ });
+
+ var port = url.port;
+ if(!port) { port = 80; }
+
+ var ssl = false;
+ if( params["url"].substr(0,5) == "https" ) {
+ ssl = true;
+ port = 443;
+ }
+
+ var client = http.createClient(port, url.hostname, ssl);
+ var path = url.pathname || '/';
+
+ if(params.method == "GET" || params.method == "DELETE") {
+ path += '?'+querystring.stringify(urlparams);
+ }
+
+ //console.log(path);
+
+ var request = client.request(params.method, path, {'host': url.hostname, "content-type": params.encoding});
+
+ if(params.method == "POST") {
+ if(params.encoding == "application/x-www-form-urlencoded") {
+
+ }
+ else if (params.encoding == "application/json") {
+
+ }
+ }
+
+ request.end();
+ request.on('response', function (response) {
+ console.log('STATUS: ' + response.statusCode);
+ console.log('HEADERS: ' + JSON.stringify(response.headers) );
+ response.setEncoding('utf8');
+ var complete = "";
+ response.on('data', function (chunk) {
+ complete += chunk;
+ });
+ response.on('end', function () {
+
+ r = complete;
+
+ // content-type:
+ var contentType = response.headers["content-type"].split(';')[0];
+
+ if(contentType) {
+
+ console.log("Content-Type "+contentType);
+
+ if( contentType == "application/json" ||
+ contentType == "text/javascript" ||
+ contentType == "application/javascript") {
+ r = JSON.parse(complete);
+ }
+
+ if(contentType == "text/xml") {
+
+ var parser = new xml2js.Parser();
+ parser.addListener('end', function(result) {
+ cb({out: result });
+ });
+ parser.parseString(complete);
+ return;
+
+ }
+
+ }
+
+ cb( {out: r} );
+ });
+
+ });
+
+};
@@ -1,97 +0,0 @@
-
-var http = require('http'),
- querystring = require('querystring'),
- URL = require('url'),
- xml2js = require('xml2js');
-
-
-exports.definition = {
- "name": "HTTP",
- "category": "Sources",
- "container": {
- "icon": "/images/icons/arrow_right.png",
- "xtype": "WireIt.FormContainer",
- "title": "HTTP",
- "fields": [
- {"type": "string", "name": "url", "wirable": true, label: "Url" },
- {"type": "select", "name": "method", "wirable": false, label: "Method", choices: ["GET", "POST", "PUT", "DELETE", "HEAD"] } ,
- {"type": "select", label: "encoding", "name": "encoding", choices: ["application/json", "application/xml", "application/x-www-form-urlencoded"] },
- {"type": "list", "name": "urlparams", listLabel: 'Parameters', elementType: {type: 'combine', fields: [ { typeInvite: 'field' }, { typeInvite: 'value', wirable: true } ], separators: [false,":",false] } }
- ],
- "terminals": [
- {"name": "out", "direction": [0,1], "offsetPosition": {"left": 86, "bottom": -15}, "ddConfig": {
- "type": "output",
- "allowedTypes": ["input"]
- }
- }
- ]
- }
- };
-
-exports.run = function(params, cb) {
-
- var url = URL.parse(params["url"]);
-
- var urlparams = {};
- params["urlparams"].forEach(function(p) {
- urlparams[p[0]] = p[1];
- });
-
- var port = url.port;
- if(!port) { port = 80; }
-
- var ssl = false;
- if( params["url"].substr(0,5) == "https" ) {
- ssl = true;
- port = 443;
- }
-
- var client = http.createClient(port, url.hostname, ssl);
- var path = url.pathname || '/';
-
- //if(params.method == "GET" || params.method == "DELETE") {
- path += '?'+querystring.stringify(urlparams);
- //}
-
- console.log(path);
-
- var request = client.request(params.method, path, {'host': url.hostname, "content-type": /*"application/x-www-form-urlencoded"*/ "multipart/form-data"});
- request.end();
- request.on('response', function (response) {
- console.log('STATUS: ' + response.statusCode);
- console.log('HEADERS: ' + JSON.stringify(response.headers) );
- response.setEncoding('utf8');
- var complete = "";
- response.on('data', function (chunk) {
- complete += chunk;
- });
- response.on('end', function () {
-
- r = complete;
-
- if(response.headers["content-type"]) {
-
- if( response.headers["content-type"] == "application/json" ||
- response.headers["content-type"] == "text/javascript" ||
- response.headers["content-type"] == "application/javascript") {
- r = JSON.parse(complete);
- }
-
- if(response.headers["content-type"] == "text/xml") {
-
- var parser = new xml2js.Parser();
- parser.addListener('end', function(result) {
- cb({out: result });
- });
- parser.parseString(complete);
- return;
-
- }
- }
-
- cb( {out: r} );
- });
-
- });
-
-};
View
@@ -1,6 +1,6 @@
{
"name": "webhookit-http",
- "version": "0.0.1",
+ "version": "0.0.4",
"description": "HTTP module for WebHookIt",
"author": "Eric Abouaf <eric.abouaf@gmail.com>",
"bugs": { "web" : "http://github.com/neyric/webhookit/issues" },
@@ -9,18 +9,18 @@
"Eric Abouaf <eric.abouaf@gmail.com> (http://neyric.com)"
],
"engines": {
- "node" : ">=0.2.5"
+ "node" : ">=0.4.0"
},
"directories": {
"lib" : "./lib"
},
"main": "./lib/webhookit-http",
"dependencies": {
- "xml2js": ">=0.1.5"
+ "xml2js-expat": ">=0.1.3"
},
"licenses":[ {"type" : "MIT"} ],
"repository": {
"type":"git",
- "url":"http://github.com/neyric/webhookit.git"
+ "url":"http://github.com/neyric/webhookit-packages.git"
}
}
@@ -17,7 +17,7 @@ exports.definition = {
"container": {
"icon": "/images/icons/magnifier.png",
"xtype": "WireIt.FormContainer",
- "title": "JSONPath",
+ "title": "jsonpath",
"width": 180,
"fields": [
{"type": "string", "name": "path", "wirable": false, label: "Path" },
Oops, something went wrong.

0 comments on commit 53591d9

Please sign in to comment.