removed hardcoding url

This commit is contained in:
danilo silva 2020-06-07 21:09:53 +00:00
parent 64de0b9a88
commit e374779c19
2 changed files with 5 additions and 5 deletions

View file

@ -3,17 +3,17 @@ defmodule PodcastFeedWeb.FeedController do
alias PodcastFeed.Boundary.ArchiveServer alias PodcastFeed.Boundary.ArchiveServer
def by_identifier(conn, %{"identifier" => identifier, "reload" => _}) do def by_identifier(conn, %{"identifier" => identifier, "reload" => _}) do
do_by_identifier(conn, fn -> ArchiveServer.reload(identifier) end) do_by_identifier(conn, identifier, fn -> ArchiveServer.reload(identifier) end)
end end
def by_identifier(conn, %{"identifier" => identifier}) do def by_identifier(conn, %{"identifier" => identifier}) do
do_by_identifier(conn, fn -> ArchiveServer.get_feed(identifier) end) do_by_identifier(conn, identifier, fn -> ArchiveServer.get_feed(identifier) end)
end end
defp do_by_identifier(conn, fetcher) do defp do_by_identifier(conn, identifier, fetcher) do
%{podcast: podcast, items: items} = fetcher.() %{podcast: podcast, items: items} = fetcher.()
conn conn
|> put_resp_content_type("text/xml") |> put_resp_content_type("text/xml")
|> render("feed.xml", podcast: podcast, items: items) |> render("feed.xml", identifier: identifier, podcast: podcast, items: items)
end end
end end

View file

@ -21,7 +21,7 @@
<itunes:keywords><%= @podcast.keywords |> Enum.join(", ") %></itunes:keywords> <itunes:keywords><%= @podcast.keywords |> Enum.join(", ") %></itunes:keywords>
<itunes:explicit><![CDATA[<%= @podcast.explicit %>]]></itunes:explicit> <itunes:explicit><![CDATA[<%= @podcast.explicit %>]]></itunes:explicit>
<itunes:image href="<%= @podcast.image.url %>" /> <itunes:image href="<%= @podcast.image.url %>" />
<atom:link href="http://www.ape-alveare.it/podcast.xml" rel="self" type="application/rss+xml" /> <atom:link href="<%= PodcastFeedWeb.Endpoint.url <> Routes.feed_path(@conn, :by_identifier, @identifier) %>" rel="self" type="application/rss+xml" />
<pubDate><%= @podcast.pubDate |> Calendar.DateTime.Format.rfc2822 %></pubDate> <pubDate><%= @podcast.pubDate |> Calendar.DateTime.Format.rfc2822 %></pubDate>
<title><![CDATA[<%= @podcast.title %>]]></title> <title><![CDATA[<%= @podcast.title %>]]></title>
<itunes:author><![CDATA[<%= @podcast.owner.name %>]]></itunes:author> <itunes:author><![CDATA[<%= @podcast.owner.name %>]]></itunes:author>