2019-02-11 22:22:35 +00:00
|
|
|
defmodule FrenzyWeb.FeedView do
|
|
|
|
use FrenzyWeb, :view
|
2020-06-06 19:23:03 +00:00
|
|
|
alias Frenzy.Feed
|
2021-09-15 14:38:46 +00:00
|
|
|
import Phoenix.Controller, only: [current_path: 1]
|
2020-06-06 19:23:03 +00:00
|
|
|
|
|
|
|
@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
|
2021-08-28 15:58:22 +00:00
|
|
|
|
|
|
|
def title(:show, %{feed: %Feed{title: title}}) do
|
|
|
|
title
|
|
|
|
end
|
|
|
|
|
|
|
|
def title(:edit, %{feed: %Feed{title: title}}) do
|
|
|
|
"Edit #{title}"
|
|
|
|
end
|
2020-06-02 02:24:18 +00:00
|
|
|
end
|