diff --git a/client/main.js b/client/main.js index e6a9a4e..dd054c3 100644 --- a/client/main.js +++ b/client/main.js @@ -1,9 +1,12 @@ import { Template } from 'meteor/templating'; import { ReactiveVar } from 'meteor/reactive-var'; +import "/lib/MyRes" + import './mainLayout.html'; -import './templates/main_item.js' +import './templates/main_item' import '/lib/router' +import './templates/user_page' Template.hello.onCreated(function helloOnCreated() { this.counter = new ReactiveVar(0); diff --git a/client/templates/main_item.js b/client/templates/main_item.js index a9615fc..d7308c1 100644 --- a/client/templates/main_item.js +++ b/client/templates/main_item.js @@ -1,5 +1,4 @@ import "./main_item.html" -import "/lib/MyRes" Template.mainItem.helpers({ main_datas: function (){ diff --git a/client/templates/userPage.html b/client/templates/userPage.html deleted file mode 100644 index 540968d..0000000 --- a/client/templates/userPage.html +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/client/templates/user_page.html b/client/templates/user_page.html new file mode 100644 index 0000000..7b5be81 --- /dev/null +++ b/client/templates/user_page.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/client/templates/user_page.js b/client/templates/user_page.js new file mode 100644 index 0000000..7f333d0 --- /dev/null +++ b/client/templates/user_page.js @@ -0,0 +1,9 @@ +Template.userPage.onRendered(function (){ + this.subscribe("userById",Router.current().params._id) +}) + +Template.userPage.helpers({ + user: function (){ + return User.findOne(Router.current().params._id) + } +}) \ No newline at end of file diff --git a/lib/router.js b/lib/router.js index 53b2ecd..4f6f857 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1,5 +1,5 @@ import "/client/templates/loading.html" -import "/client/templates/userPage.html" +import "/client/templates/user_page.html" import "/client/templates/not_found.html" Router.configure({ @@ -11,17 +11,14 @@ Router.configure({ } }) -Meteor.subscribe('user_res') +// Meteor.subscribe('user_res') Router.route("/") Router.route("/nelson", {name: 'mainItem'}) Router.route("/user/:_id", { - name: 'userPage', - data(){ - return User.findOne(this.params._id) - } + name: 'userPage' }) Router.onBeforeAction('dataNotFound',{only: 'userPage'}) diff --git a/server/publication.js b/server/publication.js index 5e899a9..f40b725 100644 --- a/server/publication.js +++ b/server/publication.js @@ -2,6 +2,10 @@ Meteor.publish("url_res",function () { return UrlRes.find() }) -Meteor.publish("user_res",function () { - return User.find() +// Meteor.publish("user_res",function () { +// return User.find() +// }) + +Meteor.publish("userById",function (id) { + return User.find({_id:id}) }) \ No newline at end of file