From dec7ef667e38503e857101b59ff78c5a1bff9660 Mon Sep 17 00:00:00 2001 From: Lukas Matt Date: Mon, 16 Jun 2014 10:18:47 -0400 Subject: [PATCH 1/3] Hide SPV controls unless authenticated * cleaned and removed dead code refs diaspora/diaspora#4711 --- .../javascripts/app/views/feedback_view.js | 7 ---- app/assets/templates/comment_tpl.jst.hbs | 18 ++++---- .../single-post-actions_tpl.jst.hbs | 41 ++++++++++--------- 3 files changed, 31 insertions(+), 35 deletions(-) diff --git a/app/assets/javascripts/app/views/feedback_view.js b/app/assets/javascripts/app/views/feedback_view.js index 41e957c89..c230d2b4f 100644 --- a/app/assets/javascripts/app/views/feedback_view.js +++ b/app/assets/javascripts/app/views/feedback_view.js @@ -4,7 +4,6 @@ app.views.Feedback = app.views.Base.extend({ className : "info", events: { - "click *[rel='auth-required']" : "requireAuth", "click .like" : "toggleLike", "click .reshare" : "resharePost", "click .post_report" : "report" @@ -39,11 +38,5 @@ app.views.Feedback = app.views.Base.extend({ if(evt) { evt.preventDefault(); } if(!window.confirm(Diaspora.I18n.t("reshares.post", {name: this.model.reshareAuthor().name}))) { return } this.model.interactions.reshare(); - }, - - requireAuth : function(evt) { - if( app.currentUser.authenticated() ) { return } - alert("you must be logged in to do that!") - return false; } }); diff --git a/app/assets/templates/comment_tpl.jst.hbs b/app/assets/templates/comment_tpl.jst.hbs index 5d5c7c1cf..23eb368d9 100644 --- a/app/assets/templates/comment_tpl.jst.hbs +++ b/app/assets/templates/comment_tpl.jst.hbs @@ -7,14 +7,16 @@
- {{#if canRemove}} - -
- - {{else}} - -
- + {{#if loggedIn}} + {{#if canRemove}} + +
+ + {{else}} + +
+ + {{/if}} {{/if}}
diff --git a/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs b/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs index c70b326f6..be1bec2c8 100644 --- a/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs +++ b/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs @@ -1,30 +1,31 @@
- - - + + - + {{#if userCanReshare}} - - - + + + {{else}} - {{#if userReshare}} - - - - {{/if}} + {{#if userReshare}} + + + + {{/if}} {{/if}} - - + + ! -
+ {{/if}}
From 10117b81b309c82ff5c27605fa79a747d1790f58 Mon Sep 17 00:00:00 2001 From: Lukas Matt Date: Tue, 17 Jun 2014 12:23:54 -0400 Subject: [PATCH 2/3] Hide report icon on SPV if author is current user --- .../views/single-post-viewer/single_post_actions.js | 10 ++++++++++ .../single-post-viewer/single-post-actions_tpl.jst.hbs | 10 ++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js index eebd39327..8dbce4adb 100644 --- a/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js +++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js @@ -7,6 +7,12 @@ app.views.SinglePostActions = app.views.Feedback.extend({ }, app.views.Feedback.prototype.events); }, + presenter: function() { + return _.extend(this.defaultPresenter(), { + authorIsNotCurrentUser : this.authorIsNotCurrentUser(), + }) + }, + renderPluginWidgets : function() { app.views.Base.prototype.renderPluginWidgets.apply(this); this.$('a').tooltip({placement: 'bottom'}); @@ -16,6 +22,10 @@ app.views.SinglePostActions = app.views.Feedback.extend({ $('.comment_stream .comment_box').focus(); $('html,body').animate({scrollTop: $('.comment_stream .comment_box').offset().top - ($('.comment_stream .comment_box').height() + 20)}); return false; + }, + + authorIsNotCurrentUser: function() { + return app.currentUser.authenticated() && this.model.get("author").id != app.user().id } }); diff --git a/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs b/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs index be1bec2c8..908c2d4ab 100644 --- a/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs +++ b/app/assets/templates/single-post-viewer/single-post-actions_tpl.jst.hbs @@ -23,9 +23,11 @@ {{/if}} {{/if}} - - - ! - + + {{#if authorIsNotCurrentUser}} + + ! + + {{/if}} {{/if}}
From c86b57fe8fccdb39310146edb0694da4422321b8 Mon Sep 17 00:00:00 2001 From: Lukas Matt Date: Wed, 18 Jun 2014 13:03:07 -0400 Subject: [PATCH 3/3] Fixed overridden interactions by re-initializing --- .../app/views/single-post-viewer/single_post_actions.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js b/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js index 8dbce4adb..69396abe6 100644 --- a/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js +++ b/app/assets/javascripts/app/views/single-post-viewer/single_post_actions.js @@ -8,8 +8,13 @@ app.views.SinglePostActions = app.views.Feedback.extend({ }, presenter: function() { + var interactions = this.model.interactions + return _.extend(this.defaultPresenter(), { authorIsNotCurrentUser : this.authorIsNotCurrentUser(), + userCanReshare : interactions.userCanReshare(), + userLike : interactions.userLike(), + userReshare : interactions.userReshare() }) },