Browse Source

removed hardcoding url

danilo silva 3 years ago
parent
commit
e374779c19

+ 4 - 4
lib/podcast_feed_web/controllers/feed_controller.ex

@@ -3,17 +3,17 @@ defmodule PodcastFeedWeb.FeedController do
   alias PodcastFeed.Boundary.ArchiveServer
 
   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
 
   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
 
-  defp do_by_identifier(conn, fetcher) do
+  defp do_by_identifier(conn, identifier, fetcher) do
     %{podcast: podcast, items: items} = fetcher.()
     conn
     |> put_resp_content_type("text/xml")
-    |> render("feed.xml", podcast: podcast, items: items)
+    |> render("feed.xml", identifier: identifier, podcast: podcast, items: items)
   end
 end

+ 1 - 1
lib/podcast_feed_web/templates/feed/feed.xml.eex

@@ -21,7 +21,7 @@
     <itunes:keywords><%= @podcast.keywords |> Enum.join(", ") %></itunes:keywords>
     <itunes:explicit><![CDATA[<%= @podcast.explicit %>]]></itunes:explicit>
     <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>
     <title><![CDATA[<%= @podcast.title %>]]></title>
     <itunes:author><![CDATA[<%= @podcast.owner.name %>]]></itunes:author>