Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicolson #24

Open
wants to merge 57 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
244557b
test works
trinisofttechnologies Feb 16, 2015
ccba7cc
test on after W insert
trinisofttechnologies Feb 16, 2015
59d6279
groundDB added
trinisofttechnologies Feb 18, 2015
2635431
nicolson_ files deleted
trinisofttechnologies Feb 18, 2015
c1f2782
no data in W or WI
trinisofttechnologies Mar 18, 2015
2ab1c39
there is no data in W object now
trinisofttechnologies Mar 18, 2015
44e071c
test case improved
trinisofttechnologies Mar 18, 2015
1815f1d
stuck at react coffee
trinisofttechnologies Mar 18, 2015
42fc8fe
got some progress
trinisofttechnologies Mar 18, 2015
a4392bf
still building
trinisofttechnologies Mar 18, 2015
cb08fd3
Groud error fixed
trinisofttechnologies Mar 18, 2015
18cf76a
merged
trinisofttechnologies Mar 19, 2015
a0046d5
merged
trinisofttechnologies Mar 19, 2015
0aa69d5
merged react
trinisofttechnologies Mar 19, 2015
c34c3d2
merged trinisoft/inbox
trinisofttechnologies Mar 19, 2015
8d78a32
.orig file removed
trinisofttechnologies Mar 19, 2015
a4b8238
updating
trinisofttechnologies Mar 19, 2015
01fd5c4
yesterday work
trinisofttechnologies Mar 20, 2015
70d092e
react still buggy
trinisofttechnologies Mar 20, 2015
46f630b
another change
trinisofttechnologies Mar 20, 2015
a268d3b
made test sync
trinisofttechnologies Mar 20, 2015
45d132b
test is working now
trinisofttechnologies Mar 20, 2015
3dd1099
back on track
trinisofttechnologies Mar 20, 2015
78dbf21
removed unworking test
trinisofttechnologies Mar 20, 2015
130a132
match failed for failing test
trinisofttechnologies Mar 20, 2015
42bd464
test working perfectly
trinisofttechnologies Mar 20, 2015
5518082
cleaning up
hastenfernandes Mar 22, 2015
33168be
first start ready
hastenfernandes Mar 22, 2015
3af6310
formated
hastenfernandes Mar 22, 2015
41e6a9b
getting better
hastenfernandes Mar 22, 2015
9e9ef01
more changes
hastenfernandes Mar 22, 2015
6af9398
always success
hastenfernandes Mar 22, 2015
05a649d
removed multiple times test
hastenfernandes Mar 22, 2015
c2addde
first commit
trinisofttechnologies Mar 25, 2015
b5335a0
merged to trinisoft
trinisofttechnologies Mar 25, 2015
dead1be
removed orig
trinisofttechnologies Mar 25, 2015
2f4ca7b
updated
trinisofttechnologies Mar 25, 2015
b9f103d
updated
trinisofttechnologies Mar 25, 2015
6b1ac43
merged
trinisofttechnologies Mar 25, 2015
cb9b6f0
removed .orig
trinisofttechnologies Mar 25, 2015
3f7439d
package changed
trinisofttechnologies Mar 26, 2015
c27d39f
app in sessions now.
trinisofttechnologies Mar 26, 2015
dda6534
changes
trinisofttechnologies Mar 30, 2015
c91ba8c
test
trinisofttechnologies Apr 6, 2015
2ae9a4a
Meteor.users to WI collection
trinisofttechnologies Apr 7, 2015
7694c20
improved connect function
trinisofttechnologies Apr 7, 2015
9e0cbbe
votes as per connect
trinisofttechnologies Apr 7, 2015
fc9e404
moving on both side
trinisofttechnologies Apr 10, 2015
0498281
no hooks running on client side
trinisofttechnologies Apr 10, 2015
33999e1
added condition
trinisofttechnologies Apr 10, 2015
5b9cad7
cannot say if it works
trinisofttechnologies Apr 10, 2015
3899569
more testing
trinisofttechnologies Apr 10, 2015
8eef632
still testing
trinisofttechnologies Apr 10, 2015
263ec5a
fixed double insert
trinisofttechnologies Apr 10, 2015
0b29a44
changed
trinisofttechnologies Apr 10, 2015
c776c17
merged
trinisofttechnologies Apr 10, 2015
970f68a
readme added
trinisofttechnologies Apr 13, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Meteor.subscribe("users",Meteor.userId());

WI.find({}).observe({
"added": function(docs){
Unionize.onChangeClient(docs);
},
"changed": function(docs){
Unionize.onChangeClient(docs);
},
"removed": function(docs){
Unionize.onChangeClient(docs);
}
});

Session.setDefault("inbox", []);
Session.setDefault("outbox", []);
Session.setDefault("follow", []);
Session.setDefault("big", []);
Unionize.onChangeFlag = false;
Unionize.onChangeClient = function(doc){
if(Unionize.onChangeFlag)
return;
if(userId == doc._id){
if(doc.inbox && Session.get("inbox").length != doc.inbox.length)
Session.set("inbox",doc.inbox);
if(doc.outbox && Session.get("outbox").length != doc.outbox.length)
Session.set("outbox",doc.outbox);
if(doc.follow && Session.get("follow").length != doc.follow.length)
Session.set("follow",doc.follow);
if(doc.big && Session.get("big").length != doc.big.length)
Session.set("big",doc.big);
}
Unionize.onChangeFlag = false;
}

// WI.after.insert(function(userId, doc, fieldNames, modifier, options){

// });

// WI.after.update(function(userId, doc, fieldNames, modifier, options){
// log("here too");
// if(userId == window.userId){
// log("here");
// Session.set("inbox",doc.inbox);
// Session.set("outbox",doc.outbox);
// Session.set("follow",doc.follow);
// }
// });

// WI.after.remove(function(userId, doc, fieldNames, modifier, options){
// log("here too");
// if(userId == window.userId){
// log("here");
// Session.set("inbox",doc.inbox);
// Session.set("outbox",doc.outbox);
// Session.set("follow",doc.follow);
// }
// });


112 changes: 112 additions & 0 deletions lib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
var WIModel = function(options){
return {
"_id": options._id,
"inbox": [],
"outbox": [],
"follow": [],
"big": [],
"seen": [],
"vote": [],
"recommend": [],
"profile": {
"profile_picture": "http://i.imgur.com/vaCjg.jpg"
}
}
}
Unionize = {};
WI = new Mongo.Collection("wi");
W = new Mongo.Collection("w");
log = console.log.bind(console);

Unionize.getUTC = function(){
return new Date().getTime();
}
Unionize.exists = function(userId){
return WI.find(userId).count()
}
Unionize.prepare = function(userId){
if(Unionize.exists(userId) == 0){
var wiModel = new WIModel({"_id": userId});
WI.insert(wiModel);
return false;
}
return true;
}
Unionize.connect = function(docs){
if(!docs)
throw new new Meteor.Error("Please check information provided undefined", "404");
if(!docs.from_user){
throw new new Meteor.Error("Source is not defined from_user", "404");
}
if(!docs.to_user)
throw new new Meteor.Error("Target is not defined to_user", "404");

Unionize.prepare(docs.from_user);

docs.startTime = Unionize.getUTC();
docs.journey = [{"onConnect": Unionize.getUTC()- docs.startTime}];
WI.update(docs.from_user,{$push: {"outbox": docs}});
}


// hooks

Unionize.onWUpdateHook = function(userId, docs){
// log("Unionize.onWInsertHook");
// log(docs.clientUpdate,Meteor.isServer)
if(docs.clientUpdate && Meteor.isServer)
return docs;

if(Meteor.isClient){
if(!Unionize.exists(docs.to_user))
return docs;
docs.clientUpdate = true;
}

Unionize.prepare(docs.to_user);

docs.journey.push({"onWUpdateHook": Unionize.getUTC()- docs.startTime});

// console.log(docs._id,Meteor.isClient,Meteor.isServer)
W.insert(docs);

docs.journey.push({"onInsertW": Unionize.getUTC()- docs.startTime});



WI.update(docs.to_user,{$push: {"inbox": docs}});
docs.journey.push({"onInsertWIInbox": Unionize.getUTC()- docs.startTime});
// if(WI.find(docs.to_user).count()){
// // log("to_user updated");
// }
return docs;

// replicated on W collection
}

// WI.insert.before(function(docs){

// });

// WI.insert.after(function(docs){

// });

// log(W.before.insert())
// W.before.insert(function(userId, docs){
// // Unionize.onWInsertHook(userId, docs);
// });


WI.before.update(function(userId, doc, fieldNames, modifier, options){
// log(Meteor.isClient,Meteor.isServer)
if(fieldNames[0] == "outbox"){
modifier["$push"].outbox = Unionize.onWUpdateHook(userId, modifier["$push"].outbox);
var docs = modifier["$push"].outbox
docs.journey.push({"onInsertWIInbox": Unionize.getUTC() - docs.startTime});
// log(userId, doc, fieldNames, modifier, options)
}
});
// W.after.update(function(){

// });
7 changes: 7 additions & 0 deletions methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// methods
Meteor.methods({
"updateUserElement": function(find,update){
WI.update(find,
update)
}
});
78 changes: 53 additions & 25 deletions package.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,47 +14,75 @@ Package.describe({
// add grounddb here
Package.on_use(function (api) {
api.versionsFrom('1.0.3.1');
api.use(['matb33:[email protected]','coffeescript'], ['client', 'server']);
api.use([
'matb33:collection-hooks',
'coffeescript',
'mongo',
'accounts-base',
'session',
], ['client', 'server']);

// like Document W will be an extended coll..
api.export('Unionize');
api.export(["W","WI","Unionize"], ['client','server']);

api.add_files([
'lib.coffee'
'lib.js'
], ['client','server']);

api.add_files([
'client.coffee'
], 'client');
'client.js'
], ['client']);

api.add_files([
'server.coffee', 'publish.coffee'
], 'server');
'server.js',
'rules.js',
'methods.js',
'publish.js'
], ['server']);

});

