Permalink
Browse files

Added ejs rendering of pubnub file + new startup params

  • Loading branch information...
1 parent 0f2142d commit 88846421bb383bb7933dc9d7e04e6756151d44ce @arnaudsj committed Oct 7, 2010
Showing with 25 additions and 7 deletions.
  1. +4 −4 Makefile
  2. +19 −2 app.js
  3. +1 −0 dump.rdb
  4. +1 −1 public/pubnub.js → views/pubnub.ejs
View
@@ -22,7 +22,7 @@ npm:
bin/npm config set root ${PWD}/.node_libraries
npmmods:
- bin/npm install vows@latest;
- bin/npm install express;
- bin/npm install redis;
-
+ bin/npm install vows@stable;
+ bin/npm install express@stable;
+ bin/npm install ejs@stable;
+ bin/npm install redis@stable;
View
@@ -16,7 +16,11 @@ app.configure(function(){
//app.use(express.cookieDecoder());
//app.use(express.session());
app.use(app.router);
- app.use(express.staticProvider(__dirname + '/public'));
+ app.set('view engine', 'ejs');
+ app.set('view options', {
+ layout: false
+ });
+ /*app.use(express.staticProvider(__dirname + '/public'));*/
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
redPublisher.flushdb();
});
@@ -32,6 +36,19 @@ app,get('pubnub-x-origin', function(req, res)
});
*/
+app.get('/pubnub.js', function(req, res)
+{
+ res.contentType('application/javascript');
+ res.render('pubnub.ejs', {
+ locals: {
+ hostname: process.argv[4],
+ port: process.argv[3]
+ }
+ })
+});
+
+
+
app.get('/pubnub-time', function(req, res)
{
pubnubResponse = {
@@ -241,6 +258,6 @@ app.get('/', function(req, res)
});
-app.listen(process.argv[2]);
+app.listen(process.argv[3]);
sys.log("pubnub server is now listening on: "+process.argv[2]+ ":" + process.argv[3]);
View
@@ -0,0 +1 @@
+REDIS0001�
@@ -8,7 +8,7 @@ window.PUBNUB||function(){window.console||(window.console=window.console||{});co
c,a[c])}function A(a,b){b.call(a,a);for(a=a.firstChild;a;){A(a,b);a=a.nextSibling}}var D=/\$?{([\w\-]+)}/g;function r(a,b,c){f(a.split(","),function(e){function o(i){if(!i)i=window.event;if(!c(i)){i.cancelBubble=true;i.returnValue=false;i.preventDefault&&i.preventDefault();i.stopPropagation&&i.stopPropagation()}}if(b.addEventListener)b.addEventListener(e,o,false);else if(b.attachEvent)b.attachEvent("on"+e,o);else b["on"+e]=o})}function h(){return y("head")[0]}function p(a,b){if(!a)return"";var c=
[],e="";for(e in a)c.push(escape(e)+"="+escape(a[e]));return(b.indexOf("?")===-1?"?":"&")+c.join("&")}function g(a){return document.createElement(a)}var l=0;function j(a){if(l)return x(a);var b=g("script"),c="x"+s(),e=100,o=setTimeout(function(){C("timeout")},a.timeout||3E4),i=a.url,m=a.data||{},q=a.c||w(),v=a.b||w();function t(){setTimeout(function(){e*=2;try{var u=h(),E=u.firstChild;E?u.insertBefore(b,E):u.appendChild(b)}catch(F){t()}},e)}function C(u){clearTimeout(o);if(b){u&&q.call(u,b,unescape(b.src));
b.onerror=null;try{h().removeChild(b)}catch(E){}}}b.async="async";window[c]=function(u){if(!u)return C("no data");v.call(b,u);window[c]=null;C(0)};r("error",b,function(){C("error")});m.unique=c;b.src=i+p(m,i);t();return C}var z=/^window\[[^\]]+\]\((.+?)\)$/;function x(a){var b=window.ActiveXObject?new window.ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest,c=a.c||w(),e=a.b||w(),o=0,i=a.data||{},m=a.url,q=setInterval(function(){if(b&&b.readyState==4&&!o){var t=b.status;o=1;if(q){clearInterval(q);
-q=null}t>=200&&t<300||t==304||t==1223?e(JSON.parse(b.responseText.replace(z,"$1"))):c(b);b=null}},14);i.unique="x"+s();try{b.open("GET",m+p(i,m),true);b.send()}catch(v){l=0;return j(a)}return function(){o=1;b&&b.abort&&b.abort()}}var k="http://127.0.0.1:8080/",d={history:function(a,b){b=b||w();a.limit=a.limit||100;if(!a.channel)return n("Must Specify a Channel");a.channel=d.d+"/"+a.channel;j({url:k+"pubnub-history",data:a,b:function(c){b(c.messages)},c:function(c){n(c)}})},time:function(a){j({url:k+"pubnub-time",
+q=null}t>=200&&t<300||t==304||t==1223?e(JSON.parse(b.responseText.replace(z,"$1"))):c(b);b=null}},14);i.unique="x"+s();try{b.open("GET",m+p(i,m),true);b.send()}catch(v){l=0;return j(a)}return function(){o=1;b&&b.abort&&b.abort()}}var k="http://<%=hostname%>:<%=port%>/",d={history:function(a,b){b=b||w();a.limit=a.limit||100;if(!a.channel)return n("Must Specify a Channel");a.channel=d.d+"/"+a.channel;j({url:k+"pubnub-history",data:a,b:function(c){b(c.messages)},c:function(c){n(c)}})},time:function(a){j({url:k+"pubnub-time",
b:function(b){a(b.time)},c:function(){a(0)}})},uuid:function(a){j({url:k+"pubnub-uuid",b:function(b){a(b.uuid)},c:function(){a(0)}})},publish:function(a,b){b=b||w()||a.callback;var c=a.message;if(!c)return n("Must Specify a Message");if(!a.channel)return n("Must Specify a Channel");c=JSON.stringify(c);if(c.length>1700)return n("Message exceeded limit 1700");if(!d.g)return n("Missing Publish Key");a.publish_key=d.g;a.channel=d.d+"/"+a.channel;a.message=c;j({url:k+"pubnub-publish",data:a,b:function(e){b(e)},
c:function(e){b(e)}})},unsubscribe:function(a){a=d.d+"/"+a.channel;if(a in d.a){d.a[a].disabled=1;d.a[a].e=0;d.a[a].f&&d.a[a].f(0)}},h:0,i:[],subscribe:function(a,b){function c(){setTimeout(function(){i*=2;j({url:k+"pubnub-subscribe",data:a,b:function(q){q&&q.server?e(q.server):c()},c:function(){c()}})},i)}function e(q){if(!(m in d.a&&d.a[m].disabled))d.a[m].f=j({url:"http://"+q+"/",data:{channel:m,timetoken:o},b:function(v){o=v.timetoken;e(q);v.messages[0]!="xdr.timeout"&&f(v.messages,function(t){b(t)})},
c:function(v){v=="timeout"?e(q):c()}})}if(!d.h)return d.i.push([a,b]);if(!a.channel)return n("Must Specify a Channel");b=b||a.callback;delete a.callback;if(!b)return n("Must Specify a Callback");if(!d.d)return n("Missing Subscribe Key");var o=0,i=100,m=a.channel=d.d+"/"+a.channel;m in d.a||(d.a[m]={});if(d.a[m].e)return n("Already Connected to this Channel: "+m);d.a[m].disabled=0;d.a[m].e=1;c()},g:"7795f1ac-fa60-414e-b01a-0d5ec643b4cb",d:"752a4eb0-b502-11df-a256-2f52a4db9804",j:"",a:{},xdr:j,each:f,map:function(a,b){var c=[];f(a||[],function(e,

0 comments on commit 8884642

Please sign in to comment.