frenzy/lib/frenzy_web/views/layout_view.ex

36 lines
722 B
Elixir
Raw Normal View History

2019-02-11 22:22:35 +00:00
defmodule FrenzyWeb.LayoutView do
use FrenzyWeb, :view
2020-06-07 15:14:01 +00:00
alias Frenzy.{Repo, Group}
2019-11-09 18:21:45 +00:00
import Ecto.Query
def user_groups(user) do
Repo.all(from g in Group, where: g.user_id == ^user.id, preload: [:feeds])
end
2021-08-28 15:58:22 +00:00
def title(%{live_module: module} = assigns) do
try do
"#{module.title(assigns)} | Frenzy"
rescue
_ ->
"Frenzy"
end
end
def title(assigns) do
vm = Phoenix.Controller.view_module(assigns[:conn])
if function_exported?(vm, :title, 2) do
action = Phoenix.Controller.action_name(assigns[:conn])
try do
"#{vm.title(action, assigns)} | Frenzy"
rescue
_ ->
"Frenzy"
end
else
"Frenzy"
end
end
2019-02-11 22:22:35 +00:00
end