|
@@ -14,6 +14,35 @@ Router.route("/", function () {
|
|
this.render("page_home", { to: "contents" });
|
|
this.render("page_home", { to: "contents" });
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+Router.route("/recommend", function () {
|
|
|
|
+ let likedDocs;
|
|
|
|
+ let recommended;
|
|
|
|
+
|
|
|
|
+ if (isLoggedIn()) {
|
|
|
|
+ let userId = Meteor.userId();
|
|
|
|
+ recommended = [];
|
|
|
|
+ let aWords, similar, wordsRegex;
|
|
|
|
+ likedDocs = Websites.find({ plus: { $in: [userId] }}).fetch();
|
|
|
|
+ likedDocs.forEach(function (liked) {
|
|
|
|
+ aWords = liked.words.split(' ');
|
|
|
|
+ wordsRegex = new RegExp(aWords.join(' .*'));
|
|
|
|
+ let criteria = {
|
|
|
|
+ _id: {$ne: liked._id},
|
|
|
|
+ words: { $regex: wordsRegex }
|
|
|
|
+ };
|
|
|
|
+ similar = Websites.find(criteria).fetch();
|
|
|
|
+ recommended.push({ liked, similar });
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ recommended = null;
|
|
|
|
+ }
|
|
|
|
+ this.render("page_recommend", {
|
|
|
|
+ to: "contents",
|
|
|
|
+ data: { recommended }
|
|
|
|
+ });
|
|
|
|
+});
|
|
|
|
+
|
|
Router.route("/search/:search", function () {
|
|
Router.route("/search/:search", function () {
|
|
const search = this.params.search;
|
|
const search = this.params.search;
|
|
this.render("page_search", {
|
|
this.render("page_search", {
|