diff --git a/.meteor/versions b/.meteor/versions index a74eb28c9..1ed83792d 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -29,6 +29,7 @@ caching-html-compiler@1.0.3-modules.8 callback-hook@1.0.5-modules.8 cfs:http-methods@0.0.30 check@1.1.1-modules.8 +chuangbo:marked@0.3.5_1 coffeescript@1.0.12-modules.8 cosmos:browserify@0.9.3 dburles:collection-helpers@1.0.4 @@ -41,6 +42,7 @@ ddp-rate-limiter@1.0.1-modules.8 ddp-server@1.2.3-modules.8 deps@1.0.9 diff-sequence@1.0.2-modules.8 +djedi:sanitize-html@1.11.2 ecmascript@0.4.0-modules.8 ecmascript-runtime@0.2.7-modules.8 ejson@1.0.8-modules.8 @@ -92,6 +94,7 @@ oauth@1.1.7-modules.8 oauth1@1.1.6-modules.8 oauth2@1.1.6-modules.8 observe-sequence@1.0.8-modules.8 +ongoworks:speakingurl@6.0.0 ordered-dict@1.0.4 percolatestudio:synced-cron@1.1.0 promise@0.5.2-modules.8 diff --git a/packages/nova-comments/lib/methods.js b/packages/nova-comments/lib/methods.js index c38796464..9e9304ad0 100644 --- a/packages/nova-comments/lib/methods.js +++ b/packages/nova-comments/lib/methods.js @@ -1,9 +1,9 @@ - +Comments.methods = {}; // ------------------------------------------------------------------------------------------- // // -------------------------------------- Submit Comment ------------------------------------- // // ------------------------------------------------------------------------------------------- // -Comments.submit = function (comment) { +Comments.methods.new = function (comment) { var userId = comment.userId; // at this stage, a userId is expected @@ -45,7 +45,7 @@ Comments.submit = function (comment) { return comment; }; -Comments.edit = function (commentId, modifier, comment) { +Comments.methods.edit = function (commentId, modifier, comment) { // ------------------------------ Callbacks ------------------------------ // @@ -68,7 +68,8 @@ Comments.edit = function (commentId, modifier, comment) { // ------------------------------------------------------------------------------------------- // Meteor.methods({ - submitComment: function(comment){ + + 'comments.new': function(comment){ // checking might be redundant because SimpleSchema already enforces the schema, but you never know check(comment, Comments.simpleSchema()); @@ -128,10 +129,10 @@ Meteor.methods({ comment.userId = user._id; } - return Comments.submit(comment); + return Comments.methods.new(comment); }, - editComment: function (modifier, commentId) { + 'comments.edit': function (modifier, commentId) { // checking might be redundant because SimpleSchema already enforces the schema, but you never know check(modifier, {$set: Comments.simpleSchema()}); @@ -162,10 +163,10 @@ Meteor.methods({ }); }); - Comments.edit(commentId, modifier, comment); + Comments.methods.edit(commentId, modifier, comment); }, - deleteCommentById: function (commentId) { + 'comments.deleteById': function (commentId) { check(commentId, String); @@ -199,5 +200,26 @@ Meteor.methods({ Messages.flash("You don't have permission to delete this comment.", "error"); } + }, + + 'comments.upvote': function (commentId) { + check(commentId, String); + return Telescope.operateOnItem.call(this, Comments, commentId, Meteor.user(), "upvote"); + }, + + 'comments.downvote': function (commentId) { + check(commentId, String); + return Telescope.operateOnItem.call(this, Comments, commentId, Meteor.user(), "downvote"); + }, + + 'comments.cancelUpvote': function (commentId) { + check(commentId, String); + return Telescope.operateOnItem.call(this, Comments, commentId, Meteor.user(), "cancelUpvote"); + }, + + 'comments.cancelDownvote': function (commentId) { + check(commentId, String); + return Telescope.operateOnItem.call(this, Comments, commentId, Meteor.user(), "cancelDownvote"); } + }); diff --git a/packages/nova-components/lib/common/Header.jsx b/packages/nova-components/lib/common/Header.jsx index 736e391be..30a9b5156 100644 --- a/packages/nova-components/lib/common/Header.jsx +++ b/packages/nova-components/lib/common/Header.jsx @@ -16,7 +16,7 @@ const Header = props => { - New Post + New Post ) } diff --git a/packages/nova-components/lib/posts/PostNew.jsx b/packages/nova-components/lib/posts/PostNew.jsx index f30f4497a..7e55d0b74 100644 --- a/packages/nova-components/lib/posts/PostNew.jsx +++ b/packages/nova-components/lib/posts/PostNew.jsx @@ -58,6 +58,7 @@ const PostNew = React.createClass({ label="Body" type="text" /> + {/* + */} diff --git a/packages/nova-components/lib/posts/list/PostViews.jsx b/packages/nova-components/lib/posts/list/PostViews.jsx index 9fb16e51f..7bf60e7fb 100644 --- a/packages/nova-components/lib/posts/list/PostViews.jsx +++ b/packages/nova-components/lib/posts/list/PostViews.jsx @@ -1,7 +1,7 @@ -let views = ["top", "new", "best", "daily"]; -const adminViews = ["pending", "rejected", "scheduled"]; - const PostViews = props => { + + let views = ["top", "new", "best", "daily"]; + const adminViews = ["pending", "rejected", "scheduled"]; if (Users.is.admin(Meteor.user())) { views = views.concat(adminViews); @@ -12,7 +12,7 @@ const PostViews = props => { diff --git a/packages/nova-components/lib/routes.jsx b/packages/nova-components/lib/routes.jsx index 517180427..67bb773ce 100644 --- a/packages/nova-components/lib/routes.jsx +++ b/packages/nova-components/lib/routes.jsx @@ -1,7 +1,7 @@ // ------------------------------------- Posts -------------------------------- // FlowRouter.route('/', { - name: 'postDefault', + name: 'posts.list', action: function (params, queryParams) { ({AppContainer, ListContainer, PostList} = Telescope.components); ({selector, options} = Posts.parameters.get(queryParams)); @@ -28,8 +28,8 @@ FlowRouter.route('/', { // } // }); -FlowRouter.route('/post/new', { - name: 'postNew', +FlowRouter.route('/posts/new', { + name: 'posts.new', action: function (params, queryParams) { ({AppContainer, PostNewContainer} = Telescope.components); ReactLayout.render(AppContainer, {content: }) @@ -37,8 +37,8 @@ FlowRouter.route('/post/new', { } }); -FlowRouter.route('/post/:_id', { - name: 'postPage', +FlowRouter.route('/posts/:_id', { + name: 'posts.single', action: function (params, queryParams) { ({AppContainer, ItemContainer, Post} = Telescope.components); ReactLayout.render(AppContainer, {content: }) @@ -46,8 +46,8 @@ FlowRouter.route('/post/:_id', { } }); -FlowRouter.route('/post/:_id/edit', { - name: 'postEdit', +FlowRouter.route('/posts/:_id/edit', { + name: 'posts.edit', action: function (params, queryParams) { ({AppContainer, ItemContainer, Post} = Telescope.components); ReactLayout.render(AppContainer, {content: }) diff --git a/packages/nova-lib/package.js b/packages/nova-lib/package.js index d34b8c9b7..2e1b4c19b 100644 --- a/packages/nova-lib/package.js +++ b/packages/nova-lib/package.js @@ -45,7 +45,7 @@ Package.onUse(function (api) { // 'kadira:dochead@1.4.0', 'dburles:collection-helpers@1.0.4', 'matb33:collection-hooks@0.8.1', - // 'chuangbo:marked@0.3.5_1', + 'chuangbo:marked@0.3.5_1', // 'meteorhacks:fast-render@2.11.0', // 'meteorhacks:subs-manager@1.6.3', 'percolatestudio:synced-cron@1.1.0', @@ -58,12 +58,11 @@ Package.onUse(function (api) { // 'utilities:avatar@0.9.2', // 'fortawesome:fontawesome@4.5.0', // 'ccan:cssreset@1.0.0', - // 'djedi:sanitize-html@1.11.2', + 'djedi:sanitize-html@1.11.2', // 'jparker:gravatar@0.4.1', // 'sanjo:meteor-files-helpers@1.2.0_1', - // 'cmather:handlebars-server@2.0.0', // 'chuangbo:cookie@1.1.0', - // 'ongoworks:speakingurl@6.0.0', + 'ongoworks:speakingurl@6.0.0', // 'okgrow:router-autoscroll@0.1.6', 'tmeasday:publish-counts@0.7.3', // 'utilities:onsubscribed@0.1.2', diff --git a/packages/nova-posts/lib/callbacks.js b/packages/nova-posts/lib/callbacks.js index 0ee56a79a..bc175d0b5 100644 --- a/packages/nova-posts/lib/callbacks.js +++ b/packages/nova-posts/lib/callbacks.js @@ -51,20 +51,12 @@ Posts.before.update(function (userId, doc, fieldNames, modifier) { * Increment the user's post count and upvote the post */ function afterPostSubmitOperations (post) { - console.log(this) var userId = post.userId; Meteor.users.update({_id: userId}, {$inc: {"telescope.postCount": 1}}); return post; } Telescope.callbacks.add("postSubmitAsync", afterPostSubmitOperations); -function upvoteOwnPost (post) { - var postAuthor = Meteor.users.findOne(post.userId); - Telescope.operateOnItem(Posts, post._id, postAuthor, "upvote"); - return post; -} -Telescope.callbacks.add("postSubmitAsync", upvoteOwnPost); - function setPostedAt (post) { if (post.isApproved() && !post.postedAt) { Posts.update(post._id, {$set: {postedAt: new Date()}}); @@ -72,7 +64,20 @@ function setPostedAt (post) { } Telescope.callbacks.add("postEditAsync", setPostedAt); -// notifications +// ------------------------------------- Votes -------------------------------- // + +if (typeof Telescope.operateOnItem !== "undefined") { + + function upvoteOwnPost (post) { + var postAuthor = Meteor.users.findOne(post.userId); + Telescope.operateOnItem(Posts, post._id, postAuthor, "upvote"); + return post; + } + Telescope.callbacks.add("postSubmitAsync", upvoteOwnPost); + +} + +// ------------------------------------- Notifications -------------------------------- // if (typeof Herald !== "undefined") { diff --git a/packages/nova-posts/lib/helpers.js b/packages/nova-posts/lib/helpers.js index dbbf87aa0..0065df87c 100644 --- a/packages/nova-posts/lib/helpers.js +++ b/packages/nova-posts/lib/helpers.js @@ -36,7 +36,7 @@ Posts.helpers({getLinkTarget: function () {return Posts.getLinkTarget(this);}}); Posts.getPageUrl = function(post, isAbsolute){ var isAbsolute = typeof isAbsolute === "undefined" ? false : isAbsolute; // default to false var prefix = isAbsolute ? Telescope.utils.getSiteUrl().slice(0,-1) : ""; - return prefix + FlowRouter.path("postPage", post); + return prefix + FlowRouter.path("posts.single", post); }; Posts.helpers({getPageUrl: function (isAbsolute) {return Posts.getPageUrl(this, isAbsolute);}}); @@ -47,7 +47,7 @@ Posts.helpers({getPageUrl: function (isAbsolute) {return Posts.getPageUrl(this, Posts.getEditUrl = function(post, isAbsolute){ var isAbsolute = typeof isAbsolute === "undefined" ? false : isAbsolute; // default to false var prefix = isAbsolute ? Telescope.utils.getSiteUrl().slice(0,-1) : ""; - return prefix + FlowRouter.path("postEdit", post); + return prefix + FlowRouter.path("posts.edit", post); }; Posts.helpers({getEditUrl: function (isAbsolute) {return Posts.getEditUrl(this, isAbsolute);}}); diff --git a/packages/nova-posts/lib/methods.js b/packages/nova-posts/lib/methods.js index 478bc5024..f24d41298 100644 --- a/packages/nova-posts/lib/methods.js +++ b/packages/nova-posts/lib/methods.js @@ -121,7 +121,6 @@ Meteor.methods({ check(post, Posts.simpleSchema()); - console.log("// submitting post…") // required properties: // title @@ -318,6 +317,26 @@ Meteor.methods({ 'posts.checkForDuplicates': function (url) { Posts.checkForSameUrl(url); + }, + + 'posts.upvote': function (postId) { + check(postId, String); + return Telescope.operateOnItem.call(this, Posts, postId, Meteor.user(), "upvote"); + }, + + 'posts.downvote': function (postId) { + check(postId, String); + return Telescope.operateOnItem.call(this, Posts, postId, Meteor.user(), "downvote"); + }, + + 'posts.cancelUpvote': function (postId) { + check(postId, String); + return Telescope.operateOnItem.call(this, Posts, postId, Meteor.user(), "cancelUpvote"); + }, + + 'posts.cancelDownvote': function (postId) { + check(postId, String); + return Telescope.operateOnItem.call(this, Posts, postId, Meteor.user(), "cancelDownvote"); } }); diff --git a/packages/nova-scoring/lib/vote.js b/packages/nova-scoring/lib/vote.js index d14fcc852..ae25e90c8 100644 --- a/packages/nova-scoring/lib/vote.js +++ b/packages/nova-scoring/lib/vote.js @@ -91,39 +91,4 @@ Telescope.operateOnItem = function (collection, itemId, user, operation) { } -} - -Meteor.methods({ - upvotePost: function (postId) { - check(postId, String); - return Telescope.operateOnItem.call(this, Posts, postId, Meteor.user(), "upvote"); - }, - downvotePost: function (postId) { - check(postId, String); - return Telescope.operateOnItem.call(this, Posts, postId, Meteor.user(), "downvote"); - }, - cancelUpvotePost: function (postId) { - check(postId, String); - return Telescope.operateOnItem.call(this, Posts, postId, Meteor.user(), "cancelUpvote"); - }, - cancelDownvotePost: function (postId) { - check(postId, String); - return Telescope.operateOnItem.call(this, Posts, postId, Meteor.user(), "cancelDownvote"); - }, - upvoteComment: function (commentId) { - check(commentId, String); - return Telescope.operateOnItem.call(this, Comments, commentId, Meteor.user(), "upvote"); - }, - downvoteComment: function (commentId) { - check(commentId, String); - return Telescope.operateOnItem.call(this, Comments, commentId, Meteor.user(), "downvote"); - }, - cancelUpvoteComment: function (commentId) { - check(commentId, String); - return Telescope.operateOnItem.call(this, Comments, commentId, Meteor.user(), "cancelUpvote"); - }, - cancelDownvoteComment: function (commentId) { - check(commentId, String); - return Telescope.operateOnItem.call(this, Comments, commentId, Meteor.user(), "cancelDownvote"); - } -}); +}; \ No newline at end of file