frenzy/lib/frenzy_web/views/layout_view.ex

36 lines
722 B
Elixir

defmodule FrenzyWeb.LayoutView do
use FrenzyWeb, :view
alias Frenzy.{Repo, Group}
import Ecto.Query
def user_groups(user) do
Repo.all(from g in Group, where: g.user_id == ^user.id, preload: [:feeds])
end
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
end