Merge branch 'master' into autoform

Conflicts:
	client/views/posts/post_item.html
	client/views/posts/post_item.js
This commit is contained in:
Sacha Greif 2014-05-30 14:03:41 +09:00
commit ae0cf36819
9 changed files with 76 additions and 25 deletions

View file

@ -1 +1 @@
0.8.1.1
0.8.1.3

View file

@ -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.

View file

@ -28,9 +28,4 @@ Template.layout.rendered = function(){
$('body').scrollTop(currentScroll);
Session.set('currentScroll', null);
}
// set title
var title = getSetting("title");
var tagline = getSetting("tagline");
document.title = (tagline ? title+': '+tagline : title) || "";
}

View file

@ -42,7 +42,13 @@
| <a href="/posts/{{_id}}/edit" class="edit-link goto-edit">Edit</a>
{{/if}}
{{#if currentUser.isAdmin}}
| {{i18n "status"}}: {{status}}, {{i18n "votes"}}: {{upvotes}}, {{i18n "baseScore"}}: {{baseScore}}, {{i18n "score"}}: {{short_score}}, {{i18n "clicks"}}: {{clicks}}
|
{{#if isApproved}}
<a href="#" class="unapprove-link goto-edit">Unapprove</a>
{{else}}
<a href="#" class="approve-link goto-edit">Approve</a>
{{/if}}
| {{i18n "score"}}: {{short_score}}, {{i18n "clicks"}}: {{clicks}}
{{/if}}
</p>
</div>

View file

@ -75,6 +75,9 @@ Template.post_item.helpers({
},
pointsUnitDisplayText: function(){
return this.upvotes == 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();
}
});

View file

@ -203,6 +203,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};

View file

@ -102,7 +102,12 @@ Router.configure({
notFoundTemplate: 'not_found',
waitOn: function () {
return _.map(preloadSubscriptions, function(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);
}
});
}
});
@ -153,17 +158,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();
@ -199,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) || "";
}
};
@ -236,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

View file

@ -15,7 +15,11 @@ adminUsers = function(){
return Meteor.users.find({isAdmin : true}).fetch();
};
getUserName = function(user){
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){

View file

@ -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 [];
}