From dc753913a79237a2849f598dc3bba2544f58d34a Mon Sep 17 00:00:00 2001 From: zPlus <-> Date: Sat, 19 Mar 2016 07:40:05 +0100 Subject: [PATCH] Votes template: remove vote arrows if user is not logged in --- template/comment.twig | 3 ++- template/index.twig | 3 ++- template/post.twig | 3 ++- template/vote.twig | 27 +++++++++++++++++++-------- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/template/comment.twig b/template/comment.twig index 8cacf9fb..55b1c2da 100644 --- a/template/comment.twig +++ b/template/comment.twig @@ -19,7 +19,8 @@ target: 'comment', hash_id: comment.hashId, vote: votes[comment.id] is defined ? votes[comment.id].vote : null, - vote_count: comment.vote + vote_count: comment.vote, + user: user is defined ? user : null } only %} diff --git a/template/index.twig b/template/index.twig index 4c612e01..82ee1759 100644 --- a/template/index.twig +++ b/template/index.twig @@ -23,7 +23,8 @@ target: 'post', hash_id: post.hashId, vote: votes[post.id] is defined ? votes[post.id].vote : null, - vote_count: post.vote + vote_count: post.vote, + user: user is defined ? user : null } only %} diff --git a/template/post.twig b/template/post.twig index ef27fbc6..a917f061 100644 --- a/template/post.twig +++ b/template/post.twig @@ -18,7 +18,8 @@ target: 'post', hash_id: post.hashId, vote: votes.post[post.id] is defined ? votes.post[post.id].vote : null, - vote_count: post.vote + vote_count: post.vote, + user: user is defined ? user : null } only %} diff --git a/template/vote.twig b/template/vote.twig index 3288e0fa..c3f3c74d 100644 --- a/template/vote.twig +++ b/template/vote.twig @@ -5,17 +5,28 @@ # - hash_id: the post/comment hashId # - vote: (optional) the vote already cast by current logged in user # - vote_count: the sum of votes for this post/comment + # - user: reference to logged in user #} - - bump - - {# Show number of votes #} - {{ vote_count }} + {% if user %} + + + bump + - - sink - + {# Show number of votes #} + {{ vote_count }} + + + sink + + + {% else %} + + {{ vote_count ~ ' vote' ~ (vote_count != 1 ? 's') }} + + {% endif %} + \ No newline at end of file