diff --git a/assemble.sh b/assemble.sh index 488395d..df41d86 100644 --- a/assemble.sh +++ b/assemble.sh @@ -3,6 +3,7 @@ #where $USER and $IP is the default username and IP of your remote Ubuntu 12.04 machine: #scp assemble.sh $USER@$IP:/home/$USER/ && ssh $USER@$IP 'bash ./assemble.sh' +#NODE=http://nodejs.org/dist/v0.8.15/node-v0.8.15-linux-x64.tar.gz #binary NODE=http://nodejs.org/dist/v0.8.15/node-v0.8.15.tar.gz MONGO=http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.1.tgz REDIS=http://redis.googlecode.com/files/redis-2.6.6.tar.gz @@ -32,6 +33,7 @@ if [ -e /usr/local/bin/node ]; then echo "node already installed." else + #TODO: REPLACE THE FOLLOWING BUILD WITH NAVE INSTEAD, TO MAKE THINGS FAST! echo "installing node" wget -O node.tar.gz $NODE mkdir node @@ -183,7 +185,7 @@ http.createServer(function (req, res) { echo "====== END LOCAL ======" echo "#!/bin/sh sudo stop theory -GIT_WORK_TREE=/usr/local/bin/theory/code git checkout -f +GIT_WORK_TREE=/usr/local/bin/theory/code git checkout -f sudo start theory echo 'deployed'" > hooks/post-receive chmod +x hooks/post-receive @@ -213,12 +215,12 @@ set httpd port 8080 and sudo mv monitrc /etc/monit/ sudo echo "check host theory_init with address 127.0.0.1 - start program = '/sbin/start theory' - stop program = '/sbin/stop theory' - if failed port 80 protocol HTTP - request / - with timeout 2 seconds - then restart +start program = '/sbin/start theory' +stop program = '/sbin/stop theory' +if failed port 80 protocol HTTP + request / + with timeout 2 seconds + then restart " > theory sudo mv theory /etc/monit/conf.d/ sudo chown -fR ubuntu ~/theory diff --git a/coalesce.js b/coalesce.js index f4d5ac9..04cf0ab 100644 --- a/coalesce.js +++ b/coalesce.js @@ -1,7 +1,7 @@ module.exports=require('theory')((function(){ var web = {}; web.name = 'web'; - web.version = 1.8; + web.version = 1.9; web.author = 'Mark'; web.dependencies = [ 'fs' @@ -286,7 +286,7 @@ module.exports=require('theory')((function(){ to.count++; return; } else - if(a[way]){ // TODO: BUG: Warning this is a no-joke condition! It is now on bottom, but should still think about bug edge cases like "test". + if(a[way]){ // TODO: Warning this is a no-joke condition! It is now on bottom, but should still think about bug edge cases like "test". a(a(m,'how.way')+'->')(m); return; }else{ @@ -299,7 +299,8 @@ module.exports=require('theory')((function(){ m.where.at = m.where.on||m.where.off||m.where.at; delete m.where.on; delete m.where.off; - return web.event.emit(m.where.at,m); + web.event.emit(m.where.at,m); + return; } if((con = state.con.s[m.who.to||'']) && con.writable){ return con.write(a.text(state.con.clean(m)).ify()); @@ -391,7 +392,7 @@ module.exports=require('theory')((function(){ c.tid = {value: c.tid.value || c.sid.tal || c.tid, HttpOnly:false}; } } - c = a.obj(c).each(function(v,i,t){ // TODO: BUG: Update documentation to reflect the new API. No more $cookie, just cookie = {value: 'blah', path: '/'} + c = a.obj(c).each(function(v,i,t){ // TODO: Update documentation to reflect the new API. No more $cookie, just cookie = {value: 'blah', path: '/'} if(a.text.is(v)){ v = {value: v}; } if(a.obj.is(v)){ @@ -420,14 +421,12 @@ module.exports=require('theory')((function(){ return fn(true); } if(m.who.tid){ // GETEX REDIS HERE - - var s, t = a.time.is(), w; + var s, t = a.time.is(), w, ws; if(s = cookie.tryst[m.who.tid]){ web.state.con.s[req.tid = m.who.tid] = req; req.sid = m.who.sid = s.sid; - - if((w = a.text(m.how.way).clip('.',0,1)) && (w+='.'+a(web.run.on,w+'.meta.stream.on'))){ - var n = a.com.meta({what:s,who:m.who,how:{way:w,web:'stream'},where:{pid:0}}); + if((w = a.text(m.how.way).clip('.',0,1)) && (ws=a(web.run.on,w+'.meta.stream.on'))){ + var n = a.com.meta({what:s,who:m.who,how:{way:(w+='.'+ws),web:'stream'},where:{pid:0}}); n.what.data = m.what; web.reply(n,function(n){ delete n.who.to; @@ -590,7 +589,7 @@ module.exports=require('theory')((function(){ delete event.w[i]; } }); - return; + return event.w[w]; }); event.on = (function(w,c){ if(!w) return {}; diff --git a/init.js b/init.js index 71abb19..0d2ea42 100644 --- a/init.js +++ b/init.js @@ -1 +1 @@ -require('./coalesce')({port: (process.env.PORT||7777), sec: -2}); \ No newline at end of file +require('./coalesce')({port: (process.env.PORT||8888), sec: -2}); \ No newline at end of file diff --git a/package.json b/package.json index cbac010..5356f88 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name": "coalesce" -, "version": "0.1.8" +, "version": "0.1.9" , "author": "Mark Nadal" , "description": "Awesome web platform for distributed projects." , "homepage": "http://github.com/amark/coalesce" diff --git a/play/hello.js b/play/hello.js index 071c909..9197b9e 100644 --- a/play/hello.js +++ b/play/hello.js @@ -5,8 +5,8 @@ module.exports = require('theory') return (document.hello.to.onkeyup = function(m){ - m.what? document.hello.to.value = m.what : a.com.send({ - what: document.hello.to.value, where: 'magic' }); + m && m.what? document.hello.to.value = m.what : + a.com.send({what: document.hello.to.value, where: 'magic' }); }); diff --git a/play/vault/vault.js b/play/vault/vault.js index 4010422..239594a 100644 --- a/play/vault/vault.js +++ b/play/vault/vault.js @@ -42,7 +42,7 @@ module.exports=require('theory')((function(){ m = a.com.meta(m,w); m.where = m.where||{on:'vault'}; m.who = m.who||{}; - if(v.id) m.who.id = v.id; + if(v.id) m.who.via = v.id; m.who.from = v.cid; a.com(w).send(m); return m; @@ -55,7 +55,7 @@ module.exports=require('theory')((function(){ m = a.com.meta(m,w); m.where = m.who.from; m.who = m.who||{}; - if(v.id) m.who.id = v.id; + if(v.id) m.who.via = v.id; m.who.from = v.cid; a.com(w).send(m); }); @@ -74,7 +74,7 @@ module.exports=require('theory')((function(){ v.onlive(m); var vs = _.store('vault'), d; if(!(m.what=vs[m.what])) return; - console.log("Retrieving "+m.what.id+"'s data."); + console.log("Retrieving "+m.what.via+"'s data."); v.com('.is').reply(m); return; } @@ -147,9 +147,9 @@ module.exports=require('theory')((function(){ +"."); return; } - console.log('Saving '+m.who.id+"'s data."); + console.log('Saving '+m.who.via+"'s data."); v.store = _.store('vault'); - v.store[m.who.id] = {when:m.when,data:m.what,id:m.who.id}; + v.store[m.who.via] = {when:m.when,data:m.what,via:m.who.via}; _.store('vault',v.store); m.what = {OK:1}; v.com.reply(m);