From e07daec6f3c9c87429f409153cc6d8c84b982347 Mon Sep 17 00:00:00 2001 From: Matt DeBergalis Date: Wed, 26 Sep 2012 22:11:44 -0700 Subject: [PATCH] Use currentUser builtin to simplify templates. * {{currentUser.isAdmin}} instead of custom helpers. * drop currentUserIsAdmin session variable. relies on fix to meteor's handlebars evaluator in 0.4.2. --- client/app.js | 9 +++------ client/templates/comment_form.html | 24 +++++++++++------------- client/templates/comment_form.js | 7 ------- client/templates/comment_item.html | 2 +- client/templates/comment_item.js | 4 ---- client/templates/comment_page.html | 8 +++++++- client/templates/nav.html | 8 ++++---- client/templates/nav.js | 9 --------- client/templates/post_item.html | 2 +- client/templates/post_item.js | 4 ---- client/templates/post_page.html | 4 +++- client/templates/settings.html | 2 +- client/templates/settings.js | 3 --- client/templates/user_item.html | 2 +- client/templates/user_item.js | 4 ---- lib/helpers.js | 4 ---- smart.lock | 2 +- 17 files changed, 33 insertions(+), 65 deletions(-) diff --git a/client/app.js b/client/app.js index 6deaf26e8..899768915 100644 --- a/client/app.js +++ b/client/app.js @@ -1,7 +1,4 @@ -Meteor.subscribe('users', function(){ - // 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 ); -}); +Meteor.subscribe('users'); Posts = new Meteor.Collection('posts'); Meteor.subscribe('posts'); @@ -15,10 +12,10 @@ Meteor.subscribe('comments', function() { Settings = new Meteor.Collection('settings'); Meteor.subscribe('settings', function(){ - if(proxinoKey=getSetting('proxinoKey')){ + if((proxinoKey=getSetting('proxinoKey'))){ Proxino.key = proxinoKey; Proxino.track_errors(); - } + } }); Session.set('state', 'list'); diff --git a/client/templates/comment_form.html b/client/templates/comment_form.html index 929cdbbf0..4ec82dd96 100644 --- a/client/templates/comment_form.html +++ b/client/templates/comment_form.html @@ -1,16 +1,14 @@ \ No newline at end of file + {{/constant}} +
+ +
+ + + diff --git a/client/templates/comment_form.js b/client/templates/comment_form.js index 99a52ede4..ea2e6030d 100644 --- a/client/templates/comment_form.js +++ b/client/templates/comment_form.js @@ -1,9 +1,3 @@ -Template.comment_form.helpers({ - show_comment_form: function(){ - return Meteor.user() !== null; - } -}); - Template.comment_form.rendered = function(){ if(Meteor.user() && !this.editor){ this.editor = new EpicEditor(EpicEditorOptions).load(); @@ -35,4 +29,3 @@ Template.comment_form.events = { } }; - diff --git a/client/templates/comment_item.html b/client/templates/comment_item.html index 7f40946dc..60c43491a 100644 --- a/client/templates/comment_item.html +++ b/client/templates/comment_item.html @@ -21,7 +21,7 @@ {{#if can_edit}} | Edit {{/if}} - {{#if is_admin}} + {{#if currentUser.isAdmin}} | queue | {{full_date}} {{/if}} diff --git a/client/templates/comment_item.js b/client/templates/comment_item.js index 8b5955ed8..91e033537 100644 --- a/client/templates/comment_item.js +++ b/client/templates/comment_item.js @@ -99,10 +99,6 @@ } } - ,is_admin: function(){ - return currentUserIsAdmin(); - } - ,repress_recursion: function(){ if(window.repress_recursion){ return true; diff --git a/client/templates/comment_page.html b/client/templates/comment_page.html index dd98ffd49..0ecfe5dc4 100644 --- a/client/templates/comment_page.html +++ b/client/templates/comment_page.html @@ -5,11 +5,17 @@ {{> post_item}} {{/with}} {{/if}} + + {{#if comment}} {{#with comment}} {{/with}} - {{> comment_form}} + {{/if}} + + {{#if currentUser}} + {{> comment_form}} + {{/if}} diff --git a/client/templates/nav.html b/client/templates/nav.html index d20387b21..f98b1e047 100644 --- a/client/templates/nav.html +++ b/client/templates/nav.html @@ -3,7 +3,7 @@