From bab24860d64c3fb8bd68baad4af47306389a1fa5 Mon Sep 17 00:00:00 2001 From: Ben Gott Date: Tue, 30 Sep 2014 12:34:42 -0500 Subject: [PATCH 01/19] Update to use bengott:avatar package for all user avatars --- .meteor/packages | 14 ++++++------ .meteor/versions | 4 ++++ client/helpers/config.js | 4 ++++ client/views/comments/comment_item.html | 2 +- client/views/common/avatar.html | 3 --- client/views/common/avatar.js | 19 ---------------- client/views/posts/modules/post_content.js | 3 ++- client/views/users/user_item.html | 2 +- client/views/users/user_profile.html | 2 +- lib/gravatar.js | 24 --------------------- lib/users.js | 22 ++----------------- public/img/default_avatar.png | Bin 3613 -> 0 bytes 12 files changed, 21 insertions(+), 78 deletions(-) delete mode 100644 client/views/common/avatar.html delete mode 100644 client/views/common/avatar.js delete mode 100644 lib/gravatar.js delete mode 100644 public/img/default_avatar.png diff --git a/.meteor/packages b/.meteor/packages index efb4a321b6..9e70de6720 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -37,6 +37,11 @@ sacha:spin@2.0.4 sacha:juice chuangbo:marked@0.3.3 percolatestudio:synced-cron@0.1.1 +npm-container +matb33:collection-hooks +djedi:sanitize-html +rajit:bootstrap3-datepicker +bengott:avatar # Telescope Packages @@ -57,12 +62,6 @@ telescope-email telescope-update-prompt telescope-notifications telescope-kadira - - -npm-container -matb33:collection-hooks -djedi:sanitize-html -rajit:bootstrap3-datepicker telescope-update-prompt telescope-notifications telescope-kadira @@ -70,5 +69,4 @@ telescope-kadira # Accounts Templates service-configuration accounts-ui -splendido:accounts-templates-unstyled - +splendido:accounts-templates-unstyled \ No newline at end of file diff --git a/.meteor/versions b/.meteor/versions index 18d61ef954..42d6ccdbbc 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -12,6 +12,7 @@ application-configuration@1.0.2 autoupdate@1.1.1 backbone@1.0.0 base64@1.0.0 +bengott:avatar@0.1.0 binary-heap@1.0.0 blaze-tools@1.0.0 blaze@2.0.1 @@ -41,6 +42,8 @@ iron:core@0.3.4 iron:dynamic-template@0.4.1 iron:layout@0.4.1 iron:router@0.9.3 +jparker:crypto-core@0.1.0 +jparker:crypto-md5@0.1.1 jquery@1.0.0 json@1.0.0 less@1.0.9 @@ -93,6 +96,7 @@ splendido:accounts-templates-core@0.9.7 splendido:accounts-templates-unstyled@0.9.7 srp@1.0.0 standard-app-packages@1.0.2 +stylus@1.0.4 telescope-api@0.0.0 telescope-base@0.0.0 telescope-daily@0.0.0 diff --git a/client/helpers/config.js b/client/helpers/config.js index 94c05de285..538923b80b 100644 --- a/client/helpers/config.js +++ b/client/helpers/config.js @@ -40,3 +40,7 @@ Statuses={ approved: 2, rejected: 3 }; + +Avatar.options = { + emailHashProperty: 'email_hash' +}; diff --git a/client/views/comments/comment_item.html b/client/views/comments/comment_item.html index f824561a34..248bd0d21d 100644 --- a/client/views/comments/comment_item.html +++ b/client/views/comments/comment_item.html @@ -15,7 +15,7 @@ {{i18n "downvote"}} -
{{>avatar userId=userId class=""}}
+
{{>avatar userId=userId cssClass="avatar circle"}}
{{authorName}} diff --git a/client/views/common/avatar.html b/client/views/common/avatar.html deleted file mode 100644 index b230088c7c..0000000000 --- a/client/views/common/avatar.html +++ /dev/null @@ -1,3 +0,0 @@ - \ No newline at end of file diff --git a/client/views/common/avatar.js b/client/views/common/avatar.js deleted file mode 100644 index 93117d3b13..0000000000 --- a/client/views/common/avatar.js +++ /dev/null @@ -1,19 +0,0 @@ -Template[getTemplate('avatar')].helpers({ - url: function () { - if (this.user) { - return getAvatarUrl(this.user); - } - else if (this.userId) { - var user = Meteor.users.findOne(this.userId); - if (user) { - return getAvatarUrl(user); - } - } - }, - cssClass: function () { - if (this.class) { - return this.class; - } - return 'user-avatar'; - } -}); \ No newline at end of file diff --git a/client/views/posts/modules/post_content.js b/client/views/posts/modules/post_content.js index a513d11fb7..61b5e3cd38 100644 --- a/client/views/posts/modules/post_content.js +++ b/client/views/posts/modules/post_content.js @@ -19,9 +19,10 @@ Template[getTemplate('postContent')].helpers({ return moment(time).format("MMMM Do, h:mm:ss a"); }, userAvatar: function(){ + // THIS FUNCTION IS DEPRECATED -- package bengott:avatar is used instead. var author = Meteor.users.findOne(this.userId, {reactive: false}); if(!!author) - return getAvatarUrl(author); + return getAvatarUrl(author); // ALSO DEPRECATED }, inactiveClass: function(){ return (isAdmin(Meteor.user()) && this.inactive) ? i18n.t('inactive') : ""; diff --git a/client/views/users/user_item.html b/client/views/users/user_item.html index b2cb8525f9..2a0578d5a2 100644 --- a/client/views/users/user_item.html +++ b/client/views/users/user_item.html @@ -1,6 +1,6 @@ \ No newline at end of file + diff --git a/packages/telescope-notifications/lib/client/templates/notification_item.js b/packages/telescope-notifications/lib/client/templates/notification_item.js index 22cddd57e5..e495c47132 100644 --- a/packages/telescope-notifications/lib/client/templates/notification_item.js +++ b/packages/telescope-notifications/lib/client/templates/notification_item.js @@ -3,17 +3,17 @@ Template[getTemplate('notificationItem')].helpers({ return moment(this.timestamp).fromNow(); }, properties: function(){ - return this.properties; + return this.data; }, notificationHTML: function(){ - return buildSiteNotification(this); + return this.message(); } }); Template[getTemplate('notificationItem')].events({ 'click .action-link': function(event, instance){ var notificationId=instance.data._id; - Notifications.update( + Herald.collection.update( {_id: notificationId}, { $set:{ @@ -27,4 +27,4 @@ Template[getTemplate('notificationItem')].events({ } ); } -}); \ No newline at end of file +}); diff --git a/packages/telescope-notifications/lib/client/templates/notification_new_comment.html b/packages/telescope-notifications/lib/client/templates/notification_new_comment.html index de3ee9bd99..8c5d76c340 100644 --- a/packages/telescope-notifications/lib/client/templates/notification_new_comment.html +++ b/packages/telescope-notifications/lib/client/templates/notification_new_comment.html @@ -4,4 +4,4 @@ left a new comment on {{postTitle}}

- \ No newline at end of file + diff --git a/packages/telescope-notifications/lib/client/templates/notification_new_reply.html b/packages/telescope-notifications/lib/client/templates/notification_new_reply.html index 770eef20c6..df90ae3d73 100644 --- a/packages/telescope-notifications/lib/client/templates/notification_new_reply.html +++ b/packages/telescope-notifications/lib/client/templates/notification_new_reply.html @@ -1,7 +1,7 @@ \ No newline at end of file + diff --git a/packages/telescope-notifications/lib/client/templates/notifications_menu.js b/packages/telescope-notifications/lib/client/templates/notifications_menu.js index 8ac0010318..c7a32d814d 100644 --- a/packages/telescope-notifications/lib/client/templates/notifications_menu.js +++ b/packages/telescope-notifications/lib/client/templates/notifications_menu.js @@ -3,13 +3,13 @@ Template[getTemplate('notificationsMenu')].helpers({ return getTemplate('notificationItem'); }, notifications: function(){ - return Notifications.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}); + return Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}); }, hasNotifications: function () { - return !!Notifications.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).count(); + return !!Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).count(); }, notification_count: function(){ - var notifications=Notifications.find({userId: Meteor.userId(), read: false}).fetch(); + var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}).fetch(); if(notifications.length==0){ return i18n.t('No notifications'); }else if(notifications.length==1){ @@ -19,7 +19,7 @@ Template[getTemplate('notificationsMenu')].helpers({ } }, notification_class: function(){ - var notifications=Notifications.find({userId: Meteor.userId(), read: false}).fetch(); + var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}).fetch(); if(notifications.length==0) return 'no-notifications'; } @@ -37,4 +37,4 @@ Template[getTemplate('notificationsMenu')].events({ } ); } -}); \ No newline at end of file +}); diff --git a/packages/telescope-notifications/lib/herald.js b/packages/telescope-notifications/lib/herald.js new file mode 100644 index 0000000000..7d63fda508 --- /dev/null +++ b/packages/telescope-notifications/lib/herald.js @@ -0,0 +1,101 @@ +Herald.collection.deny({ + update: ! can.editById, + remove: ! can.editById +}); + +var commentEmail = function (userToNotify) { + var notification = this; + // put in setTimeout so it doesn't hold up the rest of the method + Meteor.setTimeout(function () { + notificationEmail = buildEmailNotification(notification); + sendEmail(getEmail(userToNotify), notificationEmail.subject, notificationEmail.html); + }, 1); +} + +Herald.addCourier('newPost', { + media: { + email: { + emailRunner: function (user) { + var p = getPostProperties(this.data); + var subject = p.postAuthorName+' has created a new post: '+p.postTitle; + var html = buildEmailTemplate(getEmailTemplate('emailNewPost')(p)); + sendEmail(getEmail(user), subject, html); + } + } + } + // message: function (user) { return 'email template?' } +}); + +Herald.addCourier('newComment', { + media: { + onsite: {}, + email: { + emailRunner: commentEmail + } + }, + message: { + default: function (user) { + return Blaze.toHTML(Blaze.With(this, function(){ + return Template[getTemplate('notificationNewComment')] + })); + } + }, + transform: { + profileUrl: function () { + var user = Meteor.users.findOne(this.data.comment.userId); + if(user) + return getProfileUrl(user); + }, + postCommentUrl: function () { + return '/posts/'+ this.data.post._id; + }, + author: function () { + var user = Meteor.users.findOne(this.data.comment.userId); + if(user) + return getUserName(user); + }, + postTitle: function () { + return this.data.post.title; + }, + url: function () { + return /comments/ + this.comment._id; + } + } +}); + +Herald.addCourier('newReply', { + media: { + onsite: {}, + email: { + emailRunner: commentEmail + } + }, + message: { + default: function (user) { + return Blaze.toHTML(Blaze.With(this, function(){ + return Template[getTemplate('notificationNewReply')] + })); + } + }, + transform: { + profileUrl: function () { + var user = Meteor.users.findOne(this.data.comment.userId); + if(user) + return getProfileUrl(user); + }, + postCommentUrl: function () { + return '/posts/'+ this.data.post._id; + }, + author: function () { + var user = Meteor.users.findOne(this.data.comment.userId); + if(user) + return getUserName(user); + }, + postTitle: function () { + return this.data.post.title; + }, + url: function () { + return /comments/ + this.parentComment._id; + } + } +}); diff --git a/packages/telescope-notifications/lib/notifications.js b/packages/telescope-notifications/lib/notifications.js index fbac625d5d..15e46f2b32 100644 --- a/packages/telescope-notifications/lib/notifications.js +++ b/packages/telescope-notifications/lib/notifications.js @@ -1,111 +1,10 @@ -Notifications = new Meteor.Collection('notifications'); - -// Notifications = new Meteor.Collection("notifications", { -// schema: new SimpleSchema({ -// properties: { -// type: Object -// }, -// event: { -// type: String -// }, -// read: { -// type: Boolean -// }, -// createdAt: { -// type: Date -// }, -// userId: { -// type: "???" -// } -// }) -// }); - -Notifications.allow({ - insert: function(userId, doc){ - // new notifications can only be created via a Meteor method - return false; - }, - update: can.editById, - remove: can.editById -}); - -createNotification = function(event, properties, userToNotify) { - // 1. Store notification in database - var notification = { - timestamp: new Date().getTime(), - userId: userToNotify._id, - event: event, - properties: properties, - read: false - }; - var newNotificationId = Notifications.insert(notification); - - // 2. Send notification by email (if on server) - if(Meteor.isServer && getUserSetting('notifications.replies', false, userToNotify)){ - // put in setTimeout so it doesn't hold up the rest of the method - Meteor.setTimeout(function () { - notificationEmail = buildEmailNotification(notification); - sendEmail(getEmail(userToNotify), notificationEmail.subject, notificationEmail.html); - }, 1); - } -}; - -buildSiteNotification = function (notification) { - var event = notification.event, - comment = notification.properties.comment, - post = notification.properties.post, - userToNotify = Meteor.users.findOne(notification.userId), - template, - html; - - var properties = { - profileUrl: getProfileUrlById(comment.userId), - author: comment.author, - postCommentUrl: getPostCommentUrl(post._id, comment._id), - postTitle: post.title - }; - - switch(event){ - case 'newReply': - template = 'notificationNewReply'; - break; - - case 'newComment': - template = 'notificationNewComment'; - break; - - default: - break; - } - - html = Blaze.toHTML(Blaze.With(properties, function(){ - return Template[getTemplate(template)] - })); - - return html; -}; - -Meteor.methods({ - markAllNotificationsAsRead: function() { - Notifications.update( - {userId: Meteor.userId()}, - { - $set:{ - read: true - } - }, - {multi: true} - ); - } -}); - // add new post notification callback on post submit postAfterSubmitMethodCallbacks.push(function (post) { if(Meteor.isServer && !!getSetting('emailNotifications', false)){ - // we don't want emails to hold up the post submission, so we make the whole thing async with setTimeout - Meteor.setTimeout(function () { - newPostNotification(post, [post.userId]) - }, 1); + var userIds = Meteor.users.find({'profile.notifications.posts': 1}, {fields: {}}).map(function (user) { + return user._id + }); + Herald.createNotification(userIds, {courier: 'newPost', data: post}) } return post; }); @@ -119,7 +18,7 @@ commentAfterSubmitMethodCallbacks.push(function (comment) { var post = Posts.findOne(comment.postId); var postUser = Meteor.users.findOne(post.userId); - var notificationProperties = { + var notificationData = { comment: _.pick(comment, '_id', 'userId', 'author', 'body'), post: _.pick(post, '_id', 'title', 'url') }; @@ -129,25 +28,25 @@ commentAfterSubmitMethodCallbacks.push(function (comment) { var parentComment = Comments.findOne(parentCommentId); var parentUser = Meteor.users.findOne(parentComment.userId); - notificationProperties.parentComment = _.pick(parentComment, '_id', 'userId', 'author'); + notificationData.parentComment = _.pick(parentComment, '_id', 'userId', 'author'); // reply notification // do not notify users of their own actions (i.e. they're replying to themselves) if(parentUser._id != user._id) - createNotification('newReply', notificationProperties, parentUser); + Herald.createNotification(parentUser._id, {courier: 'newReply', data: notificationData}) // comment notification // if the original poster is different from the author of the parent comment, notify them too if(postUser._id != user._id && parentComment.userId != post.userId) - createNotification('newComment', notificationProperties, postUser); + Herald.createNotification(postUser._id, {courier: 'newComment', data: notificationData}) }else{ // root comment // don't notify users of their own comments if(postUser._id != user._id) - createNotification('newComment', notificationProperties, postUser); + Herald.createNotification(postUser._id, {courier: 'newComment', data: notificationData}) } } return comment; -}); \ No newline at end of file +}); diff --git a/packages/telescope-notifications/lib/server/notifications-server.js b/packages/telescope-notifications/lib/server/notifications-server.js index 5ebdb99b01..2aee0d3bc1 100644 --- a/packages/telescope-notifications/lib/server/notifications-server.js +++ b/packages/telescope-notifications/lib/server/notifications-server.js @@ -6,10 +6,10 @@ getUnsubscribeLink = function(user){ buildEmailNotification = function (notification) { var subject, template; - var post = notification.properties.post; - var comment = notification.properties.comment; + var post = notification.data.post; + var comment = notification.data.comment; - switch(notification.event){ + switch(notification.courier){ case 'newReply': subject = 'Someone replied to your comment on "'+post.title+'"'; template = 'emailNewReply'; @@ -24,7 +24,7 @@ buildEmailNotification = function (notification) { break; } - var emailProperties = _.extend(notification.properties, { + var emailProperties = _.extend(notification.data, { body: marked(comment.body), profileUrl: getProfileUrlById(comment.userId), postCommentUrl: getPostCommentUrl(post._id, comment._id), @@ -42,20 +42,6 @@ buildEmailNotification = function (notification) { } }; -newPostNotification = function(post, excludedIDs){ - var excludedIDs = typeof excludedIDs == 'undefined' ? [] : excludedIDs; - var p = getPostProperties(post); - var subject = p.postAuthorName+' has created a new post: '+p.postTitle; - var html = buildEmailTemplate(getEmailTemplate('emailNewPost')(p)); - - // send a notification to every user according to their notifications settings - Meteor.users.find({'profile.notifications.posts': 1}).forEach(function(user) { - // don't send user a notification if their ID is in excludedIDs - if(excludedIDs.indexOf(user._id) == -1) - sendEmail(getEmail(user), subject, html); - }); -}; - Meteor.methods({ unsubscribeUser : function(hash){ // TO-DO: currently, if you have somebody's email you can unsubscribe them diff --git a/packages/telescope-notifications/lib/server/publication.js b/packages/telescope-notifications/lib/server/publication.js deleted file mode 100644 index abe94f2f71..0000000000 --- a/packages/telescope-notifications/lib/server/publication.js +++ /dev/null @@ -1,7 +0,0 @@ -Meteor.publish('notifications', function() { - // only publish notifications belonging to the current user - if(canViewById(this.userId)){ - return Notifications.find({userId:this.userId}); - } - return []; -}); \ No newline at end of file diff --git a/packages/telescope-notifications/package.js b/packages/telescope-notifications/package.js index e12597d4b3..84efcde67f 100644 --- a/packages/telescope-notifications/package.js +++ b/packages/telescope-notifications/package.js @@ -10,13 +10,14 @@ Package.onUse(function (api) { 'telescope-lib', 'telescope-base', 'telescope-email', - 'aldeed:simple-schema' + 'kestanous:herald@0.6.0', + 'kestanous:herald-email@0.2.1' ], ['client', 'server']); api.use([ + 'iron:router', 'jquery', 'underscore', - 'iron:router', 'templating', 'tracker' ], 'client'); @@ -27,10 +28,10 @@ Package.onUse(function (api) { api.add_files([ 'lib/notifications.js', + 'lib/herald.js' ], ['client', 'server']); api.add_files([ - 'lib/client/notifications-client.js', 'lib/client/templates/notification_item.html', 'lib/client/templates/notification_item.js', 'lib/client/templates/notification_new_comment.html', @@ -42,19 +43,14 @@ Package.onUse(function (api) { ], ['client']); api.add_files([ - 'lib/server/notifications-server.js', - 'lib/server/publication.js' + 'lib/server/notifications-server.js' ], ['server']); api.export([ - 'Notifications', - 'createNotification', - 'buildSiteNotification', - 'newPostNotification', + 'Herald', 'buildEmailNotification', - 'getUnsubscribeLink', - 'postSubmitMethodCallbacks' + 'getUnsubscribeLink' ]); }); -// TODO: once user profile edit form is generated dynamically, add notification options from this package as well. \ No newline at end of file +// TODO: once user profile edit form is generated dynamically, add notification options from this package as well. diff --git a/packages/telescope-notifications/versions.json b/packages/telescope-notifications/versions.json index 3b9d0bd5d6..315e170d42 100644 --- a/packages/telescope-notifications/versions.json +++ b/packages/telescope-notifications/versions.json @@ -1,13 +1,13 @@ { "dependencies": [ - [ - "aldeed:simple-schema", - "1.0.3" - ], [ "application-configuration", "1.0.2" ], + [ + "autoupdate", + "1.1.1" + ], [ "base64", "1.0.0" @@ -52,6 +52,10 @@ "ejson", "1.0.3" ], + [ + "fastclick", + "1.0.0" + ], [ "follower-livedata", "1.0.1" @@ -72,6 +76,10 @@ "htmljs", "1.0.1" ], + [ + "http", + "1.0.6" + ], [ "id-map", "1.0.0" @@ -90,7 +98,7 @@ ], [ "iron:router", - "0.9.3" + "0.9.4" ], [ "jquery", @@ -100,6 +108,18 @@ "json", "1.0.0" ], + [ + "kestanous:herald", + "0.6.0" + ], + [ + "kestanous:herald-email", + "0.2.1" + ], + [ + "livedata", + "1.0.10" + ], [ "logging", "1.0.3" @@ -108,6 +128,10 @@ "meteor", "1.1.1" ], + [ + "meteor-platform", + "1.1.1" + ], [ "minifiers", "1.1.0" @@ -116,6 +140,10 @@ "minimongo", "1.0.3" ], + [ + "mobile-status-bar", + "1.0.0" + ], [ "mongo", "1.0.6" @@ -140,6 +168,10 @@ "reactive-var", "1.0.2" ], + [ + "reload", + "1.1.0" + ], [ "retry", "1.0.0" @@ -148,6 +180,10 @@ "routepolicy", "1.0.1" ], + [ + "session", + "1.0.2" + ], [ "spacebars", "1.0.2" @@ -156,6 +192,10 @@ "spacebars-compiler", "1.0.2" ], + [ + "standard-app-packages", + "1.0.2" + ], [ "telescope-base", "0.0.0" @@ -188,6 +228,10 @@ "underscore", "1.0.0" ], + [ + "url", + "1.0.0" + ], [ "webapp", "1.1.2" @@ -198,6 +242,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-rss/versions.json b/packages/telescope-rss/versions.json index cb036c8ae0..bc98eb8d1f 100644 --- a/packages/telescope-rss/versions.json +++ b/packages/telescope-rss/versions.json @@ -86,6 +86,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-search/versions.json b/packages/telescope-search/versions.json index acc0e04eac..ca7e034f99 100644 --- a/packages/telescope-search/versions.json +++ b/packages/telescope-search/versions.json @@ -82,7 +82,7 @@ ], [ "iron:router", - "0.9.3" + "0.9.4" ], [ "jquery", @@ -186,6 +186,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-tags/versions.json b/packages/telescope-tags/versions.json index acc0e04eac..ca7e034f99 100644 --- a/packages/telescope-tags/versions.json +++ b/packages/telescope-tags/versions.json @@ -82,7 +82,7 @@ ], [ "iron:router", - "0.9.3" + "0.9.4" ], [ "jquery", @@ -186,6 +186,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-theme-base/versions.json b/packages/telescope-theme-base/versions.json index cb036c8ae0..bc98eb8d1f 100644 --- a/packages/telescope-theme-base/versions.json +++ b/packages/telescope-theme-base/versions.json @@ -86,6 +86,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-theme-hubble/versions.json b/packages/telescope-theme-hubble/versions.json index cb036c8ae0..bc98eb8d1f 100644 --- a/packages/telescope-theme-hubble/versions.json +++ b/packages/telescope-theme-hubble/versions.json @@ -86,6 +86,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-update-prompt/versions.json b/packages/telescope-update-prompt/versions.json index 4c56f735cb..a481d205f2 100644 --- a/packages/telescope-update-prompt/versions.json +++ b/packages/telescope-update-prompt/versions.json @@ -82,7 +82,7 @@ ], [ "iron:router", - "0.9.3" + "0.9.4" ], [ "jquery", @@ -190,6 +190,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file From 582ee672abdb0394b78fa36268e85ed0ce70e91a Mon Sep 17 00:00:00 2001 From: Charlie DeTar Date: Fri, 3 Oct 2014 15:48:32 -0600 Subject: [PATCH 03/19] Add querystring updates to search Update and parse a "?q=" query string for search to improve cross-site linkability. --- packages/telescope-search/lib/client/routes.js | 9 +++++++-- .../telescope-search/lib/client/views/search.js | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packages/telescope-search/lib/client/routes.js b/packages/telescope-search/lib/client/routes.js index 342806777d..51dce46c9e 100644 --- a/packages/telescope-search/lib/client/routes.js +++ b/packages/telescope-search/lib/client/routes.js @@ -7,7 +7,12 @@ adminNav.push({ Meteor.startup(function () { PostsSearchController = PostsListController.extend({ - view: 'search' + view: 'search', + onBeforeAction: function() { + if ("q" in this.params) { + Session.set("searchQuery", this.params.q); + } + } }); Router.onBeforeAction(Router._filters.isAdmin, {only: ['logs']}); @@ -40,4 +45,4 @@ Meteor.startup(function () { }); -}); \ No newline at end of file +}); diff --git a/packages/telescope-search/lib/client/views/search.js b/packages/telescope-search/lib/client/views/search.js index 51b9f04efd..2e3dee39f3 100644 --- a/packages/telescope-search/lib/client/views/search.js +++ b/packages/telescope-search/lib/client/views/search.js @@ -29,16 +29,24 @@ Meteor.startup(function () { // if search field is empty, just do nothing and show an empty template $search.addClass('empty'); Session.set('searchQuery', ''); + Router.go('/search', null, {replaceState: true}); }else{ // if search field is not empty, add a delay to avoid firing new searches for every keystroke delay(function(){ Session.set('searchQuery', val); $search.removeClass('empty'); - // if we're not already on the search page, go to it - if(getCurrentRoute().indexOf('search') == -1) - Router.go('/search'); + + // Update the querystring. + var opts = {query: 'q=' + encodeURIComponent(val)}; + // if we're already on the search page, do a replaceState. Otherwise, + // just use the pushState default. + if(getCurrentRoute().indexOf('/search') === 0) { + opts.replaceState = true; + } + Router.go('search', null, opts); + }, 700 ); } } }); -}); \ No newline at end of file +}); From ed09d0ea7ce1e05f853072c9d9131d4538832019 Mon Sep 17 00:00:00 2001 From: Charlie DeTar Date: Fri, 3 Oct 2014 16:21:06 -0600 Subject: [PATCH 04/19] Fully abstract isAdmin We're using a fork with a different definition of "isAdmin" (using ``meteor-roles`` rather than the boolean user.isAdmin). ``lib/user.js`` provides abstracted methods for reading admin state, which makes it very easy to change our definition -- except that the abstractions weren't used universally. This commit finishes the job of using the abstractions, and adds a few new parts to also allow abstracting setting and updating admin-ness: - setAdmin: sets admin status directly on a user object. - updateAdmin: executes a mongo update to set admin status. - adminMongoQuery: the query parameter for admin-ness, for composing user queries with other fields. - notAdminMongoQuery: the query parameter for not-admin-ness. --- client/views/comments/comment_item.html | 2 +- client/views/comments/comment_item.js | 2 +- client/views/posts/modules/post_admin.html | 4 ++-- client/views/users/user_item.js | 14 +++----------- lib/parameters.js | 6 +++--- lib/users.js | 7 +++++++ lib/vote.js | 2 +- packages/telescope-search/lib/search.js | 18 ++++++------------ server/users.js | 12 +++++++----- 9 files changed, 31 insertions(+), 36 deletions(-) diff --git a/client/views/comments/comment_item.html b/client/views/comments/comment_item.html index f824561a34..fea23012e3 100644 --- a/client/views/comments/comment_item.html +++ b/client/views/comments/comment_item.html @@ -25,7 +25,7 @@ {{#if can_edit}} | {{i18n "Edit"}} {{/if}} - {{#if currentUser.isAdmin}} + {{#if isAdmin}} | {{full_date}} {{/if}}
diff --git a/client/views/comments/comment_item.js b/client/views/comments/comment_item.js index ef257f3f98..db3c5685fe 100644 --- a/client/views/comments/comment_item.js +++ b/client/views/comments/comment_item.js @@ -81,7 +81,7 @@ Template[getTemplate('comment_item')].helpers({ }, can_edit: function(){ if(this.userId && Meteor.userId()) - return Meteor.user().isAdmin || (Meteor.userId() === this.userId); + return isAdmin(Meteor.user()) || (Meteor.userId() === this.userId); else return false; }, diff --git a/client/views/posts/modules/post_admin.html b/client/views/posts/modules/post_admin.html index 7b41621164..4a236f1bad 100644 --- a/client/views/posts/modules/post_admin.html +++ b/client/views/posts/modules/post_admin.html @@ -1,5 +1,5 @@ \ No newline at end of file + diff --git a/client/views/users/user_item.js b/client/views/users/user_item.js index b2770522a0..a80a1af048 100644 --- a/client/views/users/user_item.js +++ b/client/views/users/user_item.js @@ -44,23 +44,15 @@ Template[getTemplate('user_item')].events({ }, 'click .admin-link': function(e, instance){ e.preventDefault(); - Meteor.users.update(instance.data._id,{ - $set:{ - isAdmin: true - } - }); + updateAdmin(instance.data._id, true); }, 'click .unadmin-link': function(e, instance){ e.preventDefault(); - Meteor.users.update(instance.data._id,{ - $set:{ - isAdmin: false - } - }); + updateAdmin(instance.data._id, false); }, 'click .delete-link': function(e, instance){ e.preventDefault(); if(confirm(i18n.t("Are you sure you want to delete ")+getDisplayName(instance.data)+"?")) Meteor.users.remove(instance.data._id); } -}); \ No newline at end of file +}); diff --git a/lib/parameters.js b/lib/parameters.js index b665a36b9b..c245564b3f 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -41,13 +41,13 @@ getUsersParameters = function(filterBy, sortBy, limit) { switch(filterBy){ case 'invited': // consider admins as invited - find = {$or: [{isInvited: true}, {isAdmin: true}]}; + find = {$or: [{isInvited: true}, adminMongoQuery]}; break; case 'uninvited': - find = {$and: [{isInvited: false}, {isAdmin: false}]}; + find = {$and: [{isInvited: false}, notAdminMongoQuery]}; break; case 'admin': - find = {isAdmin: true}; + find = adminMongoQuery; break; } diff --git a/lib/users.js b/lib/users.js index 2e3fe3fa3c..33e4c6fba1 100644 --- a/lib/users.js +++ b/lib/users.js @@ -6,6 +6,13 @@ isAdmin=function(user){ user = (typeof user === 'undefined') ? Meteor.user() : user; return !!user && !!user.isAdmin; }; +setAdmin = function(user, admin){ + user = (typeof user === 'undefined') ? Meteor.user() : user; + user.isAdmin = !!admin; +}; +updateAdmin = function(userId, admin) { + Meteor.users.update(userId, {$set: {isAdmin: admin}}); +}; isInvited=function(user){ if(!user || typeof user === 'undefined') return false; diff --git a/lib/vote.js b/lib/vote.js index 427152db62..9dbf6088b3 100644 --- a/lib/vote.js +++ b/lib/vote.js @@ -1,7 +1,7 @@ // returns how much "power" a user's votes have var getVotePower = function(user){ - // return (user && user.isAdmin) ? 5 : 1; + // return isAdmin(user) ? 5 : 1; return 1; // for now, leave everybody at 1 including admins; 5 is too unbalanced }; diff --git a/packages/telescope-search/lib/search.js b/packages/telescope-search/lib/search.js index 7597535acc..a900810afc 100644 --- a/packages/telescope-search/lib/search.js +++ b/packages/telescope-search/lib/search.js @@ -16,19 +16,13 @@ Searches = new Meteor.Collection("searches", { }) }); -Searches.allow({ - update: isAdminById -, remove: isAdminById +Meteor.startup(function() { + Searches.allow({ + update: isAdminById + , remove: isAdminById + }); }); -// XXX -// TODO: find a way to make the package use the same isAdminById as the rest of the app -isAdminById=function(userId){ - var user = Meteor.users.findOne(userId); - return !!(user && isAdmin(user)); -}; - - // search post list parameters viewParameters.search = function (terms, baseParameters) { // if query is empty, just return parameters that will result in an empty collection @@ -49,4 +43,4 @@ viewParameters.search = function (terms, baseParameters) { } }); return parameters; -} \ No newline at end of file +} diff --git a/server/users.js b/server/users.js index 72c52086ff..0d9b5b105b 100644 --- a/server/users.js +++ b/server/users.js @@ -3,7 +3,6 @@ Accounts.onCreateUser(function(options, user){ profile: options.profile || {}, karma: 0, isInvited: false, - isAdmin: false, postCount: 0, commentCount: 0, invitedCount: 0, @@ -37,8 +36,11 @@ Accounts.onCreateUser(function(options, user){ user.slug = slugify(getUserName(user)); // if this is the first user ever, make them an admin - if (!Meteor.users.find().count() ) - user.isAdmin = true; + if (!Meteor.users.find().count() ) { + setAdmin(user, true); + } else { + setAdmin(user, false); + } // give new users a few invites (default to 3) user.inviteCount = getSetting('startInvitesCount', 3); @@ -73,7 +75,7 @@ Accounts.onCreateUser(function(options, user){ } // send notifications to admins - var admins = Meteor.users.find({isAdmin: true}); + var admins = adminUsers(); admins.forEach(function(admin){ if(getUserSetting('notifications.users', false, admin)){ var emailProperties = { @@ -113,4 +115,4 @@ Meteor.methods({ var hash = getEmailHash(user); Meteor.users.update(user._id, {$set : {email_hash : hash}}); } -}); \ No newline at end of file +}); From 06227de3c4680e2c462966629ba3612af251489d Mon Sep 17 00:00:00 2001 From: The Gitter Badger Date: Sat, 4 Oct 2014 02:03:29 +0000 Subject: [PATCH 05/19] Added Gitter badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 31586fc988..529eb3a328 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ Telescope is an open-source, real-time social news site built with [Meteor](http Note that Telescope is distributed under the [MIT License](http://opensource.org/licenses/MIT) ### We Need Your Help! +[![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/TelescopeJS/Telescope?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) A lot of work has already gone into Telescope, but it needs that final push to reach its full potential. From f5c4908d1252ffdbe4133c9aa537c382bfb56943 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Sat, 4 Oct 2014 12:51:44 +0900 Subject: [PATCH 06/19] Upgrading to 0.9.3.1 --- .meteor/release | 2 +- History.md | 10 ++++++++++ packages/npm-container/versions.json | 2 +- packages/telescope-api/versions.json | 2 +- packages/telescope-base/versions.json | 2 +- packages/telescope-daily/versions.json | 2 +- packages/telescope-email/versions.json | 2 +- packages/telescope-i18n/versions.json | 2 +- packages/telescope-kadira/versions.json | 2 +- packages/telescope-lib/versions.json | 2 +- packages/telescope-module-embedly/versions.json | 2 +- packages/telescope-module-share/versions.json | 2 +- packages/telescope-newsletter/versions.json | 2 +- packages/telescope-notifications/versions.json | 2 +- packages/telescope-rss/versions.json | 2 +- packages/telescope-search/versions.json | 2 +- packages/telescope-tags/versions.json | 2 +- packages/telescope-theme-base/versions.json | 2 +- packages/telescope-theme-hubble/versions.json | 2 +- packages/telescope-update-prompt/versions.json | 2 +- 20 files changed, 29 insertions(+), 19 deletions(-) diff --git a/.meteor/release b/.meteor/release index 7b32bf7a26..01887b6a68 100644 --- a/.meteor/release +++ b/.meteor/release @@ -1 +1 @@ -METEOR@0.9.3 +METEOR@0.9.3.1 diff --git a/History.md b/History.md index a293e99f72..a48927a1f5 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,13 @@ +## v0.9.8 + +* Fixing #457 (pending posts view not working). +* Added German translation (thanks @Helmi!). +* Added `?q=` parameter to searches (thanks @yourcelf!). +* Abstracting `isAdmin` (thanks @yourcelsf!). +* Refactoring `getPostsParameters` (thanks @delgermurun!). +* Using `bengott:avatar` package for avatars (thanks @bengott!). +* Upgrading to Meteor 0.9.3.1. + ## v0.9.7 “SettingsScope” * Updating to Meteor 0.9.3. diff --git a/packages/npm-container/versions.json b/packages/npm-container/versions.json index b7f39bd426..37c642cee1 100644 --- a/packages/npm-container/versions.json +++ b/packages/npm-container/versions.json @@ -10,6 +10,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-api/versions.json b/packages/telescope-api/versions.json index cb036c8ae0..bc98eb8d1f 100644 --- a/packages/telescope-api/versions.json +++ b/packages/telescope-api/versions.json @@ -86,6 +86,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-base/versions.json b/packages/telescope-base/versions.json index 05bb562a8d..877ccad65f 100644 --- a/packages/telescope-base/versions.json +++ b/packages/telescope-base/versions.json @@ -82,6 +82,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-daily/versions.json b/packages/telescope-daily/versions.json index 1d67f1cc9f..ac94b85e9b 100644 --- a/packages/telescope-daily/versions.json +++ b/packages/telescope-daily/versions.json @@ -210,6 +210,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-email/versions.json b/packages/telescope-email/versions.json index 6a5b991569..8850db53a6 100644 --- a/packages/telescope-email/versions.json +++ b/packages/telescope-email/versions.json @@ -18,6 +18,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-i18n/versions.json b/packages/telescope-i18n/versions.json index f9299181de..0c7046c5e8 100644 --- a/packages/telescope-i18n/versions.json +++ b/packages/telescope-i18n/versions.json @@ -74,6 +74,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-kadira/versions.json b/packages/telescope-kadira/versions.json index 1b81c48973..55cb329f36 100644 --- a/packages/telescope-kadira/versions.json +++ b/packages/telescope-kadira/versions.json @@ -154,6 +154,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-lib/versions.json b/packages/telescope-lib/versions.json index e280ee124d..ffca2b0652 100644 --- a/packages/telescope-lib/versions.json +++ b/packages/telescope-lib/versions.json @@ -14,6 +14,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-module-embedly/versions.json b/packages/telescope-module-embedly/versions.json index 8e02619562..7ae2abf589 100644 --- a/packages/telescope-module-embedly/versions.json +++ b/packages/telescope-module-embedly/versions.json @@ -98,6 +98,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-module-share/versions.json b/packages/telescope-module-share/versions.json index 2ec1b9a95c..e2d4c37488 100644 --- a/packages/telescope-module-share/versions.json +++ b/packages/telescope-module-share/versions.json @@ -90,6 +90,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-newsletter/versions.json b/packages/telescope-newsletter/versions.json index 878157c6f1..ca353f4d10 100644 --- a/packages/telescope-newsletter/versions.json +++ b/packages/telescope-newsletter/versions.json @@ -214,6 +214,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-notifications/versions.json b/packages/telescope-notifications/versions.json index 3b9d0bd5d6..701a01dc81 100644 --- a/packages/telescope-notifications/versions.json +++ b/packages/telescope-notifications/versions.json @@ -198,6 +198,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-rss/versions.json b/packages/telescope-rss/versions.json index cb036c8ae0..bc98eb8d1f 100644 --- a/packages/telescope-rss/versions.json +++ b/packages/telescope-rss/versions.json @@ -86,6 +86,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-search/versions.json b/packages/telescope-search/versions.json index acc0e04eac..f536bd5f6a 100644 --- a/packages/telescope-search/versions.json +++ b/packages/telescope-search/versions.json @@ -186,6 +186,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-tags/versions.json b/packages/telescope-tags/versions.json index acc0e04eac..f536bd5f6a 100644 --- a/packages/telescope-tags/versions.json +++ b/packages/telescope-tags/versions.json @@ -186,6 +186,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-theme-base/versions.json b/packages/telescope-theme-base/versions.json index cb036c8ae0..bc98eb8d1f 100644 --- a/packages/telescope-theme-base/versions.json +++ b/packages/telescope-theme-base/versions.json @@ -86,6 +86,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-theme-hubble/versions.json b/packages/telescope-theme-hubble/versions.json index cb036c8ae0..bc98eb8d1f 100644 --- a/packages/telescope-theme-hubble/versions.json +++ b/packages/telescope-theme-hubble/versions.json @@ -86,6 +86,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file diff --git a/packages/telescope-update-prompt/versions.json b/packages/telescope-update-prompt/versions.json index 4c56f735cb..7ae03089f5 100644 --- a/packages/telescope-update-prompt/versions.json +++ b/packages/telescope-update-prompt/versions.json @@ -190,6 +190,6 @@ ] ], "pluginDependencies": [], - "toolVersion": "meteor-tool@1.0.32", + "toolVersion": "meteor-tool@1.0.33", "format": "1.0" } \ No newline at end of file From 73d1098646b45b943fb0f4f97c241ef77e896399 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Sun, 5 Oct 2014 10:12:10 +0900 Subject: [PATCH 07/19] Make it possible to hide fields from quickform; cleanup --- client/views/settings/quickFormSettings.html | 20 +-- client/views/settings/quickFormSettings.js | 121 ++++++++++--------- 2 files changed, 73 insertions(+), 68 deletions(-) diff --git a/client/views/settings/quickFormSettings.html b/client/views/settings/quickFormSettings.html index 2c18986d97..04e9e0aef4 100644 --- a/client/views/settings/quickFormSettings.html +++ b/client/views/settings/quickFormSettings.html @@ -27,16 +27,18 @@

{{this}}