fix: fetch the hostname from the url to print the current link

This commit is contained in:
danilo silva 2020-07-04 06:47:23 +00:00
parent 16d7d68032
commit 1ee361938e
2 changed files with 17 additions and 2 deletions

View file

@ -2,7 +2,7 @@
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:itunesu="http://www.itunesu.com/feed" version="2.0"> <rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:itunesu="http://www.itunesu.com/feed" version="2.0">
<channel> <channel>
<link><%= @podcast.link %></link> <link><%= @podcast.link %></link>
<language><![CDATA[<%= @podcast.language %>]]></language> <language><%= @podcast.language %></language>
<copyright>&#xA9;2022</copyright> <copyright>&#xA9;2022</copyright>
<webMaster><![CDATA[<%= @podcast.webmaster %>]]></webMaster> <webMaster><![CDATA[<%= @podcast.webmaster %>]]></webMaster>
<managingEditor><![CDATA[<%= @podcast.webmaster %>]]></managingEditor> <managingEditor><![CDATA[<%= @podcast.webmaster %>]]></managingEditor>
@ -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="<%= OpenpodWeb.Endpoint.url <> Routes.feed_path(@conn, :by_identifier, @identifier) %>" rel="self" type="application/rss+xml" /> <atom:link href="<%= base_url(@conn) <> 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>

View file

@ -6,4 +6,19 @@ defmodule OpenpodWeb.FeedView do
sec = length - (min * 60) |> Integer.to_string |> String.pad_leading(2, "0") sec = length - (min * 60) |> Integer.to_string |> String.pad_leading(2, "0")
"#{min}:#{sec}" "#{min}:#{sec}"
end end
def base_url(conn) do
scheme = conn
|> Map.fetch!(:scheme)
|> Atom.to_string
host = conn
|> Map.fetch!(:host)
port = conn
|> Map.fetch!(:port)
|> Integer.to_string
"#{scheme}://#{host}:#{port}"
end
end end