Commit f39a36385aab779dea46f70221b4617eef9a1da2

Thomas de Grivel 2022-01-22T12:15:51

move avatar partial

diff --git a/lib/kmxgit_web/templates/repository/avatar.html.heex b/lib/kmxgit_web/templates/repository/avatar.html.heex
deleted file mode 100644
index d7ba2f6..0000000
--- a/lib/kmxgit_web/templates/repository/avatar.html.heex
+++ /dev/null
@@ -1,6 +0,0 @@
-<% user = Kmxgit.UserManager.get_user_by_email(@email) %>
-<%= if user do %>
-  <%= link to: Routes.slug_path(@conn, :show, user.slug.slug) do %><img src={Exgravatar.gravatar_url(@email, s: @size)} alt={@title} title={@title} class={@class} /><% end %>
-<% else %>
-  <img src={Exgravatar.gravatar_url(@email, s: @size)} alt={@title} title={@title} class={@class} />
-<% end %>
diff --git a/lib/kmxgit_web/templates/repository/log.html.heex b/lib/kmxgit_web/templates/repository/log.html.heex
index feff839..b02443b 100644
--- a/lib/kmxgit_web/templates/repository/log.html.heex
+++ b/lib/kmxgit_web/templates/repository/log.html.heex
@@ -31,7 +31,7 @@
           <%= for commit <- @log do %>
             <tr class="commit">
               <td class="author">
-                <%= render("avatar.html", conn: @conn, email: commit.author_email, size: 48, title: commit.author, class: "") %>
+                <%= render(KmxgitWeb.UserView, "avatar.html", conn: @conn, email: commit.author_email, size: 48, title: commit.author, class: "") %>
               </td>
               <td class="hash">
                 <%= link String.slice(commit.hash, 0..7), id: commit.hash, to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_commit", @git.log1.hash])) %>
diff --git a/lib/kmxgit_web/templates/repository/show_commit_message.html.heex b/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
index 198acc4..26071c1 100644
--- a/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
@@ -1,5 +1,5 @@
 <div class="log1">
-  <%= render("avatar.html", conn: @conn, email: @git.log1.author_email, size: 48, title: @git.log1.author, class: "commit-avatar") %>
+  <%= render(KmxgitWeb.UserView, "avatar.html", conn: @conn, email: @git.log1.author_email, size: 48, title: @git.log1.author, class: "commit-avatar") %>
   <span class="hash">
     <%= link String.slice(@git.log1.hash, 0..8), to: Routes.repository_path(@conn, :show, Repository.owner_slug(@repo), Repository.splat(@repo, ["_log", @tree] ++ (if @path, do: String.split(@path, "/"), else: []))) <> "##{@git.log1.hash}" %>
   </span>
diff --git a/lib/kmxgit_web/templates/repository/show_properties.html.heex b/lib/kmxgit_web/templates/repository/show_properties.html.heex
index 6ef13f6..fdb26b3 100644
--- a/lib/kmxgit_web/templates/repository/show_properties.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_properties.html.heex
@@ -42,7 +42,7 @@
     </th>
     <td>
       <%= for user <- @members do %>
-        <%= render("avatar.html", conn: @conn, email: user.email, size: 48, title: user.slug.slug, class: "") %>
+        <%= render(KmxgitWeb.UserView, "avatar.html", conn: @conn, email: user.email, size: 48, title: user.slug.slug, class: "") %>
       <% end %>
     </td>
   </tr>
diff --git a/lib/kmxgit_web/templates/user/avatar.html.heex b/lib/kmxgit_web/templates/user/avatar.html.heex
new file mode 100644
index 0000000..d7ba2f6
--- /dev/null
+++ b/lib/kmxgit_web/templates/user/avatar.html.heex
@@ -0,0 +1,6 @@
+<% user = Kmxgit.UserManager.get_user_by_email(@email) %>
+<%= if user do %>
+  <%= link to: Routes.slug_path(@conn, :show, user.slug.slug) do %><img src={Exgravatar.gravatar_url(@email, s: @size)} alt={@title} title={@title} class={@class} /><% end %>
+<% else %>
+  <img src={Exgravatar.gravatar_url(@email, s: @size)} alt={@title} title={@title} class={@class} />
+<% end %>