23 lines
530 B
Elixir
23 lines
530 B
Elixir
defmodule FrenzyWeb.FeedView do
|
|
use FrenzyWeb, :view
|
|
alias Frenzy.Feed
|
|
import Phoenix.Controller, only: [current_path: 1]
|
|
|
|
@spec feed_site_url(feed :: Feed.t()) :: String.t()
|
|
def feed_site_url(%Feed{site_url: site_url}) when is_binary(site_url) do
|
|
site_url
|
|
end
|
|
|
|
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
|