frenzy/lib/frenzy_web/views/layout_view.ex

36 lines
722 B
Elixir
Raw Normal View History

2019-02-11 17:22:35 -05:00
defmodule FrenzyWeb.LayoutView do
use FrenzyWeb, :view
2020-06-07 11:14:01 -04:00
alias Frenzy.{Repo, Group}
2019-11-09 13:21:45 -05: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 11:58:22 -04: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 17:22:35 -05:00
end