-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.js
51 lines (47 loc) · 1.3 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
if (Meteor.isClient) {
Template.hello.greeting = function () {
return "Welcome to example.";
};
Template.hello.picture = function(){
var user = Meteor.users.findOne();
return user;
}
Template.hello.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
}
});
Meteor.subscribe("userData");
Meteor.subscribe("items");
}
Items = new Meteor.Collection("items");
if (Meteor.isServer) {
Meteor.startup(function () {
// code to run on server at startup
});
Meteor.publish("userData",function(){
return Meteor.users.find({},{fields:{'services.facebook.id':1}});
});
Meteor.publish("items", function(){
return Items.find();
});
Items.allow({
"insert": function(){return true},
"update": function(){return this.owner==Meteor.userId()}
});
Meteor.methods({
"addItem": function(data){
return Items.insert({owner:Meteor.userId(), title:data.title, body:data.body});
},
"facebook": function(){
var user = Meteor.user();
id = user.services.facebook.id;
token = user.services.facebook.accessToken;
var result = HTTP.get("http://google.ro");
console.log(result);
return result;
}
});
}