From af9d6ddab3e3a893fd4709fa239955844ffc67ec Mon Sep 17 00:00:00 2001
From: Steffen van Bergerem <svbergerem@online.de>
Date: Tue, 10 Mar 2015 16:31:36 +0100
Subject: [PATCH] Use handlebars helpers wherever possible

---
 app/assets/stylesheets/stream_element.scss      |  4 ++--
 app/assets/templates/comment_tpl.jst.hbs        | 10 ++++------
 app/assets/templates/header_tpl.jst.hbs         |  2 +-
 app/assets/templates/likes-info_tpl.jst.hbs     |  8 +++-----
 app/assets/templates/reshare_tpl.jst.hbs        |  6 ++++--
 app/assets/templates/stream-element_tpl.jst.hbs |  6 +++---
 features/step_definitions/hovercard_steps.rb    |  2 +-
 7 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/app/assets/stylesheets/stream_element.scss b/app/assets/stylesheets/stream_element.scss
index 3c1ca3cc0b..a0f6a4d83e 100644
--- a/app/assets/stylesheets/stream_element.scss
+++ b/app/assets/stylesheets/stream_element.scss
@@ -53,12 +53,12 @@
         width: 50px;
       }
     }
-    .author {
+    .author-name {
       font-weight: bold;
       margin-bottom: 4px;
       unicode-bidi: bidi-override;
     }
-    a.author { color: $blue; }
+    a.author-name { color: $blue; }
     .feedback {
       margin-top: 5px;
       font-size: 11px;
diff --git a/app/assets/templates/comment_tpl.jst.hbs b/app/assets/templates/comment_tpl.jst.hbs
index 3196cad332..b2c54c698f 100644
--- a/app/assets/templates/comment_tpl.jst.hbs
+++ b/app/assets/templates/comment_tpl.jst.hbs
@@ -20,16 +20,14 @@
     {{/if}}
     </div>
 
-    {{#with author}}
-      <a href="/people/{{guid}}" class="author author-name {{hovercardable this}}">
-        {{name}}
-      </a>
-    {{/with}}
+    {{#linkToAuthor author}}
+      {{name}}
+    {{/linkToAuthor}}
 
     <div class="collapsible comment-content">
       {{{text}}}
     </div>
-    
+
     <div class="info">
       <a href="/posts/{{parent.id}}#{{guid}}" class="permalink_comment">
         <time class="timeago" data-original-title="{{{localTime created_at}}}" datetime="{{created_at}}"/>
diff --git a/app/assets/templates/header_tpl.jst.hbs b/app/assets/templates/header_tpl.jst.hbs
index 0361701e09..ab3ebc62cf 100644
--- a/app/assets/templates/header_tpl.jst.hbs
+++ b/app/assets/templates/header_tpl.jst.hbs
@@ -72,7 +72,7 @@
       <div class="user-menu-more-indicator">
         â–¼
       </div>
-      <img alt="{{current_user.name}}" class="avatar user-menu-avatar" src="{{current_user.avatar.small}}" title="{{current_user.name}}" />
+      {{{personImage current_user 'small' 'avatar user-menu-avatar'}}}
       <a class="user-name" href="#">{{current_user.name}}</a>
     </li>
     <li class="user-menu-item"><a href="/people/{{current_user.guid}}">{{t "header.profile"}}</a></li>
diff --git a/app/assets/templates/likes-info_tpl.jst.hbs b/app/assets/templates/likes-info_tpl.jst.hbs
index c9cfceee12..71206eb503 100644
--- a/app/assets/templates/likes-info_tpl.jst.hbs
+++ b/app/assets/templates/likes-info_tpl.jst.hbs
@@ -12,11 +12,9 @@
         {{else}}
 
           {{#each likes}}
-            {{#with author}}
-              <a href="/people/{{guid}}" class="{{hovercardable this}}">
-                <img src="{{avatar.small}}" class="avatar micro" title="{{name}}"/>
-              </a>
-            {{/with}}
+            {{#linkToAuthor author}}
+              {{{personImage this 'small' 'micro'}}}
+            {{/linkToAuthor}}
           {{/each}}
         {{/unless}}
       </div>
diff --git a/app/assets/templates/reshare_tpl.jst.hbs b/app/assets/templates/reshare_tpl.jst.hbs
index ef7b821f29..a1a6616588 100644
--- a/app/assets/templates/reshare_tpl.jst.hbs
+++ b/app/assets/templates/reshare_tpl.jst.hbs
@@ -6,14 +6,16 @@
 
       {{#with root}}
         <a href="/people/{{author.guid}}" class="img {{{hovercardable this}}}">
-          <img src="{{author.avatar.small}}" class="avatar" />
+          {{{personImage author 'small'}}}
         </a>
       {{/with}}
 
       {{#with root}}
         <div class="bd">
           <div>
-            <a href="/people/{{author.guid}}" class="author {{{hovercardable author}}}">{{author.name}}</a>
+            {{#linkToAuthor author}}
+              {{name}}
+            {{/linkToAuthor}}
 
             <span class="details grey">
               -
diff --git a/app/assets/templates/stream-element_tpl.jst.hbs b/app/assets/templates/stream-element_tpl.jst.hbs
index 4ed0daeb95..f3a96b1a86 100644
--- a/app/assets/templates/stream-element_tpl.jst.hbs
+++ b/app/assets/templates/stream-element_tpl.jst.hbs
@@ -37,9 +37,9 @@
     {{/if}}
 
     <div>
-      {{#with author}}
-        <a href="/people/{{guid}}" class="author {{{hovercardable this}}}">{{name}}</a>
-      {{/with}}
+      {{#linkToAuthor author}}
+        {{name}}
+      {{/linkToAuthor}}
 
       <span class="details grey">
         -
diff --git a/features/step_definitions/hovercard_steps.rb b/features/step_definitions/hovercard_steps.rb
index ab086fb10e..c76e481e7e 100644
--- a/features/step_definitions/hovercard_steps.rb
+++ b/features/step_definitions/hovercard_steps.rb
@@ -16,6 +16,6 @@ end
 
 When (/^I hover "([^"]*)" within "([^"]*)"$/) do |name, selector|
   with_scope(selector) do
-    find(".author", text: name).hover
+    find(".author-name", text: name).hover
   end
 end
-- 
GitLab