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