Package.on_test(function (api) {
api.versionsFrom('1.0.3.1');
api.use(['underscore','ground:[email protected]','aldeed:console-me','matb33:[email protected]','tracker', 'tinytest', 'test-helpers', 'coffeescript', 'insecure', 'accounts-base', 'accounts-password', 'underscore', 'random', 'pedrohenriquerls:reactjs'], ['client', 'server']);
api.add_files([
'lib.coffee',
'testUpdateClient.coffee',
'tests.coffee',
], ['client', 'server']);

api.add_files([
'server.coffee',
'publish.coffee'
], ['server']);
// api.versionsFrom('1.0.3.1');
api.use(
[
'underscore',
'ground:db',
'aldeed:console-me',
'matb33:collection-hooks',
'tracker',
'tinytest',
'test-helpers',
'coffeescript',
'insecure',
'accounts-base',
'accounts-password',
'underscore',
'random',
'pedrohenriquerls:reactjs',
'mongo'
],
[
'client',
'server'
]);

api.export(["W","WI","Unionize"], ['client','server']);

api.add_files([
'client.coffee'
], ['client']);
'lib.js'
], ['client','server']);

api.add_files([
'react_test.coffee'
'client.js'
], ['client']);
});

api.add_files([
'server.js'
], ['server']);

api.add_files([
'test.js'
], ['client','server']);


});
6 changes: 6 additions & 0 deletions publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Meteor.publish(null,function(){
return WI.find({});
});
Meteor.publish(null,function(){
return W.find({});
});
38 changes: 38 additions & 0 deletions react_package.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@userId = 'wiber' unless Meteor.userId()


@FeedList = React.createClass
"getInitialState": ()->
{feeds: WI.findOne
"_id": userId}
"componentDidMount": ()->
self = @
Tracker.autorun ()->
feed = WI.findOne({"_id": userId})
self.setState({"feeds": feed})
"render": ()->
feedsList = []
# console.log(this.state.feeds)
if(this.state.feeds and this.state.feeds.outbox)
outbox = this.state.feeds.outbox
feedsList = outbox.map (feed)->
# console.log(feed)
# React.DOM.div(null,"Something is returned")
Feed({"feed": feed})
# console.error(feedsList)
return React.DOM.div(null,"",feedsList)

@Feed = React.createClass({
"render": ()->
# console.error(this.props.feed)
feed = this.props.feed

React.DOM.div(null,{},
feed.from
# [
# React.DOM.div(null,{},feed.from),
# React.DOM.div(null,{},feed.to)
# ]
)
# React.DOM.div(null,"Something is returning")
})
50 changes: 34 additions & 16 deletions react_test.coffee
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@

# doesn't need to be asyn

Tinytest.add 'reactjs - 5 dom element equals to data', (test, next) ->
testingRecommend = { from: 'another1', to: 'wiber6' }
connect(testingRecommend)
intervalId = null
intervalId = setInterval(()->
domString = React.renderComponentToString(feedItems(null))
if domString.match(testingRecommend.from + testingRecommend.to)
test.equal(true,true)
next()
clearInterval(intervalId)
, 500)

# Tinytest.addAsync 'reactjs - dom element equals to data', (test, next) ->
# testingRecommend = { from: 'another1', to: 'wiber6' }
# connect(testingRecommend)
# intervalId = null
# intervalId = setInterval(()->
# domString = React.renderComponentToString(feedItems(null))
# if domString.match(testingRecommend.from + testingRecommend.to)
# test.equal(true,true)
# next()
# clearInterval(intervalId)
# , 500)

# @feedItems = React.createClass
# "getInitialState": ()->
# {feeds: WI.findOne
# "_id": user}
# "_id": myWI}
# "componentDidMount": ()->
# self = @
# Tracker.autorun ()->
# feed = WI.findOne({"_id": user})
# feed = WI.findOne({"_id": myWI})
# self.setState({"feeds": feed})
# "render": ()->
# # console.error(this.state.feeds)
Expand All @@ -38,4 +37,23 @@ Tinytest.add 'reactjs - 5 dom element equals to data', (test, next) ->
# test.equal(this.state.feeds.sending.length,feedsList.length)
# next()
# return React.DOM.div(null,feedsList)
# React.renderComponentToString(@feedItems(null))
# React.renderComponentToString(@feedItems(null))

smite = ()->
#nothing here yet.



aNewReact = React.createClass({
"onClick": ()->
,
"render": ()->
# return <div> </div>
return React.DOM.div(null,{
"onClick": this.onClick
})
,
"event": ()->
#changes
})

Loading