From 8c655d55bf26621d3843fcb03c885399a9034732 Mon Sep 17 00:00:00 2001 From: Tarang Patel Date: Mon, 11 Nov 2013 23:19:32 +0200 Subject: [PATCH 01/25] Use cursor to iterate lists of users --- server/notifications.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/notifications.js b/server/notifications.js index b6acafe4d..a9b2e742b 100644 --- a/server/notifications.js +++ b/server/notifications.js @@ -53,11 +53,11 @@ Meteor.methods({ }, notifyUsers : function(notification, currentUser){ // send a notification to every user according to their notifications settings - _.each(Meteor.users.find().fetch(), function(user, index, list){ + Meteor.users.find().forEach(function(user) { if(user._id !== currentUser._id && getUserSetting('notifications.posts', false, user)){ // don't send users notifications for their own posts sendEmail(getEmail(user), notification.subject, notification.text, notification.html); } }); } -}); \ No newline at end of file +}); From 20305d9b77ae0ab1ceb204bc298b61bfc264d838 Mon Sep 17 00:00:00 2001 From: Ry Walker Date: Mon, 11 Nov 2013 16:25:47 -0500 Subject: [PATCH 02/25] Fix subscription for spiderable --- server/publications.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/publications.js b/server/publications.js index cdb356f47..ddd3c93c2 100644 --- a/server/publications.js +++ b/server/publications.js @@ -81,8 +81,11 @@ Meteor.publish('allUsers', function(find, options) { // TODO: find a better way Meteor.publish('allUsersAdmin', function() { - if (isAdminById(this.userId)) - return Meteor.users.find(); + if (isAdminById(this.userId)) { + return Meteor.users.find(); + } else { + this.stop(); + } }); // -------------------------------------------- Posts -------------------------------------------- // @@ -160,4 +163,4 @@ Meteor.publish('categories', function() { if(canViewById(this.userId)){ return Categories.find(); } -}); \ No newline at end of file +}); From 050ca1ba15f90113eaa6b855673b757d0c4da334 Mon Sep 17 00:00:00 2001 From: Ry Walker Date: Mon, 11 Nov 2013 16:29:40 -0500 Subject: [PATCH 03/25] Use higher quality gravatar image --- lib/users.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/users.js b/lib/users.js index d53767098..7e53c2e58 100644 --- a/lib/users.js +++ b/lib/users.js @@ -67,7 +67,7 @@ getAvatarUrl = function(user){ }else{ return Gravatar.getGravatar(user, { d: 'http://demo.telesc.pe/img/default_avatar.png', - s: 30 + s: 80 }); } } @@ -115,4 +115,4 @@ getProperty = function(object, property){ // else return property return object[array[0]]; } -} \ No newline at end of file +} From fa4e7dbc49259137532b9e4d5d08625d5d2ab236 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Tue, 12 Nov 2013 19:05:59 +0900 Subject: [PATCH 04/25] syntax fix --- lib/scoring.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scoring.js b/lib/scoring.js index 6c0a11ae6..0ee72b9d2 100644 --- a/lib/scoring.js +++ b/lib/scoring.js @@ -1,4 +1,4 @@ -updateScore = function (item, collection, forceUpdate) { +updateScore = function (collection, item, forceUpdate) { var forceUpdate = typeof forceUpdate !== 'undefined' ? forceUpdate : false; // For performance reasons, the database is only updated if the difference between the old score and the new score // is meaningful enough. To find out, we calculate the "power" of a single vote after n days. From 0ea12ec96f07f9c663f171fd58b06fe00de1f123 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Thu, 14 Nov 2013 10:04:11 +0900 Subject: [PATCH 05/25] do not try to add user to mailchimp list if they don't have an email --- client/helpers/router.js | 1 - client/views/users/user_email.js | 19 ++++++------------- server/users.js | 7 +++++-- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/client/helpers/router.js b/client/helpers/router.js index 6f4963a3d..1c0a67ae4 100644 --- a/client/helpers/router.js +++ b/client/helpers/router.js @@ -174,7 +174,6 @@ var filters = { hasCompletedProfile: function() { var user = Meteor.user(); if (user && ! Meteor.loggingIn() && ! userProfileComplete(user)){ - // Session.set('selectedUserId', user._id); this.render('user_email'); this.stop(); } diff --git a/client/views/users/user_email.js b/client/views/users/user_email.js index 8c139cd1c..bf08985b9 100644 --- a/client/views/users/user_email.js +++ b/client/views/users/user_email.js @@ -1,3 +1,9 @@ +Template.user_email.helpers({ + user: function(){ + return Meteor.user(); + } +}); + Template.user_email.events = { 'submit form': function(e){ e.preventDefault(); @@ -26,16 +32,3 @@ Template.user_email.events = { } }; - -Template.user_email.profileIncomplete = function() { - return Meteor.user() && !this.loading && !userProfileComplete(this); -} - -Template.user_email.user = function(){ - var current_user=Meteor.user(); - if(Session.get('selectedUserId') && !current_user.loading && current_user.isAdmin){ - return Meteor.users.findOne(Session.get('selectedUserId')); - }else{ - return current_user; - } -} \ No newline at end of file diff --git a/server/users.js b/server/users.js index f59c39e74..4dc0dc6bb 100644 --- a/server/users.js +++ b/server/users.js @@ -4,6 +4,8 @@ Accounts.onCreateUser(function(options, user){ // users start pending and need to be invited user.isInvited = false; user.isAdmin = false; + user.postCount = 0; + user.commentCount = 0; if (options.email) user.profile.email = options.email; @@ -26,8 +28,9 @@ Accounts.onCreateUser(function(options, user){ trackEvent('new user', {username: user.username, email: user.profile.email}); - // add new user to MailChimp list - addToMailChimpList(user); + // if user has already filled in their email, add them to MailChimp list + if(user.profile.email) + addToMailChimpList(user); return user; }); From ad9bea13edae7a95b357559b920dd28ba5da3673 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Thu, 14 Nov 2013 10:49:37 +0900 Subject: [PATCH 06/25] refactored invites and user dashboard a bit --- client/sass/modules/_users.scss | 11 ++++++++++- client/stylesheets/screen.css | 22 +++++++++++++++------ client/views/users/user_edit.html | 2 +- client/views/users/user_edit.js | 2 +- client/views/users/user_item.html | 29 +++++++++++++++++++++++----- client/views/users/user_item.js | 6 +++++- client/views/users/user_profile.html | 4 ++-- client/views/users/user_profile.js | 5 +++-- client/views/users/users.html | 9 +++++---- lib/parameters.js | 2 ++ server/invites.js | 8 +++----- server/publications.js | 2 +- server/toolbox.js | 2 +- server/users.js | 21 +++++++++++--------- 14 files changed, 86 insertions(+), 39 deletions(-) diff --git a/client/sass/modules/_users.scss b/client/sass/modules/_users.scss index 06561dd6f..87f020b00 100644 --- a/client/sass/modules/_users.scss +++ b/client/sass/modules/_users.scss @@ -3,13 +3,16 @@ background: $lightest-grey; @include border-radius(3px); padding: 8px 15px; - font-size: 14px; + font-size: 13px; a, span{ display: inline-block; margin-right: 20px; &.active{ border-bottom: 2px solid $blue; } + &:last-child{ + margin-right: 0; + } } .filter{ float: left; @@ -54,4 +57,10 @@ table{ } } +} +.user-table{ + font-size: 13px; + tr{ + border-bottom: 1px solid #eee; + } } \ No newline at end of file diff --git a/client/stylesheets/screen.css b/client/stylesheets/screen.css index d4521ab10..fb6e8ae40 100644 --- a/client/stylesheets/screen.css +++ b/client/stylesheets/screen.css @@ -1621,7 +1621,7 @@ input[type="submit"], button, .button, .auth-buttons #login-buttons #login-butto -o-border-radius: 3px; border-radius: 3px; padding: 8px 15px; - font-size: 14px; } + font-size: 13px; } /* line 3, ../sass/partials/_mixins.scss */ .filter-sort:before, .filter-sort:after { content: ""; @@ -1636,14 +1636,17 @@ input[type="submit"], button, .button, .auth-buttons #login-buttons #login-butto /* line 10, ../sass/modules/_users.scss */ .filter-sort a.active, .filter-sort span.active { border-bottom: 2px solid #7ac0e4; } - /* line 14, ../sass/modules/_users.scss */ + /* line 13, ../sass/modules/_users.scss */ + .filter-sort a:last-child, .filter-sort span:last-child { + margin-right: 0; } + /* line 17, ../sass/modules/_users.scss */ .filter-sort .filter { float: left; } - /* line 17, ../sass/modules/_users.scss */ + /* line 20, ../sass/modules/_users.scss */ .filter-sort .sort { float: right; } -/* line 24, ../sass/modules/_users.scss */ +/* line 27, ../sass/modules/_users.scss */ .user-list .user .user-avatar, .user-table .user .user-avatar { height: 30px; width: 30px; @@ -1655,13 +1658,20 @@ input[type="submit"], button, .button, .auth-buttons #login-buttons #login-butto -o-border-radius: 30px; border-radius: 30px; } -/* line 38, ../sass/modules/_users.scss */ +/* line 41, ../sass/modules/_users.scss */ table tr td { padding: 10px; } -/* line 44, ../sass/modules/_users.scss */ +/* line 47, ../sass/modules/_users.scss */ table thead tr td { font-weight: bold; } +/* line 61, ../sass/modules/_users.scss */ +.user-table { + font-size: 13px; } + /* line 63, ../sass/modules/_users.scss */ + .user-table tr { + border-bottom: 1px solid #eee; } + /* line 2, ../sass/modules/_user-profile.scss */ .user-profile .user-avatar { height: 80px; diff --git a/client/views/users/user_edit.html b/client/views/users/user_edit.html index 15512d444..53da15c2c 100644 --- a/client/views/users/user_edit.html +++ b/client/views/users/user_edit.html @@ -83,7 +83,7 @@

Invites

- +
{{/if}} diff --git a/client/views/users/user_edit.js b/client/views/users/user_edit.js index e74039dea..77111b4b0 100644 --- a/client/views/users/user_edit.js +++ b/client/views/users/user_edit.js @@ -49,7 +49,7 @@ Template.user_edit.events = { "profile.notifications.posts": $('input[name=notifications_posts]:checked').length, "profile.notifications.comments": $('input[name=notifications_comments]:checked').length, "profile.notifications.replies": $('input[name=notifications_replies]:checked').length, - "invitesCount": parseInt($target.find('[name=invitesCount]').val()) + "inviteCount": parseInt($target.find('[name=inviteCount]').val()) }; var old_password = $target.find('[name=old_password]').val(); diff --git a/client/views/users/user_item.html b/client/views/users/user_item.html index 7d0278bd0..f1c291975 100644 --- a/client/views/users/user_item.html +++ b/client/views/users/user_item.html @@ -1,14 +1,33 @@ \ No newline at end of file diff --git a/client/views/users/user_item.js b/client/views/users/user_item.js index 091bc4f82..40d782eec 100644 --- a/client/views/users/user_item.js +++ b/client/views/users/user_item.js @@ -20,11 +20,15 @@ Template.user_item.helpers({ userIsAdmin: function(){ return isAdmin(this); }, - profileUrl: function () { + getProfileUrl: function () { return getProfileUrl(this); }, getKarma: function() { return Math.round(100*this.karma)/100; + }, + getInvitedUserProfileUrl: function () { + var user = Meteor.users.findOne(this.invitedId); + return getProfileUrl(user); } }); diff --git a/client/views/users/user_profile.html b/client/views/users/user_profile.html index c03d8662b..381ab37d8 100644 --- a/client/views/users/user_profile.html +++ b/client/views/users/user_profile.html @@ -41,8 +41,8 @@ Edit profile {{/if}} {{#if canInvite}} - {{#if invitesCount}} - Invite ({{invitesCount}} left) + {{#if inviteCount}} + Invite ({{inviteCount}} left) {{else}} Invite (none left) {{/if}} diff --git a/client/views/users/user_profile.js b/client/views/users/user_profile.js index bb3bb5f15..ca8604889 100644 --- a/client/views/users/user_profile.js +++ b/client/views/users/user_profile.js @@ -13,8 +13,8 @@ Template.user_profile.helpers({ // if the user is logged in, the target user hasn't been invited yet, invites are enabled, and user is not viewing their own profile return Meteor.user() && Meteor.user()._id != this._id && !isInvited(this) && invitesEnabled() && canInvite(Meteor.user()); }, - invitesCount: function() { - return Meteor.user().invitesCount; + inviteCount: function() { + return Meteor.user().inviteCount; }, getTwitterName: function () { return getTwitterName(this); @@ -27,5 +27,6 @@ Template.user_profile.helpers({ Template.user_profile.events({ 'click .invite-link': function(e, instance){ Meteor.call('inviteUser', instance.data.user._id); + throwError('Thanks, user has been invited.') } }); \ No newline at end of file diff --git a/client/views/users/users.html b/client/views/users/users.html index 53a9ac43f..25e611d6d 100644 --- a/client/views/users/users.html +++ b/client/views/users/users.html @@ -17,6 +17,7 @@ Username Posts Comments + InvitedCount

@@ -24,13 +25,13 @@ - - - - + + + + diff --git a/lib/parameters.js b/lib/parameters.js index 8d5b8e45c..e10cbebe0 100644 --- a/lib/parameters.js +++ b/lib/parameters.js @@ -99,6 +99,8 @@ getUsersParameters = function(filterBy, sortBy, limit) { break; case 'commentCount': sort = {commentCount: -1}; + case 'invitedCount': + sort = {invitedCount: -1}; } return { find: find, diff --git a/server/invites.js b/server/invites.js index 41f08b60e..7292f314b 100644 --- a/server/invites.js +++ b/server/invites.js @@ -1,21 +1,19 @@ Meteor.methods({ inviteUser: function (userId) { - var currentUser = Meteor.user(); var invitedUser = Meteor.users.findOne(userId); var invite = { - invited: invitedUser._id, + invitedId: invitedUser._id, invitedName: getDisplayName(invitedUser), time: new Date() }; // if the current user is logged in, still has available invites and is himself invited (or an admin), and the target user is not invited - if(currentUser && currentUser.invitesCount > 0 && canInvite(currentUser) && !isInvited(invitedUser)){ + if(currentUser && currentUser.inviteCount > 0 && canInvite(currentUser) && !isInvited(invitedUser)){ // update invinting user - Meteor.users.update(Meteor.userId(), {$inc:{invitesCount: -1}}); - Meteor.users.update(Meteor.userId(), {$push:{invites: invite}}); + Meteor.users.update(Meteor.userId(), {$inc:{inviteCount: -1}, $inc:{invitedCount: 1}, $push:{invites: invite}}); // update invited user Meteor.users.update(userId, {$set: { diff --git a/server/publications.js b/server/publications.js index 459144752..8cb44757a 100644 --- a/server/publications.js +++ b/server/publications.js @@ -3,7 +3,7 @@ var privacyOptions = { // false means private isAdmin: false, emails: false, notifications: false, - invitesCount: false, + inviteCount: false, 'profile.email': false, 'services.twitter.accessToken': false, 'services.twitter.accessTokenSecret': false, diff --git a/server/toolbox.js b/server/toolbox.js index 7c5787593..9455a6aaf 100644 --- a/server/toolbox.js +++ b/server/toolbox.js @@ -14,7 +14,7 @@ Meteor.methods({ }, giveInvites: function () { if(isAdmin(Meteor.user())) - Meteor.users.update({}, {$inc:{invitesCount: 1}}, {multi:true}); + Meteor.users.update({}, {$inc:{inviteCount: 1}}, {multi:true}); }, updateUserProfiles: function () { console.log('//--------------------------//\nUpdating user profiles…') diff --git a/server/users.js b/server/users.js index 4dc0dc6bb..aa4f8aa8d 100644 --- a/server/users.js +++ b/server/users.js @@ -1,12 +1,15 @@ Accounts.onCreateUser(function(options, user){ - user.profile = options.profile || {}; - user.karma = 0; - // users start pending and need to be invited - user.isInvited = false; - user.isAdmin = false; - user.postCount = 0; - user.commentCount = 0; - + var userProperties = { + profile: options.profile || {}, + karma: 0, + isInvited: false, + isAdmin: false, + postCount: 0, + commentCount: 0, + invitedCount: 0 + } + user = _.extend(user, userProperties); + if (options.email) user.profile.email = options.email; @@ -24,7 +27,7 @@ Accounts.onCreateUser(function(options, user){ user.isAdmin = true; // give new users a few invites (default to 3) - user.invitesCount = getSetting('startInvitesCount', 3); + user.inviteCount = getSetting('startInvitesCount', 3); trackEvent('new user', {username: user.username, email: user.profile.email}); From 1b75b37e4abfcf7c4f0a354537183a6470341675 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Fri, 15 Nov 2013 11:50:57 +0900 Subject: [PATCH 07/25] return empty cursors when user cannot view --- client/helpers/router.js | 4 +++- server/publications.js | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/client/helpers/router.js b/client/helpers/router.js index 1c0a67ae4..eb7dafbd4 100644 --- a/client/helpers/router.js +++ b/client/helpers/router.js @@ -139,7 +139,9 @@ var filters = { }, canView: function() { + console.log('canview?') if(Session.get('settingsLoaded') && !canView()){ + console.log('cannot view') this.render('no_rights'); this.stop(); } @@ -208,9 +210,9 @@ Router.before(filters.nProgressHook, {only: [ 'all-users' ]}); +Router.before(filters.canView); Router.before(filters.hasCompletedProfile); Router.before(filters.isLoggedIn, {only: ['comment_reply','post_submit']}); -Router.before(filters.canView); Router.before(filters.isLoggedOut, {only: ['signin', 'signup']}); Router.before(filters.canPost, {only: ['posts_pending', 'comment_reply', 'post_submit']}); Router.before(filters.canEditPost, {only: ['post_edit']}); diff --git a/server/publications.js b/server/publications.js index 8cb44757a..530ad6954 100644 --- a/server/publications.js +++ b/server/publications.js @@ -31,6 +31,7 @@ Meteor.publish('singleUser', function(userIdOrSlug) { // if we find something when treating the argument as an ID, return that; else assume it's a slug return findById.count() ? findById : findBySlug; } + return []; }); // Publish authors of the current post and its comments @@ -51,6 +52,7 @@ Meteor.publish('postUsers', function(postId) { return Meteor.users.find({_id: {$in: users}}, {fields: privacyOptions}); } + return []; }); // Publish author of the current comment @@ -60,6 +62,7 @@ Meteor.publish('commentUser', function(commentId) { var comment = Comments.findOne(commentId); return Meteor.users.find({_id: comment && comment.userId}, {fields: privacyOptions}); } + return []; }); // Publish all the users that have posted the currently displayed list of posts @@ -70,6 +73,7 @@ Meteor.publish('postsListUsers', function(find, options) { var userIds = _.pluck(posts.fetch(), 'userId'); return Meteor.users.find({_id: {$in: userIds}}, {fields: privacyOptions, multi: true}); } + return []; }); // Publish all users @@ -80,6 +84,7 @@ Meteor.publish('allUsers', function(find, options) { options = _.extend(options, {fields: privacyOptions}); return Meteor.users.find(find, options); } + return []; }); // publish all users for admins to make autocomplete work @@ -89,7 +94,7 @@ Meteor.publish('allUsersAdmin', function() { if (isAdminById(this.userId)) { return Meteor.users.find(); } else { - this.stop(); + return []; } }); @@ -101,6 +106,7 @@ Meteor.publish('singlePost', function(id) { if(canViewById(this.userId)){ return Posts.find(id); } + return []; }); // Publish the post related to the current comment @@ -110,6 +116,7 @@ Meteor.publish('commentPost', function(commentId) { var comment = Comments.findOne(commentId); return Posts.find({_id: comment && comment.post}); } + return []; }); // Publish a list of posts @@ -129,6 +136,7 @@ Meteor.publish('postsList', function(find, options) { return posts; } + return []; }); @@ -141,6 +149,7 @@ Meteor.publish('postComments', function(postId) { if(canViewById(this.userId)){ return Comments.find({post: postId}); } + return []; }); // Publish a single comment @@ -149,12 +158,16 @@ Meteor.publish('singleComment', function(commentId) { if(canViewById(this.userId)){ return Comments.find(commentId); } + return []; }); // -------------------------------------------- Other -------------------------------------------- // Meteor.publish('settings', function() { - return Settings.find(); + return Settings.find({}, {fields:{ + mailChimpAPIKey: false, + mailChimpListId: false + }}); }); Meteor.publish('notifications', function() { @@ -162,10 +175,12 @@ Meteor.publish('notifications', function() { if(canViewById(this.userId)){ return Notifications.find({userId:this.userId}); } + return []; }); Meteor.publish('categories', function() { if(canViewById(this.userId)){ return Categories.find(); } + return []; }); From f5238d4fb72f29e696f48a8efa1b6799d6a9a057 Mon Sep 17 00:00:00 2001 From: Ry Walker Date: Thu, 14 Nov 2013 22:16:18 -0500 Subject: [PATCH 08/25] Whitespace --- client/views/common/nav.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/views/common/nav.html b/client/views/common/nav.html index a5ebc90e8..13012012c 100644 --- a/client/views/common/nav.html +++ b/client/views/common/nav.html @@ -2,7 +2,7 @@
Menu - + - + {{#if logo_url}}

@@ -47,13 +47,13 @@ {{else}}

{{site_title}}

{{/if}} - + {{#if canView}} {{/if}} - +
{{loginButtons align="right"}}
From 377f5704ef7552dd69f2351ac3382f1b19bae7dd Mon Sep 17 00:00:00 2001 From: Ry Walker Date: Thu, 14 Nov 2013 23:01:59 -0500 Subject: [PATCH 09/25] Basic search working --- client/helpers/router.js | 2 +- client/sass/modules/_header.scss | 11 +++++++++-- client/sass/screen.scss | 2 +- client/stylesheets/screen.css | 7 +++++++ client/views/common/nav.html | 3 +++ client/views/common/nav.js | 16 ++++++++++++++-- packages/iron-router | 2 +- server/publications.js | 11 +++++++++-- 8 files changed, 45 insertions(+), 9 deletions(-) diff --git a/client/helpers/router.js b/client/helpers/router.js index eb7dafbd4..a0857352d 100644 --- a/client/helpers/router.js +++ b/client/helpers/router.js @@ -246,7 +246,7 @@ PostsListController = RouteController.extend({ // note: most of the time this.params.slug will be empty var parameters = getParameters(view, limit, this.params.slug); return [ - Meteor.subscribe('postsList', parameters.find, parameters.options), + Meteor.subscribe('postsList', parameters.find, parameters.options, Session.get("query")), Meteor.subscribe('postsListUsers', parameters.find, parameters.options) ] }, diff --git a/client/sass/modules/_header.scss b/client/sass/modules/_header.scss index 320d6c794..5313b7066 100644 --- a/client/sass/modules/_header.scss +++ b/client/sass/modules/_header.scss @@ -112,7 +112,7 @@ height:26px; margin-right:10px; cursor:pointer; - color:white; + color:white; &:before{ color:white(0.5); content:"Welcome, "; @@ -136,6 +136,13 @@ >li{ @include horizontal-list-item; margin-right:10px; + input#search { + padding: 4px; + margin-top: -2px; + border-radius: 4px; + border: 0px; + width: 150px; + } >a{ color:white; font-size:16px; @@ -153,4 +160,4 @@ } } } -} \ No newline at end of file +} diff --git a/client/sass/screen.scss b/client/sass/screen.scss index c22dd0d76..9b9ea7685 100644 --- a/client/sass/screen.scss +++ b/client/sass/screen.scss @@ -34,4 +34,4 @@ @import "partials/mobile"; @import "themes/default"; -@import "themes/telescope"; \ No newline at end of file +@import "themes/telescope"; diff --git a/client/stylesheets/screen.css b/client/stylesheets/screen.css index fb6e8ae40..cfb4d9739 100644 --- a/client/stylesheets/screen.css +++ b/client/stylesheets/screen.css @@ -803,6 +803,13 @@ body.pageslide-open { .nav:after { clear: both; } /* line 136, ../sass/modules/_header.scss */ + .nav input#search { + padding: 4px; + margin-top: -2px; + border-radius: 4px; + border: 0px; + width: 150px; + } .nav > li { list-style-image: none; list-style-type: none; diff --git a/client/views/common/nav.html b/client/views/common/nav.html index 13012012c..7a130bec6 100644 --- a/client/views/common/nav.html +++ b/client/views/common/nav.html @@ -36,6 +36,9 @@ {{/if}} +
  • + +
  • {{#if logo_url}} diff --git a/client/views/common/nav.js b/client/views/common/nav.js index cbc37cf3b..f3a404edb 100644 --- a/client/views/common/nav.js +++ b/client/views/common/nav.js @@ -6,14 +6,23 @@ Template.nav.events = { 'click #mobile-menu': function(event){ event.preventDefault(); $('body').toggleClass('mobile-nav-open'); - }, + }, 'click .login-header': function(e){ e.preventDefault(); Router.go('/account'); + }, + 'keyup #search': function(e){ + e.preventDefault(); + Session.set('query', $(e.target).val()); } }; +Template.nav.preserve({ + 'input#search': function (node) { return node.id; } +}); + Template.nav.rendered=function(){ + if(!Meteor.user()){ $('.login-link-text').text("Sign Up/Sign In"); }else{ @@ -58,5 +67,8 @@ Template.nav.helpers({ }, categoryLink: function () { return getCategoryUrl(this.slug); + }, + query: function () { + return Session.get("query"); } -}); \ No newline at end of file +}); diff --git a/packages/iron-router b/packages/iron-router index b829b0dbb..8fcd7873e 120000 --- a/packages/iron-router +++ b/packages/iron-router @@ -1 +1 @@ -/Users/sacha/.meteorite/packages/iron-router/EventedMind/iron-router/4e1ee0581d68bff422a915dacb0bd30eae10fe08 \ No newline at end of file +/Users/ry/.meteorite/packages/iron-router/EventedMind/iron-router/4e1ee0581d68bff422a915dacb0bd30eae10fe08 \ No newline at end of file diff --git a/server/publications.js b/server/publications.js index 530ad6954..a39ec4b1b 100644 --- a/server/publications.js +++ b/server/publications.js @@ -121,10 +121,17 @@ Meteor.publish('commentPost', function(commentId) { // Publish a list of posts -Meteor.publish('postsList', function(find, options) { +Meteor.publish('postsList', function(find, options, query) { if(canViewById(this.userId)){ options = options || {}; - var posts = Posts.find(find, options); + if (query){ + var posts = Posts.find({$or: [ + {headline: {$regex: query, $options: 'i'}}, + {body: {$regex: query, $options: 'i'}} + ]}, options); + } else { + var posts = Posts.find(find, options); + } // console.log('//-------- Subscription Parameters:'); // console.log(find); From d78bc35fb263bb99527aafe9f4f9715072e08817 Mon Sep 17 00:00:00 2001 From: Ry Walker Date: Thu, 14 Nov 2013 23:14:26 -0500 Subject: [PATCH 10/25] Add URL too --- server/publications.js | 1 + 1 file changed, 1 insertion(+) diff --git a/server/publications.js b/server/publications.js index a39ec4b1b..165aad3ac 100644 --- a/server/publications.js +++ b/server/publications.js @@ -127,6 +127,7 @@ Meteor.publish('postsList', function(find, options, query) { if (query){ var posts = Posts.find({$or: [ {headline: {$regex: query, $options: 'i'}}, + {url: {$regex: query, $options: 'i'}}, {body: {$regex: query, $options: 'i'}} ]}, options); } else { From d8c31b7f623d8b3523a55406489296930d6d1bdb Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Fri, 15 Nov 2013 15:29:39 +0900 Subject: [PATCH 11/25] css tweaks --- History.md | 4 ++ client/helpers/router.js | 1 - client/sass/modules/_header.scss | 50 +++++++++++++++++--- client/stylesheets/screen.css | 58 +++++++++++++++++++---- client/views/common/nav.html | 21 ++++++--- client/views/common/nav.js | 81 +++++++++++++++++++------------- packages/iron-router | 2 +- 7 files changed, 159 insertions(+), 58 deletions(-) diff --git a/History.md b/History.md index 2320702c8..6c28a9fc4 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,7 @@ +## v0.7.2 + +* Added basic search (thanks Ry!) + ## v0.7.1 * Added karma redistribution. diff --git a/client/helpers/router.js b/client/helpers/router.js index a0857352d..00615ce6a 100644 --- a/client/helpers/router.js +++ b/client/helpers/router.js @@ -139,7 +139,6 @@ var filters = { }, canView: function() { - console.log('canview?') if(Session.get('settingsLoaded') && !canView()){ console.log('cannot view') this.render('no_rights'); diff --git a/client/sass/modules/_header.scss b/client/sass/modules/_header.scss index 5313b7066..f60a78d6e 100644 --- a/client/sass/modules/_header.scss +++ b/client/sass/modules/_header.scss @@ -136,13 +136,7 @@ >li{ @include horizontal-list-item; margin-right:10px; - input#search { - padding: 4px; - margin-top: -2px; - border-radius: 4px; - border: 0px; - width: 150px; - } + >a{ color:white; font-size:16px; @@ -161,3 +155,45 @@ } } } +.search{ + position: relative; + .search-field{ + font-size: 14px; + padding: 4px 12px; + line-height: 1.3; + border-radius: 20px; + border: 0px; + width: 100px; + background: white; + &:focus{ + outline:none; + } + } + .search-clear{ + display: block; + background: black(0.15); + @include border-radius(50%); + font-weight: bold; + position: absolute; + right: 5px; + top: 50%; + margin-top: -9px; + font-size: 12px; + height: 16px; + width: 16px; + text-align: center; + line-height: 16px; + z-index: 1000; + } + &.empty{ + .search-field{ + background: white(0.1); + &:focus{ + background: white; + } + } + .search-clear{ + display: none; + } + } +} \ No newline at end of file diff --git a/client/stylesheets/screen.css b/client/stylesheets/screen.css index cfb4d9739..f6800222c 100644 --- a/client/stylesheets/screen.css +++ b/client/stylesheets/screen.css @@ -803,13 +803,6 @@ body.pageslide-open { .nav:after { clear: both; } /* line 136, ../sass/modules/_header.scss */ - .nav input#search { - padding: 4px; - margin-top: -2px; - border-radius: 4px; - border: 0px; - width: 150px; - } .nav > li { list-style-image: none; list-style-type: none; @@ -829,20 +822,65 @@ body.pageslide-open { /* line 50, ../../../../.rvm/gems/ruby-1.9.3-p194/gems/compass-0.12.2/frameworks/compass/stylesheets/compass/typography/lists/_horizontal-list.scss */ .nav > li.last { padding-right: 0; } - /* line 139, ../sass/modules/_header.scss */ + /* line 140, ../sass/modules/_header.scss */ .nav > li > a { color: white; font-size: 16px; line-height: 26px; height: 26px; font-weight: normal; } - /* line 147, ../sass/modules/_header.scss */ + /* line 148, ../sass/modules/_header.scss */ .nav > li > a.intercom em:before { content: '('; } - /* line 150, ../sass/modules/_header.scss */ + /* line 151, ../sass/modules/_header.scss */ .nav > li > a.intercom em:after { content: ')'; } +/* line 158, ../sass/modules/_header.scss */ +.search { + position: relative; } + /* line 160, ../sass/modules/_header.scss */ + .search .search-field { + font-size: 14px; + padding: 4px 12px; + line-height: 1.3; + border-radius: 20px; + border: 0px; + width: 100px; + background: white; } + /* line 168, ../sass/modules/_header.scss */ + .search .search-field:focus { + outline: none; } + /* line 172, ../sass/modules/_header.scss */ + .search .search-clear { + display: block; + background: rgba(0, 0, 0, 0.15); + -webkit-border-radius: 50%; + -moz-border-radius: 50%; + -ms-border-radius: 50%; + -o-border-radius: 50%; + border-radius: 50%; + font-weight: bold; + position: absolute; + right: 5px; + top: 50%; + margin-top: -9px; + font-size: 12px; + height: 16px; + width: 16px; + text-align: center; + line-height: 16px; + z-index: 1000; } + /* line 189, ../sass/modules/_header.scss */ + .search.empty .search-field { + background: rgba(255, 255, 255, 0.1); } + /* line 191, ../sass/modules/_header.scss */ + .search.empty .search-field:focus { + background: white; } + /* line 195, ../sass/modules/_header.scss */ + .search.empty .search-clear { + display: none; } + /* line 1, ../sass/modules/_posts.scss */ .empty-notice { text-align: center; diff --git a/client/views/common/nav.html b/client/views/common/nav.html index 7a130bec6..cce5bd1cc 100644 --- a/client/views/common/nav.html +++ b/client/views/common/nav.html @@ -5,10 +5,18 @@ diff --git a/client/views/common/nav.js b/client/views/common/nav.js index f3a404edb..a6b1d6b49 100644 --- a/client/views/common/nav.js +++ b/client/views/common/nav.js @@ -1,36 +1,3 @@ -Template.nav.events = { - 'click #logout': function(event){ - event.preventDefault(); - Meteor.logout(); - }, - 'click #mobile-menu': function(event){ - event.preventDefault(); - $('body').toggleClass('mobile-nav-open'); - }, - 'click .login-header': function(e){ - e.preventDefault(); - Router.go('/account'); - }, - 'keyup #search': function(e){ - e.preventDefault(); - Session.set('query', $(e.target).val()); - } -}; - -Template.nav.preserve({ - 'input#search': function (node) { return node.id; } -}); - -Template.nav.rendered=function(){ - - if(!Meteor.user()){ - $('.login-link-text').text("Sign Up/Sign In"); - }else{ - $('#login-buttons-logout').before(''); - $('#login-buttons-logout').before(''); - } -}; - Template.nav.helpers({ site_title: function(){ return getSetting('title'); @@ -70,5 +37,53 @@ Template.nav.helpers({ }, query: function () { return Session.get("query"); + }, + queryEmpty: function () { + return !!Session.get("query") ? '' : 'empty'; } }); + +Template.nav.preserve({ + 'input#search': function (node) { return node.id; } +}); + +Template.nav.rendered=function(){ + + if(!Meteor.user()){ + $('.login-link-text').text("Sign Up/Sign In"); + }else{ + $('#login-buttons-logout').before(''); + $('#login-buttons-logout').before(''); + } +}; + +Template.nav.events = { + 'click #logout': function(e){ + e.preventDefault(); + Meteor.logout(); + }, + 'click #mobile-menu': function(e){ + e.preventDefault(); + $('body').toggleClass('mobile-nav-open'); + }, + 'click .login-header': function(e){ + e.preventDefault(); + Router.go('/account'); + }, + 'click .search-clear': function (e) { + e.preventDefault(); + Session.set('query', ''); + $('.search').addClass('empty'); + }, + 'keyup .search-field': function(e){ + e.preventDefault(); + var val = $(e.target).val(), + $search = $('.search'); + if(val==''){ + $search.addClass('empty'); + }else{ + $search.removeClass('empty'); + } + Session.set('query', val); + } +}; \ No newline at end of file diff --git a/packages/iron-router b/packages/iron-router index 8fcd7873e..b829b0dbb 120000 --- a/packages/iron-router +++ b/packages/iron-router @@ -1 +1 @@ -/Users/ry/.meteorite/packages/iron-router/EventedMind/iron-router/4e1ee0581d68bff422a915dacb0bd30eae10fe08 \ No newline at end of file +/Users/sacha/.meteorite/packages/iron-router/EventedMind/iron-router/4e1ee0581d68bff422a915dacb0bd30eae10fe08 \ No newline at end of file From 84a35bd7374a1c3c96f2e044650311429bf155f2 Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Sat, 16 Nov 2013 12:51:33 +0900 Subject: [PATCH 12/25] use type=search --- client/sass/modules/_header.scss | 16 ---------------- client/stylesheets/screen.css | 26 +++----------------------- client/views/common/nav.html | 3 +-- client/views/common/nav.js | 7 +------ 4 files changed, 5 insertions(+), 47 deletions(-) diff --git a/client/sass/modules/_header.scss b/client/sass/modules/_header.scss index f60a78d6e..7ccec7707 100644 --- a/client/sass/modules/_header.scss +++ b/client/sass/modules/_header.scss @@ -169,22 +169,6 @@ outline:none; } } - .search-clear{ - display: block; - background: black(0.15); - @include border-radius(50%); - font-weight: bold; - position: absolute; - right: 5px; - top: 50%; - margin-top: -9px; - font-size: 12px; - height: 16px; - width: 16px; - text-align: center; - line-height: 16px; - z-index: 1000; - } &.empty{ .search-field{ background: white(0.1); diff --git a/client/stylesheets/screen.css b/client/stylesheets/screen.css index f6800222c..6aeb21968 100644 --- a/client/stylesheets/screen.css +++ b/client/stylesheets/screen.css @@ -851,33 +851,13 @@ body.pageslide-open { /* line 168, ../sass/modules/_header.scss */ .search .search-field:focus { outline: none; } - /* line 172, ../sass/modules/_header.scss */ - .search .search-clear { - display: block; - background: rgba(0, 0, 0, 0.15); - -webkit-border-radius: 50%; - -moz-border-radius: 50%; - -ms-border-radius: 50%; - -o-border-radius: 50%; - border-radius: 50%; - font-weight: bold; - position: absolute; - right: 5px; - top: 50%; - margin-top: -9px; - font-size: 12px; - height: 16px; - width: 16px; - text-align: center; - line-height: 16px; - z-index: 1000; } - /* line 189, ../sass/modules/_header.scss */ + /* line 173, ../sass/modules/_header.scss */ .search.empty .search-field { background: rgba(255, 255, 255, 0.1); } - /* line 191, ../sass/modules/_header.scss */ + /* line 175, ../sass/modules/_header.scss */ .search.empty .search-field:focus { background: white; } - /* line 195, ../sass/modules/_header.scss */ + /* line 179, ../sass/modules/_header.scss */ .search.empty .search-clear { display: none; } diff --git a/client/views/common/nav.html b/client/views/common/nav.html index cce5bd1cc..5aa695ade 100644 --- a/client/views/common/nav.html +++ b/client/views/common/nav.html @@ -45,8 +45,7 @@ {{/if}} diff --git a/client/views/common/nav.js b/client/views/common/nav.js index a6b1d6b49..b7cb50f3a 100644 --- a/client/views/common/nav.js +++ b/client/views/common/nav.js @@ -70,12 +70,7 @@ Template.nav.events = { e.preventDefault(); Router.go('/account'); }, - 'click .search-clear': function (e) { - e.preventDefault(); - Session.set('query', ''); - $('.search').addClass('empty'); - }, - 'keyup .search-field': function(e){ + 'keyup, change, search .search-field': function(e){ e.preventDefault(); var val = $(e.target).val(), $search = $('.search'); From 2bb0ab29fd315c936a6029bf1e7cdd318454e6fd Mon Sep 17 00:00:00 2001 From: Sacha Greif Date: Sat, 16 Nov 2013 13:13:21 +0900 Subject: [PATCH 13/25] made updateUserProfiles into a migration --- client/views/admin/toolbox.html | 7 ------- server/migrations.js | 33 +++++++++++++++++++++++++++++++++ server/toolbox.js | 32 -------------------------------- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/client/views/admin/toolbox.html b/client/views/admin/toolbox.html index 36f11e4d3..e9d1cd2ef 100644 --- a/client/views/admin/toolbox.html +++ b/client/views/admin/toolbox.html @@ -1,13 +1,6 @@

    Name Member sinceEmail Posts Comments KarmaIs Invited?Is Admin?DeleteInvitesInvited?Admin?Actions