Skip to content

Commit

Permalink
fix playground
Browse files Browse the repository at this point in the history
  • Loading branch information
amark committed Mar 6, 2014
1 parent fd4ded9 commit 46ecca1
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 26 deletions.
16 changes: 9 additions & 7 deletions assemble.sh
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions 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'
Expand Down Expand Up @@ -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{
Expand All @@ -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());
Expand Down Expand Up @@ -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)){
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 {};
Expand Down
2 changes: 1 addition & 1 deletion init.js
@@ -1 +1 @@
require('./coalesce')({port: (process.env.PORT||7777), sec: -2});
require('./coalesce')({port: (process.env.PORT||8888), sec: -2});
2 changes: 1 addition & 1 deletion 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"
Expand Down
4 changes: 2 additions & 2 deletions play/hello.js
Expand Up @@ -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' });

});

Expand Down
10 changes: 5 additions & 5 deletions play/vault/vault.js
Expand Up @@ -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;
Expand All @@ -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);
});
Expand All @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 46ecca1

Please sign in to comment.