asciinema.org/web/views/user_view.ex
2017-06-02 15:40:24 +02:00

22 lines
479 B
Elixir

defmodule Asciinema.UserView do
alias Asciinema.{Gravatar, User}
def avatar_url(user) do
username = user_username(user)
email = user.email || "#{username}+#{user.id}@asciinema.org"
Gravatar.gravatar_url(email)
end
def profile_path(%User{id: id, username: username}) do
if username do
"/~#{username}"
else
"/u/#{id}"
end
end
defp user_username(user) do
user.username || user.temporary_username || "user:#{user.id}"
end
end