mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 10:01:40 -05:00
Merge branch 'master' of github.com:SachaG/Telescope
This commit is contained in:
commit
7d4a3f7cb9
21 changed files with 69 additions and 136 deletions
|
@ -1,7 +1,4 @@
|
||||||
Meteor.subscribe('users', function(){
|
Meteor.subscribe('users');
|
||||||
// once we've subscribed, set a session variable to check if the current user is an admin
|
|
||||||
Session.set('currentUserIsAdmin', (Meteor.user() && !Meteor.user().loading) ? isAdmin(Meteor.user()) : false );
|
|
||||||
});
|
|
||||||
|
|
||||||
Posts = new Meteor.Collection('posts');
|
Posts = new Meteor.Collection('posts');
|
||||||
Meteor.subscribe('posts');
|
Meteor.subscribe('posts');
|
||||||
|
@ -15,10 +12,10 @@ Meteor.subscribe('comments', function() {
|
||||||
|
|
||||||
Settings = new Meteor.Collection('settings');
|
Settings = new Meteor.Collection('settings');
|
||||||
Meteor.subscribe('settings', function(){
|
Meteor.subscribe('settings', function(){
|
||||||
if(proxinoKey=getSetting('proxinoKey')){
|
if((proxinoKey=getSetting('proxinoKey'))){
|
||||||
Proxino.key = proxinoKey;
|
Proxino.key = proxinoKey;
|
||||||
Proxino.track_errors();
|
Proxino.track_errors();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Session.set('state', 'list');
|
Session.set('state', 'list');
|
||||||
|
|
|
@ -1,16 +1,14 @@
|
||||||
<template name="comment_form">
|
<template name="comment_form">
|
||||||
{{#if show_comment_form}}
|
<div class="comment-new">
|
||||||
<div class="comment-new">
|
<form>
|
||||||
<form>
|
{{#constant}}
|
||||||
{{#constant}}
|
|
||||||
<div class="comment-field" id="editor">
|
<div class="comment-field" id="editor">
|
||||||
<textarea id="comment" rows="3" autofocus="autofocus"></textarea>
|
<textarea id="comment" rows="3" autofocus="autofocus"></textarea>
|
||||||
</div>
|
</div>
|
||||||
{{/constant}}
|
{{/constant}}
|
||||||
<div class="comment-submit">
|
<div class="comment-submit">
|
||||||
<input type="submit" class="button" value="Add Comment" />
|
<input type="submit" class="button" value="Add Comment" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
</template>
|
||||||
</template>
|
|
||||||
|
|
|
@ -1,9 +1,3 @@
|
||||||
Template.comment_form.helpers({
|
|
||||||
show_comment_form: function(){
|
|
||||||
return Meteor.user() !== null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Template.comment_form.rendered = function(){
|
Template.comment_form.rendered = function(){
|
||||||
if(Meteor.user() && !this.editor){
|
if(Meteor.user() && !this.editor){
|
||||||
this.editor = new EpicEditor(EpicEditorOptions).load();
|
this.editor = new EpicEditor(EpicEditorOptions).load();
|
||||||
|
@ -35,4 +29,3 @@ Template.comment_form.events = {
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template name="comment_item">
|
<template name="comment_item">
|
||||||
<li class="comment comment-displayed" id="{{_id}}">
|
<li class="comment comment-displayed" id="{{_id}}">
|
||||||
<!-- <div class="comment-notification"><a href="#" class="open-comment-link">{{author}}</a></div>
|
<!-- <div class="comment-notification"><a href="#" class="open-comment-link">{{author.username}}</a></div>
|
||||||
--> <div class="comment-body">
|
--> <div class="comment-body">
|
||||||
<div class="comment-content">
|
<div class="comment-content">
|
||||||
<div class="comment-actions {{#if upvoted}}upvoted{{/if}} {{#if downvoted}}downvoted{{/if}}">
|
<div class="comment-actions {{#if upvoted}}upvoted{{/if}} {{#if downvoted}}downvoted{{/if}}">
|
||||||
|
@ -14,14 +14,14 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-meta">
|
<div class="comment-meta">
|
||||||
<a class="comment-username" href="/users/{{user_id}}">{{author}}</a>
|
<a class="comment-username" href="/users/{{user_id}}">{{author.username}}</a>
|
||||||
<span class="comment-time">{{ago}},</span>
|
<span class="comment-time">{{ago}},</span>
|
||||||
<span class="points">{{votes}} <span class="unit">points </span>
|
<span class="points">{{votes}} <span class="unit">points </span>
|
||||||
<a href="/comments/{{_id}}" class="comment-permalink icon-link goto-comment">link</a>
|
<a href="/comments/{{_id}}" class="comment-permalink icon-link goto-comment">link</a>
|
||||||
{{#if can_edit}}
|
{{#if can_edit}}
|
||||||
| <a class="edit-link" href="/comments/{{_id}}/edit">Edit</a>
|
| <a class="edit-link" href="/comments/{{_id}}/edit">Edit</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if is_admin}}
|
{{#if currentUser.isAdmin}}
|
||||||
| <a class="queue-comment" href="#">queue</a>
|
| <a class="queue-comment" href="#">queue</a>
|
||||||
| <span>{{full_date}}</span>
|
| <span>{{full_date}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -16,30 +16,30 @@
|
||||||
$queuedAncestors=$comment.parents(".comment-queued");
|
$queuedAncestors=$comment.parents(".comment-queued");
|
||||||
if($queuedAncestors.exists()){
|
if($queuedAncestors.exists()){
|
||||||
// console.log("----------- case 1: Queued Ancestor -----------");
|
// console.log("----------- case 1: Queued Ancestor -----------");
|
||||||
// 1.
|
// 1.
|
||||||
// our comment has one or more queued ancestor, so we look for the root-most
|
// our comment has one or more queued ancestor, so we look for the root-most
|
||||||
// ancestor's queue container
|
// ancestor's queue container
|
||||||
$container=$queuedAncestors.last().data("queue");
|
$container=$queuedAncestors.last().data("queue");
|
||||||
}else if($prev.hasClass("queue-container")){
|
}else if($prev.hasClass("queue-container")){
|
||||||
// console.log("----------- case 2: Queued Brother -----------");
|
// console.log("----------- case 2: Queued Brother -----------");
|
||||||
// 2.
|
// 2.
|
||||||
// the comment just above is queued, so we use the same queue container as him
|
// the comment just above is queued, so we use the same queue container as him
|
||||||
$container=$prev.data("queue");
|
$container=$prev.data("queue");
|
||||||
}else if($prev.find(".comment").last().hasClass("comment-queued")){
|
}else if($prev.find(".comment").last().hasClass("comment-queued")){
|
||||||
// console.log("----------- case 3: Queued Cousin -----------");
|
// console.log("----------- case 3: Queued Cousin -----------");
|
||||||
// 3.
|
// 3.
|
||||||
// there are no queued comments going up on the same level,
|
// there are no queued comments going up on the same level,
|
||||||
// but the bottom-most child of the comment directly above is queued
|
// but the bottom-most child of the comment directly above is queued
|
||||||
$container=$prev.find(".comment").last().data("queue");
|
$container=$prev.find(".comment").last().data("queue");
|
||||||
}else if($down.hasClass("queue-container")){
|
}else if($down.hasClass("queue-container")){
|
||||||
// console.log("----------- case 4: Queued Sister -----------");
|
// console.log("----------- case 4: Queued Sister -----------");
|
||||||
// 3.
|
// 3.
|
||||||
// the comment just below is queued, so we use the same queue container as him
|
// the comment just below is queued, so we use the same queue container as him
|
||||||
$container=$next.data("queue");
|
$container=$next.data("queue");
|
||||||
}else if($up.hasClass('comment-displayed') || !$up.exists()){
|
}else if($up.hasClass('comment-displayed') || !$up.exists()){
|
||||||
// console.log("----------- case 5: No Queue -----------");
|
// console.log("----------- case 5: No Queue -----------");
|
||||||
// 4.
|
// 4.
|
||||||
// we've found containers neither above or below, but
|
// we've found containers neither above or below, but
|
||||||
// A) we've hit a displayed comment or
|
// A) we've hit a displayed comment or
|
||||||
// B) we've haven't found any comments (i.e. we're at the beginning of the list)
|
// B) we've haven't found any comments (i.e. we're at the beginning of the list)
|
||||||
// so we put our queue container just before the comment
|
// so we put our queue container just before the comment
|
||||||
|
@ -77,18 +77,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
,author: function(){
|
,author: function(){
|
||||||
if(Meteor.users.findOne(this.user_id)){
|
return Meteor.users.findOne(this.user_id);
|
||||||
return Meteor.users.findOne(this.user_id).username;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,can_edit: function(){
|
,can_edit: function(){
|
||||||
if(this.user_id){
|
if(this.user_id && Meteor.userId())
|
||||||
if(Meteor.user() && (isAdmin(Meteor.user()) || Meteor.user()._id==this.user_id)){
|
return Meteor.user().isAdmin || (Meteor.userId() === this.user_id);
|
||||||
return true;
|
else
|
||||||
}
|
return false;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,body_formatted: function(){
|
,body_formatted: function(){
|
||||||
|
@ -99,15 +95,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
,is_admin: function(){
|
|
||||||
return currentUserIsAdmin();
|
|
||||||
}
|
|
||||||
|
|
||||||
,repress_recursion: function(){
|
,repress_recursion: function(){
|
||||||
if(window.repress_recursion){
|
return window.repress_recursion;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,ago: function(){
|
,ago: function(){
|
||||||
|
@ -115,15 +104,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
,upvoted: function(){
|
,upvoted: function(){
|
||||||
var user = Meteor.user();
|
return Meteor.user() && _.include(this.upvoters, Meteor.user()._id);
|
||||||
if(!user) return false;
|
|
||||||
return _.include(this.upvoters, user._id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
,downvoted: function(){
|
,downvoted: function(){
|
||||||
var user = Meteor.user();
|
return Meteor.user() && _.include(this.downvoters, Meteor.user()._id);
|
||||||
if(!user) return false;
|
|
||||||
return _.include(this.downvoters, user._id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -182,7 +167,7 @@ Template.comment_item.rendered=function(){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
var href=event.target.href.replace(/^(?:\/\/|[^\/]+)*\//, "");
|
var href=event.target.href.replace(/^(?:\/\/|[^\/]+)*\//, "");
|
||||||
|
|
||||||
Session.set('selected_comment', this);
|
Session.set('selected_comment_id', this._id);
|
||||||
// Session.set('state', 'reply');
|
// Session.set('state', 'reply');
|
||||||
Router.navigate(href, {trigger: true});
|
Router.navigate(href, {trigger: true});
|
||||||
},
|
},
|
||||||
|
@ -222,7 +207,7 @@ Template.comment_item.rendered=function(){
|
||||||
// 'click .queue-container, click .queue-container a': function(e, instance){
|
// 'click .queue-container, click .queue-container a': function(e, instance){
|
||||||
// e.preventDefault();
|
// e.preventDefault();
|
||||||
// var $this=$(e.target);
|
// var $this=$(e.target);
|
||||||
|
|
||||||
// var queueContainer= $this.is("a") ? $this.closest('.queue-container') : $this;
|
// var queueContainer= $this.is("a") ? $this.closest('.queue-container') : $this;
|
||||||
// console.log($this, queueContainer);
|
// console.log($this, queueContainer);
|
||||||
// queueContainer.find("a").each(function(){
|
// queueContainer.find("a").each(function(){
|
||||||
|
@ -233,6 +218,6 @@ Template.comment_item.rendered=function(){
|
||||||
// }
|
// }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
|
@ -1,15 +1,21 @@
|
||||||
<template name="comment_page">
|
<template name="comment_page">
|
||||||
<div class="post grid comment-page">
|
<div class="post grid comment-page">
|
||||||
{{#if postLoaded}}
|
{{#if post}}
|
||||||
{{#with post}}
|
{{#with post}}
|
||||||
{{> post_item}}
|
{{> post_item}}
|
||||||
{{/with}}
|
{{/with}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if comment}}
|
||||||
{{#with comment}}
|
{{#with comment}}
|
||||||
<ul class="selected-comment">
|
<ul class="selected-comment">
|
||||||
{{> comment_item}}
|
{{> comment_item}}
|
||||||
</ul>
|
</ul>
|
||||||
{{/with}}
|
{{/with}}
|
||||||
{{> comment_form}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if currentUser}}
|
||||||
|
{{> comment_form}}
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,28 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
Template.comment_page.show = function(){
|
|
||||||
return Session.equals('state', 'reply');
|
|
||||||
};
|
|
||||||
|
|
||||||
Template.comment_page.show_comment_form = function(){
|
|
||||||
return Meteor.user() !== null;
|
|
||||||
};
|
|
||||||
|
|
||||||
Template.comment_page.postLoaded = function(){
|
|
||||||
var selected_comment = Comments.findOne(Session.get('selected_comment_id'));
|
|
||||||
if(selected_comment){
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Template.comment_page.post = function(){
|
Template.comment_page.post = function(){
|
||||||
var selected_comment = Comments.findOne(Session.get('selected_comment_id'));
|
var selected_comment = Comments.findOne(Session.get('selected_comment_id'));
|
||||||
if(selected_comment){
|
return selected_comment && Posts.findOne(selected_comment.post);
|
||||||
var post = selected_comment.post;
|
|
||||||
return Posts.findOne(post);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Template.comment_page.comment = function(){
|
Template.comment_page.comment = function(){
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><a class="top" href="/top">Top</a></li>
|
<li><a class="top" href="/top">Top</a></li>
|
||||||
<li><a class="new" href="/new">New</a></li>
|
<li><a class="new" href="/new">New</a></li>
|
||||||
{{#if is_admin}}
|
{{#if currentUser.isAdmin}}
|
||||||
<li><a class="users" href="/users">Users</a></li>
|
<li><a class="users" href="/users">Users</a></li>
|
||||||
<li><a class="settings" href="/settings">Settings</a></li>
|
<li><a class="settings" href="/settings">Settings</a></li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
<ul class="nav site-nav desktop">
|
<ul class="nav site-nav desktop">
|
||||||
<li><a class="top" href="/top">Top</a></li>
|
<li><a class="top" href="/top">Top</a></li>
|
||||||
<li><a class="new" href="/new">New</a></li>
|
<li><a class="new" href="/new">New</a></li>
|
||||||
{{#if is_admin}}
|
{{#if currentUser.isAdmin}}
|
||||||
<li><a class="users" href="/users">Users</a></li>
|
<li><a class="users" href="/users">Users</a></li>
|
||||||
<li><a class="settings" href="/settings">Settings</a></li>
|
<li><a class="settings" href="/settings">Settings</a></li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
@ -30,13 +30,13 @@
|
||||||
<li><a href="jobs">Jobs</a></li> -->
|
<li><a href="jobs">Jobs</a></li> -->
|
||||||
</ul>
|
</ul>
|
||||||
<ul class="nav user-nav desktop">
|
<ul class="nav user-nav desktop">
|
||||||
<!-- {{#if logged_in}}
|
<!-- {{#if currentUser}}
|
||||||
<li><a id="logout" href="logout">Log Out</a></li>
|
<li><a id="logout" href="logout">Log Out</a></li>
|
||||||
{{else}}
|
{{else}}
|
||||||
<li><a id="signup" href="signup">Sign Up</a></li>
|
<li><a id="signup" href="signup">Sign Up</a></li>
|
||||||
<li><a id="signin" href="signin">Sign In</a></li>
|
<li><a id="signin" href="signin">Sign In</a></li>
|
||||||
{{/if}} -->
|
{{/if}} -->
|
||||||
{{#if logged_in}}
|
{{#if currentUser}}
|
||||||
<li><a id="submit" class="submit button" href="/submit">Post</a></li>
|
<li><a id="submit" class="submit button" href="/submit">Post</a></li>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -1,12 +1,3 @@
|
||||||
Template.nav.helpers({
|
|
||||||
logged_in: function(){
|
|
||||||
return Meteor.user() !== null;
|
|
||||||
}
|
|
||||||
,is_admin: function(){
|
|
||||||
return currentUserIsAdmin();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
Template.nav.events = {
|
Template.nav.events = {
|
||||||
'click #logout': function(event){
|
'click #logout': function(event){
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
|
@ -36,11 +36,11 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if url}}<span class="post-domain">{{domain}}</span>{{/if}}
|
{{#if url}}<span class="post-domain">{{domain}}</span>{{/if}}
|
||||||
</h3>
|
</h3>
|
||||||
<p class="post-meta"><span class="points">{{votes}} <span class="unit">points </span></span>by <a class="post-author" href="/users/{{user_id}}">{{author}}</a> <span class="post-time">{{ago}}</span><span class="comments">, <a class="go-to-comments" href="posts/{{_id}}">{{comments}} comments</a></span>
|
<p class="post-meta"><span class="points">{{votes}} <span class="unit">points </span></span>by <a class="post-author" href="/users/{{user_id}}">{{authorName}}</a> <span class="post-time">{{ago}}</span><span class="comments">, <a class="go-to-comments" href="posts/{{_id}}">{{comments}} comments</a></span>
|
||||||
{{#if can_edit}}
|
{{#if can_edit}}
|
||||||
| <a href="/posts/{{_id}}/edit" class="edit-link goto-edit">Edit</a>
|
| <a href="/posts/{{_id}}/edit" class="edit-link goto-edit">Edit</a>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if is_admin}}
|
{{#if currentUser.isAdmin}}
|
||||||
| votes: {{votes}}, baseScore: {{baseScore}}, score: {{short_score}}
|
| votes: {{votes}}, baseScore: {{baseScore}}, score: {{short_score}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -100,19 +100,13 @@ Template.post_item.current_domain = function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
Template.post_item.can_edit = function(){
|
Template.post_item.can_edit = function(){
|
||||||
if(this.user_id){
|
if(this.user_id && Meteor.userId())
|
||||||
if(Meteor.user() && (isAdmin(Meteor.user()) || Meteor.user()._id==this.user_id)){
|
return Meteor.user().isAdmin || (Meteor.userId() === this.user_id);
|
||||||
return true;
|
else
|
||||||
}
|
return false;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Template.post_item.is_admin = function(){
|
Template.post_item.authorName = function(){
|
||||||
return currentUserIsAdmin();
|
|
||||||
};
|
|
||||||
|
|
||||||
Template.post_item.author = function(){
|
|
||||||
if(this.user_id && Meteor.users.findOne(this.user_id)){
|
if(this.user_id && Meteor.users.findOne(this.user_id)){
|
||||||
return Meteor.users.findOne(this.user_id).username;
|
return Meteor.users.findOne(this.user_id).username;
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -3,7 +3,9 @@
|
||||||
{{#with post}}
|
{{#with post}}
|
||||||
{{> post_item}}
|
{{> post_item}}
|
||||||
{{/with}}
|
{{/with}}
|
||||||
{{> comment_form}}
|
{{#if currentUser}}
|
||||||
|
{{> comment_form}}
|
||||||
|
{{/if}}
|
||||||
{{> comment_list}}
|
{{> comment_list}}
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{{#if no_settings}}
|
{{#if no_settings}}
|
||||||
<p>No settings yet.</p>
|
<p>No settings yet.</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if currentUserIsAdmin}}
|
{{#if currentUser.isAdmin}}
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label>Site Title</label>
|
<label>Site Title</label>
|
||||||
<div class="controls"><input id="title" name="title" type="text" value="{{title}}" /></div>
|
<div class="controls"><input id="title" name="title" type="text" value="{{title}}" /></div>
|
||||||
|
|
|
@ -41,9 +41,6 @@ Template.settings.events = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Template.settings.currentUserIsAdmin = function(){
|
|
||||||
return currentUserIsAdmin();
|
|
||||||
}
|
|
||||||
Template.settings.no_settings = function(){
|
Template.settings.no_settings = function(){
|
||||||
if(Settings.find().fetch()[0]){
|
if(Settings.find().fetch()[0]){
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -36,7 +36,7 @@ Template.user_edit.events = {
|
||||||
|
|
||||||
Template.user_edit.user = function(){
|
Template.user_edit.user = function(){
|
||||||
var current_user=Meteor.user();
|
var current_user=Meteor.user();
|
||||||
if(window.selected_user_id && !current_user.loading && isAdmin(current_user)){
|
if(window.selected_user_id && !current_user.loading && current_user.isAdmin){
|
||||||
return Meteor.users.findOne(window.selected_user_id);
|
return Meteor.users.findOne(window.selected_user_id);
|
||||||
}else{
|
}else{
|
||||||
return current_user;
|
return current_user;
|
||||||
|
|
|
@ -14,6 +14,6 @@
|
||||||
</td>
|
</td>
|
||||||
<td><a href="#">{{comments_count}}</a></td>
|
<td><a href="#">{{comments_count}}</a></td>
|
||||||
<td>{{karma}}</td>
|
<td>{{karma}}</td>
|
||||||
<td>{{#if is_admin}}<i class="icon-check"></i>{{/if}}</td>
|
<td>{{#if currentUser.isAdmin}}<i class="icon-check"></i>{{/if}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</template>
|
</template>
|
|
@ -34,7 +34,3 @@ Template.user_item.comments_count = function(){
|
||||||
// Posts.find({'user_id':this._id}).forEach(function(post){console.log(post.headline);});
|
// Posts.find({'user_id':this._id}).forEach(function(post){console.log(post.headline);});
|
||||||
return Comments.find({'user_id':this._id}).count();
|
return Comments.find({'user_id':this._id}).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
Template.user_item.is_admin = function(){
|
|
||||||
return isAdmin(this);
|
|
||||||
}
|
|
|
@ -8,10 +8,6 @@ var breakTag = '<br />';
|
||||||
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
|
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
|
||||||
}
|
}
|
||||||
|
|
||||||
currentUserIsAdmin = function(){
|
|
||||||
return Session.get('currentUserIsAdmin');
|
|
||||||
}
|
|
||||||
|
|
||||||
getSetting = function(setting){
|
getSetting = function(setting){
|
||||||
var settings=Settings.find().fetch()[0];
|
var settings=Settings.find().fetch()[0];
|
||||||
if(settings){
|
if(settings){
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
isAdmin=function(userOrId){
|
|
||||||
var user= typeof userOrId === 'string' ? Meteor.users.findOne(userOrId) : userOrId;
|
|
||||||
return user && user.isAdmin;
|
|
||||||
}
|
|
|
@ -1,4 +1,8 @@
|
||||||
// Users
|
// Users
|
||||||
|
isAdmin=function(userId){
|
||||||
|
var user = Meteor.users.findOne(userId);
|
||||||
|
return user && user.isAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
Meteor.publish('users', function() {
|
Meteor.publish('users', function() {
|
||||||
if (this.userId() && isAdmin(this.userId())) {
|
if (this.userId() && isAdmin(this.userId())) {
|
||||||
|
@ -92,7 +96,7 @@ Meteor.startup(function(){
|
||||||
if(isAdmin(userId) || (docs[0].user_id && docs[0].user_id==userId)){
|
if(isAdmin(userId) || (docs[0].user_id && docs[0].user_id==userId)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
"meteor": {
|
"meteor": {
|
||||||
"git": "https://github.com/meteor/meteor.git",
|
"git": "https://github.com/meteor/meteor.git",
|
||||||
"branch": "auth",
|
"branch": "auth",
|
||||||
"commit": "687407a4d3be776635d3b59242e8304d9e29abdb"
|
"commit": "d2616308361203215c122f962ae9a5c763b5ca09"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"basePackages": {
|
"basePackages": {
|
||||||
|
|
Loading…
Add table
Reference in a new issue