From 8da131624552bc718fed9b9f86ca64719ad44e42 Mon Sep 17 00:00:00 2001
From: Sacha Greif
Date: Wed, 21 May 2014 15:36:29 +0900
Subject: [PATCH 1/7] updated Meteor
---
.meteor/release | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.meteor/release b/.meteor/release
index 5ee5d6a2f..6e8ef266d 100644
--- a/.meteor/release
+++ b/.meteor/release
@@ -1 +1 @@
-0.8.1.1
+0.8.1.2
From 8773c23a6a1e29186a238269b64bec9749d87f59 Mon Sep 17 00:00:00 2001
From: Sacha Greif
Date: Wed, 21 May 2014 16:01:15 +0900
Subject: [PATCH 2/7] making subscription preloader more flexible
---
lib/router.js | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/router.js b/lib/router.js
index c1a6aade3..63fc1f491 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -102,7 +102,12 @@ Router.configure({
notFoundTemplate: 'not_found',
waitOn: function () {
return _.map(preloadSubscriptions, function(sub){
- Meteor.subscribe(sub);
+ // can either pass strings or objects with subName and subArguments properties
+ if (typeof sub === 'object'){
+ Meteor.subscribe(sub.subName, sub.subArguments);
+ }else{
+ Meteor.subscribe(sub);
+ }
});
}
});
From 1598511dc33a2f26966ac1a64a0e949f329a9b30 Mon Sep 17 00:00:00 2001
From: Sacha Greif
Date: Fri, 23 May 2014 13:08:40 +0900
Subject: [PATCH 3/7] fixing getUsername; fixing site title
---
client/views/common/layout.js | 15 +++++----------
lib/router.js | 8 ++++++++
lib/users.js | 8 ++++++--
3 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/client/views/common/layout.js b/client/views/common/layout.js
index 4623435c1..55e675acc 100644
--- a/client/views/common/layout.js
+++ b/client/views/common/layout.js
@@ -24,13 +24,8 @@ Template.layout.created = function(){
}
Template.layout.rendered = function(){
- if(currentScroll=Session.get('currentScroll')){
- $('body').scrollTop(currentScroll);
- Session.set('currentScroll', null);
- }
-
- // set title
- var title = getSetting("title");
- var tagline = getSetting("tagline");
- document.title = (tagline ? title+': '+tagline : title) || "";
-}
+ if(currentScroll=Session.get('currentScroll')){
+ $('body').scrollTop(currentScroll);
+ Session.set('currentScroll', null);
+ }
+}
\ No newline at end of file
diff --git a/lib/router.js b/lib/router.js
index 63fc1f491..7ed779e77 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -109,6 +109,14 @@ Router.configure({
Meteor.subscribe(sub);
}
});
+ },
+ onAfterAction: function () {
+ // set title
+ var title = getSetting("title");
+ var tagline = getSetting("tagline");
+ console.log('title: '+title)
+ console.log('tagline: '+tagline)
+ document.title = (tagline ? title+': '+tagline : title) || "";
}
});
diff --git a/lib/users.js b/lib/users.js
index 8e33813c5..5f4a01ca8 100644
--- a/lib/users.js
+++ b/lib/users.js
@@ -15,7 +15,11 @@ adminUsers = function(){
return Meteor.users.find({isAdmin : true}).fetch();
};
getUserName = function(user){
- return user.username;
+ if (user.username)
+ return user.username;
+ if (user.services.twitter && user.services.twitter.screenName)
+ return user.services.twitter.screenName
+ return null;
};
getDisplayName = function(user){
return (user.profile && user.profile.name) ? user.profile.name : user.username;
@@ -66,7 +70,7 @@ getEmail = function(user){
if(user.profile && user.profile.email){
return user.profile.email;
}else{
- return '';
+ return null;
}
};
getAvatarUrl = function(user){
From 649e8d3f2391fa4bdde1f169c0079ebaf01c2675 Mon Sep 17 00:00:00 2001
From: Sacha Greif
Date: Fri, 23 May 2014 13:08:52 +0900
Subject: [PATCH 4/7] adding approve/unapprove methods
---
client/views/posts/post_item.html | 8 +++++++-
client/views/posts/post_item.js | 11 +++++++++++
collections/posts.js | 15 +++++++++++++++
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/client/views/posts/post_item.html b/client/views/posts/post_item.html
index 35103c351..2da242de0 100644
--- a/client/views/posts/post_item.html
+++ b/client/views/posts/post_item.html
@@ -42,7 +42,13 @@
| Edit
{{/if}}
{{#if currentUser.isAdmin}}
- | {{i18n "status"}}: {{status}}, {{i18n "votes"}}: {{votes}}, {{i18n "baseScore"}}: {{baseScore}}, {{i18n "score"}}: {{short_score}}, {{i18n "clicks"}}: {{clicks}}
+ |
+ {{#if isApproved}}
+ Unapprove
+ {{else}}
+ Approve
+ {{/if}}
+ | {{i18n "score"}}: {{short_score}}, {{i18n "clicks"}}: {{clicks}}
{{/if}}
diff --git a/client/views/posts/post_item.js b/client/views/posts/post_item.js
index 042006008..384bbd3b5 100644
--- a/client/views/posts/post_item.js
+++ b/client/views/posts/post_item.js
@@ -75,6 +75,9 @@ Template.post_item.helpers({
},
pointsUnitDisplayText: function(){
return this.votes == 1 ? i18n.t('point') : i18n.t('points');
+ },
+ isApproved: function(){
+ return this.status == STATUS_APPROVED;
}
});
@@ -132,5 +135,13 @@ Template.post_item.events({
$this.toggleClass("active");
$share.toggleClass("hidden");
$share.find('.share-replace').sharrre(SharrreOptions);
+ },
+ 'click .approve-link': function(e, instance){
+ Meteor.call('approvePost', this);
+ e.preventDefault();
+ },
+ 'click .unapprove-link': function(e, instance){
+ Meteor.call('unapprovePost', this);
+ e.preventDefault();
}
});
\ No newline at end of file
diff --git a/collections/posts.js b/collections/posts.js
index aa2815142..17af225a2 100644
--- a/collections/posts.js
+++ b/collections/posts.js
@@ -119,6 +119,21 @@ Meteor.methods({
post_edit: function(post){
// TODO: make post_edit server-side?
},
+ approvePost: function(post){
+ if(isAdmin(Meteor.user())){
+ var now = new Date().getTime();
+ Posts.update(post._id, {$set: {status: 2, submitted: now}});
+ }else{
+ throwError('You need to be an admin to do that.');
+ }
+ },
+ unapprovePost: function(post){
+ if(isAdmin(Meteor.user())){
+ Posts.update(post._id, {$set: {status: 1}});
+ }else{
+ throwError('You need to be an admin to do that.');
+ }
+ },
clickedPost: function(post, sessionId){
// only let clients increment a post's click counter once per session
var click = {_id: post._id, sessionId: sessionId};
From 2b37fd13595df83678b69e2107ec15633f7a1608 Mon Sep 17 00:00:00 2001
From: Sacha Greif
Date: Fri, 23 May 2014 13:32:52 +0900
Subject: [PATCH 5/7] fixing canPost and canView filters; only publish invited
users to admin
---
lib/router.js | 15 ++++++++-------
server/publications.js | 2 +-
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/router.js b/lib/router.js
index 7ed779e77..0fb2ae852 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -114,8 +114,6 @@ Router.configure({
// set title
var title = getSetting("title");
var tagline = getSetting("tagline");
- console.log('title: '+title)
- console.log('tagline: '+tagline)
document.title = (tagline ? title+': '+tagline : title) || "";
}
});
@@ -166,17 +164,20 @@ Router._filters = {
},
canView: function(pause) {
- if(!this.ready()) return;
- if(!canView()){
- console.log('cannot view');
+ if(!this.ready() || Meteor.loggingIn()){
+ this.render('loading');
+ pause();
+ }else if (!canView()) {
this.render('no_rights');
pause();
}
},
canPost: function (pause) {
- if(!this.ready()) return;
- if(!canPost()){
+ if(!this.ready() || Meteor.loggingIn()){
+ this.render('loading');
+ pause();
+ }else if(!canPost()){
throwError(i18n.t("Sorry, you don't have permissions to add new items."));
this.render('no_rights');
pause();
diff --git a/server/publications.js b/server/publications.js
index 717ef277e..09c1afa0d 100644
--- a/server/publications.js
+++ b/server/publications.js
@@ -94,7 +94,7 @@ Meteor.publish('allUsers', function(filterBy, sortBy, limit) {
Meteor.publish('allUsersAdmin', function() {
if (isAdminById(this.userId)) {
- return Meteor.users.find();
+ return Meteor.users.find({isInvited: true});
} else {
return [];
}
From 01cf53d88a4f7e843f67c23d1675732c15d158bb Mon Sep 17 00:00:00 2001
From: Sacha Greif
Date: Fri, 30 May 2014 10:32:30 +0900
Subject: [PATCH 6/7] cleaning up setTitle filter
---
.meteor/release | 2 +-
lib/router.js | 20 ++++++++++----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/.meteor/release b/.meteor/release
index 6e8ef266d..db5f2c74b 100644
--- a/.meteor/release
+++ b/.meteor/release
@@ -1 +1 @@
-0.8.1.2
+0.8.1.3
diff --git a/lib/router.js b/lib/router.js
index 0fb2ae852..ed40d6f8a 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -109,12 +109,6 @@ Router.configure({
Meteor.subscribe(sub);
}
});
- },
- onAfterAction: function () {
- // set title
- var title = getSetting("title");
- var tagline = getSetting("tagline");
- document.title = (tagline ? title+': '+tagline : title) || "";
}
});
@@ -213,6 +207,13 @@ Router._filters = {
this.render('user_email');
pause();
}
+ },
+
+ setTitle: function() {
+ // set title
+ var title = getSetting("title");
+ var tagline = getSetting("tagline");
+ document.title = (tagline ? title+': '+tagline : title) || "";
}
};
@@ -250,10 +251,9 @@ if(Meteor.isClient){
// After Hooks
Router.onAfterAction(filters.resetScroll, {except:['posts_top', 'posts_new', 'posts_best', 'posts_pending', 'posts_category', 'all-users']});
- Router.onAfterAction( function () {
- analyticsInit(); // will only run once thanks to _.once()
- analyticsRequest(); // log this request with mixpanel, etc
- });
+ Router.onAfterAction(analyticsInit); // will only run once thanks to _.once()
+ Router.onAfterAction(analyticsRequest); // log this request with mixpanel, etc
+ Router.onAfterAction(filters.setTitle);
// Unload Hooks
From 0d687e9c84da0a8412c1ec0c4effa3c1fd98b5cf Mon Sep 17 00:00:00 2001
From: Sacha Greif
Date: Fri, 30 May 2014 10:35:28 +0900
Subject: [PATCH 7/7] updated history
---
History.md | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/History.md b/History.md
index 2c5f959cb..e8faa926f 100644
--- a/History.md
+++ b/History.md
@@ -1,3 +1,9 @@
+## v0.8.1 “FlexScope”
+
+* Extracted part of the tags feature into its own package.
+* Made subscription preloader more flexible.
+* Made navigation menu dynamic.
+
## v0.8 “BlazeScope”
* Updated for Meteor 0.8.1.1/Blaze compatibility.