Skip to content

Commit

Permalink
Minor improvements to feed view & template
Browse files Browse the repository at this point in the history
  • Loading branch information
jerodsanto committed Mar 1, 2024
1 parent dd94748 commit 2b8268e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/changelog_web/templates/feed/_show_notes.xml.eex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<%= if @plusplus do %>
<p>Thank you for supporting us with a Changelog++ membership! 🤗</p>
<% else %>
<p><a href="<%= Routes.page_url(Endpoint, :++) %>" rel="payment">Changelog++</a> <%= EpisodeView.plusplus_cta(@episode) %> Join today!</p>
<p><a href="<%= url(~p"/++") %>" rel="payment">Changelog++</a> <%= EpisodeView.plusplus_cta(@episode) %> Join today!</p>
<%= if Enum.any?(@episode.sponsors) do %>
<p>Sponsors:</p>
<p><ul>
Expand Down
11 changes: 6 additions & 5 deletions lib/changelog_web/templates/feed/podcast.xml.eex
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
<channel>
<title><%= @podcast |> podcast_name_with_metadata() |> escaped() %></title>
<copyright>All rights reserved</copyright>
<link><%= podcast_url(@conn, @podcast) %></link>
<link><%= podcast_url(@podcast) %></link>
<atom:link href="<%= PodcastView.feed_url(@podcast) %>" rel="self" type="application/rss+xml" />
<atom:link href="<%= podcast_url(@conn, @podcast) %>" rel="alternate" type="text/html" />
<atom:link href="<%= podcast_url(@podcast) %>" rel="alternate" type="text/html" />
<language>en-us</language>
<description><%= @podcast |> podcast_full_description() |> escaped() %></description>
<itunes:author>Changelog Media</itunes:author>
Expand All @@ -20,6 +20,7 @@
<itunes:image href="<%= PodcastView.cover_url(@podcast) %>"/>
<itunes:owner>
<itunes:name>Changelog Media</itunes:name>
<itunes:email>[email protected]</itunes:email>
</itunes:owner>
<itunes:keywords><%= @podcast.keywords %></itunes:keywords>
<itunes:category text="Technology">
Expand Down Expand Up @@ -47,7 +48,7 @@
<%= for episode <- @episodes do %>
<item>
<title><%= episode_title(@podcast, episode) |> escaped() %></title>
<link><%= Routes.episode_url(@conn, :show, episode.podcast.slug, episode.slug) %></link>
<link><%= url(~p"/#{episode.podcast.slug}/#{episode.slug}") %></link>
<guid isPermaLink="false"><%= EpisodeView.guid(episode) %></guid>
<pubDate><%= TimeView.rss(episode.published_at) %></pubDate>
<enclosure url="<%= EpisodeView.audio_url(episode) %>" length="<%= episode.audio_bytes %>" type="audio/mpeg" />
Expand All @@ -66,10 +67,10 @@
<%= render_many(episode.hosts, __MODULE__, "_person.xml", as: :person, role: "host") %>
<%= render_many(episode.guests, __MODULE__, "_person.xml", as: :person, role: "guest") %>
<%= if Episode.has_transcript(episode) do %>
<podcast:transcript url="<%= Routes.episode_url(@conn, :transcript, episode.podcast.slug, episode.slug) %>" type="text/html" />
<podcast:transcript url="<%= url(~p"/#{episode.podcast.slug}/#{episode.slug}/transcript") %>" type="text/html" />
<% end %>
<%= if Enum.any?(episode.audio_chapters) do %>
<podcast:chapters url="<%= Routes.episode_url(@conn, :chapters, episode.podcast.slug, episode.slug) %>" type="application/json+chapters" />
<podcast:chapters url="<%= url(~p"/#{episode.podcast.slug}/#{episode.slug}/chapters") %>" type="application/json+chapters" />
<% end %>
<%= if episode.socialize_url do %>
<podcast:socialInteract uri="<%= episode.socialize_url %>" protocol="activitypub" />
Expand Down
12 changes: 4 additions & 8 deletions lib/changelog_web/views/feed_view.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ defmodule ChangelogWeb.FeedView do
alias Changelog.{Episode, ListKit, NewsItem, Podcast, Post}

alias ChangelogWeb.{
Endpoint,
EpisodeView,
NewsItemView,
PersonView,
Expand All @@ -16,16 +15,13 @@ defmodule ChangelogWeb.FeedView do
def discussion_link(nil), do: ""

def discussion_link(episode = %Episode{}) do
Endpoint
|> Routes.episode_url(:discuss, episode.podcast.slug, episode.slug)
|> discussion_link()
url(~p"/#{episode.podcast.slug}/#{episode.slug}/discuss") |> discussion_link()
end

def discussion_link(post = %Post{}), do: discussion_link(post.news_item)

def discussion_link(item = %NewsItem{}) do
url = Routes.news_item_url(Endpoint, :show, NewsItemView.hashid(item))
discussion_link(url)
url(~p"/news/#{NewsItemView.hashid(item)}") |> discussion_link()
end

def discussion_link(url) when is_binary(url) do
Expand Down Expand Up @@ -72,9 +68,9 @@ defmodule ChangelogWeb.FeedView do
end

# Exists to special-case /interviews
def podcast_url(conn, podcast) do
def podcast_url(podcast) do
slug = if Podcast.is_interviews(podcast), do: "interviews", else: podcast.slug
Routes.podcast_url(conn, :show, slug)
url(~p"/#{slug}")
end

def render_item(item = %{object: episode = %Episode{}}, assigns) do
Expand Down

0 comments on commit 2b8268e

Please sign in to comment.