Add page titles
This commit is contained in:
parent
5c8baa2057
commit
71a23faa90
|
@ -3,6 +3,10 @@ defmodule FrenzyWeb.EditPipelineLive do
|
|||
use Phoenix.HTML
|
||||
alias Frenzy.{Repo, Pipeline}
|
||||
|
||||
def title(%{pipeline: %Pipeline{name: name}}) do
|
||||
"Edit #{name}"
|
||||
end
|
||||
|
||||
@stages [
|
||||
{"Filter Stage", "Frenzy.Pipeline.FilterStage"},
|
||||
{"Scrape Stage", "Frenzy.Pipeline.ScrapeStage"},
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
|
||||
|
||||
<title>Frenzy</title>
|
||||
<title><%= title(assigns) %></title>
|
||||
|
||||
<%= csrf_meta_tag() %>
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
defmodule FrenzyWeb.AccountView do
|
||||
use FrenzyWeb, :view
|
||||
|
||||
def title(:show, _) do
|
||||
"Account Settings"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,4 +10,12 @@ defmodule FrenzyWeb.FeedView do
|
|||
def feed_site_url(%Feed{feed_url: feed_url}) do
|
||||
URI.merge(feed_url, "/") |> to_string()
|
||||
end
|
||||
|
||||
def title(:show, %{feed: %Feed{title: title}}) do
|
||||
title
|
||||
end
|
||||
|
||||
def title(:edit, %{feed: %Feed{title: title}}) do
|
||||
"Edit #{title}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
defmodule FrenzyWeb.GroupView do
|
||||
use FrenzyWeb, :view
|
||||
|
||||
def title(:index, _) do
|
||||
"Groups"
|
||||
end
|
||||
|
||||
def title(:show, %{group: %Frenzy.Group{title: title}}) do
|
||||
title
|
||||
end
|
||||
|
||||
def title(:edit, %{group: %Frenzy.Group{title: title}}) do
|
||||
"Edit #{title}"
|
||||
end
|
||||
|
||||
def title(:read, %{group: %Frenzy.Group{title: title}}) do
|
||||
"Read #{title}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
defmodule FrenzyWeb.ItemView do
|
||||
use FrenzyWeb, :view
|
||||
end
|
||||
|
||||
def title(:show, %{item: %Frenzy.Item{title: title}, feed: %Frenzy.Feed{title: feed}}) do
|
||||
"#{title} | #{feed}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -6,4 +6,30 @@ defmodule FrenzyWeb.LayoutView do
|
|||
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
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
defmodule FrenzyWeb.LoginView do
|
||||
use FrenzyWeb, :view
|
||||
|
||||
def title(_, _) do
|
||||
"Login"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,3 +1,19 @@
|
|||
defmodule FrenzyWeb.PipelineView do
|
||||
use FrenzyWeb, :view
|
||||
|
||||
def title(:index, _) do
|
||||
"Pipelines"
|
||||
end
|
||||
|
||||
def title(:new, _) do
|
||||
"Add Pipeline"
|
||||
end
|
||||
|
||||
def title(:show, %{pipeline: %Frenzy.Pipeline{name: name}}) do
|
||||
name
|
||||
end
|
||||
|
||||
def title(:edit, %{pipeline: %Frenzy.Pipeline{name: name}}) do
|
||||
"Edit #{name}"
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue