123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- /**
- * Configure accounts-ui.
- */
- Accounts.ui.config({
- passwordSignupFields: "USERNAME_ONLY"
- });
- // Routing.
- Router.configure({
- layoutTemplate: "layout"
- });
- Router.route("/", function () {
- 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 () {
- const search = this.params.search;
- this.render("page_search", {
- to: "contents",
- data: {
- search,
- result: Websites.find({ words: { $regex: new RegExp(search) } }).fetch()
- }
- });
- });
- Router.route("/site/:id", function () {
- const id = this.params.id;
- const doc = _.extend({ onPage: true }, Websites.findOne({ _id: id }));
- this.render("page_site", {
- to: "contents",
- data: function () {
- return doc;
- }
- });
- });
|