Commit 86f7a1afc6c3f931970532e4cfe01b80163b0d6f

Thomas de Grivel 2022-01-22T11:41:08

avatar with link to profile page if found

diff --git a/lib/kmxgit_web.ex b/lib/kmxgit_web.ex
index ac2e890..5c56545 100644
--- a/lib/kmxgit_web.ex
+++ b/lib/kmxgit_web.ex
@@ -57,15 +57,15 @@ defmodule KmxgitWeb do
 
       alias Kmxgit.UserManager.User
 
-      def recaptcha_site_key do
-        Application.get_env :kmxgit, :recaptcha_site_key
-      end
-
       def disk_usage(size) do
         FileSize.new(size, :kb)
         |> FileSize.convert(:mb)
         |> FileSize.to_string()
       end
+
+      def recaptcha_site_key do
+        Application.get_env :kmxgit, :recaptcha_site_key
+      end
     end
   end
 
diff --git a/lib/kmxgit_web/templates/repository/avatar.html.heex b/lib/kmxgit_web/templates/repository/avatar.html.heex
new file mode 100644
index 0000000..1445e6b
--- /dev/null
+++ b/lib/kmxgit_web/templates/repository/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} /><% end %>
+<% else %>
+  <img src={Exgravatar.gravatar_url(@email, s: @size)} alt={@title} title={@title} />
+<% end %>
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 7bf2ce2..47e840d 100644
--- a/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
+++ b/lib/kmxgit_web/templates/repository/show_commit_message.html.heex
@@ -2,9 +2,7 @@
   <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>
-  <span class="author">
-    <img src={Exgravatar.gravatar_url(@git.log1.author_email, s: 32)} alt={@git.log1.author} title={@git.log1.author} />
-  </span>
+  <%= render("avatar.html", conn: @conn, email: @git.log1.author_email, size: 32, title: @git.log1.author) %>
   <span class="date">
     <%= @git.log1.date |> String.replace("T", " ") |> String.replace("+", " +") %>
   </span>