From 776e5d35c1e3cc3d242f37c6e99b1ab2bb306fe3 Mon Sep 17 00:00:00 2001 From: Jerod Santo Date: Tue, 13 Aug 2024 13:01:19 -0500 Subject: [PATCH] Link up podcast & clips playlists on YouTube --- assets/app/layout/show.scss | 10 +++--- .../images/icons/podcast_icon-youtube.png | Bin 0 -> 1793 bytes lib/changelog/schema/podcast/podcast.ex | 19 +++++++---- lib/changelog_web/plugs/vanity_domains.ex | 1 + .../templates/admin/podcast/_form.html.heex | 12 +++++++ .../templates/podcast/_feed.html.eex | 27 --------------- .../templates/podcast/_feed.html.heex | 32 ++++++++++++++++++ .../podcast/_subscribe_buttons.html.heex | 9 +++-- .../podcast/_subscribe_tooltip.html.heex | 9 +++-- lib/changelog_web/views/podcast_view.ex | 5 +++ ...813144053_add_youtube_urls_to_podcasts.exs | 11 ++++++ 11 files changed, 94 insertions(+), 41 deletions(-) create mode 100644 assets/static/images/icons/podcast_icon-youtube.png delete mode 100644 lib/changelog_web/templates/podcast/_feed.html.eex create mode 100644 lib/changelog_web/templates/podcast/_feed.html.heex create mode 100644 priv/repo/migrations/20240813144053_add_youtube_urls_to_podcasts.exs diff --git a/assets/app/layout/show.scss b/assets/app/layout/show.scss index 19fd8beb2b..1b795bb30d 100644 --- a/assets/app/layout/show.scss +++ b/assets/app/layout/show.scss @@ -233,13 +233,12 @@ flex-wrap: wrap; &-item { - height: 20px; + height: 30px; margin: 0 8px 12px; padding: 4px 0 0 30px; - background-size: 20px 20px; + background-size: 30px 30px; background-repeat: no-repeat; - font-size: 0.74em; - line-height: 1; + font-size: 0; color: $white; transition: color 0.1s $base-easing; @@ -270,6 +269,9 @@ &--youtube-music { background-image: url("../images/icons/podcast_icon-youtube-music.png"); } + &--youtube { + background-image: url("../images/icons/podcast_icon-youtube.png"); + } &--bandcamp { background-image: url("../images/icons/podcast_icon-bandcamp.png"); } diff --git a/assets/static/images/icons/podcast_icon-youtube.png b/assets/static/images/icons/podcast_icon-youtube.png new file mode 100644 index 0000000000000000000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0sg>P%D#w4AM%hS{R)lnw#QRN=;0{OL1Jc^R=1V0BRM9x9!7oM zhU;Y3?13t0pUZOz+TXFFjc!9!|IPyg`{-87=v7yJDso|Lre${AcH74hMM&Vo)h;;7 z+s4r>dYgUsSG(XIU*qk0!2x~WG{x|l>f9zJkY@1I4*gsidOr@dcRoV{5Ty#wcM4E;2I3tyuU{O3WKekmj!J0dG7wkz+upsmzLfaf!No0_gd{|RCjU;MG&rq0$em;2sP zr>om9Ne9PtM^Wk!V~BGY6f=S{){hyZ0W%W=vjMW%h?MzYQnZZLHK~v#GsH%|QJ%(( zS(l1pXg%ZF*et-*KVzKAn+=o_gg{8o8`W( zU%u0_YU?*xb5h9OJHFef|2-)=d}7dVad2W0|sf^Q!pf z&27EjW?_%Z#}72LawEFGF|V|+M Person.newest_first() |> Repo.all() } @@ -135,7 +142,7 @@ defmodule Changelog.Podcast do podcast |> cast( attrs, - ~w(name slug status vanity_domain schedule_note welcome description extended_description keywords mastodon_handle mastodon_token twitter_handle apple_url spotify_url riverside_url chartable_id recorded_live partner position)a + ~w(name slug status vanity_domain schedule_note welcome description extended_description keywords mastodon_handle mastodon_token twitter_handle apple_url spotify_url riverside_url youtube_url clips_url recorded_live partner position)a ) |> validate_required([:name, :slug, :status]) |> validate_format(:vanity_domain, Regexp.http(), message: Regexp.http_message()) diff --git a/lib/changelog_web/plugs/vanity_domains.ex b/lib/changelog_web/plugs/vanity_domains.ex index c771664c7d..19f5688943 100644 --- a/lib/changelog_web/plugs/vanity_domains.ex +++ b/lib/changelog_web/plugs/vanity_domains.ex @@ -75,6 +75,7 @@ defmodule ChangelogWeb.Plug.VanityDomains do ["apple"] -> PodcastView.subscribe_on_apple_url(podcast) ["android"] -> PodcastView.subscribe_on_android_url(podcast) ["spotify"] -> PodcastView.subscribe_on_spotify_url(podcast) + ["youtube"] -> PodcastView.subscribe_on_youtube_url(podcast) ["overcast"] -> PodcastView.subscribe_on_overcast_url(podcast) ["pcast"] -> PodcastView.subscribe_on_pocket_casts_url(podcast) ["rss"] -> changelog_destination([podcast.slug, "feed"]) diff --git a/lib/changelog_web/templates/admin/podcast/_form.html.heex b/lib/changelog_web/templates/admin/podcast/_form.html.heex index 5ae62b8d8f..36dfb75204 100644 --- a/lib/changelog_web/templates/admin/podcast/_form.html.heex +++ b/lib/changelog_web/templates/admin/podcast/_form.html.heex @@ -198,6 +198,18 @@ <%= AdminHelpers.error_message(f, :riverside_url) %> +
+ <%= label(f, :youtube_url, "YouTube URL") %> + <%= text_input(f, :youtube_url) %> + <%= AdminHelpers.error_message(f, :youtube_url) %> +
+ +
+ <%= label(f, :clips_url, "Clips URL") %> + <%= text_input(f, :clips_url) %> + <%= AdminHelpers.error_message(f, :clips_url) %> +
+
<%= if !AdminHelpers.is_persisted(f.data) do %> diff --git a/lib/changelog_web/templates/podcast/_feed.html.eex b/lib/changelog_web/templates/podcast/_feed.html.eex deleted file mode 100644 index 9faaa4c462..0000000000 --- a/lib/changelog_web/templates/podcast/_feed.html.eex +++ /dev/null @@ -1,27 +0,0 @@ -<%= if @podcast.status == :inactive do %> -

This podcast is not in production. Please browse and enjoy the archive below.

-<% end %> - - - -<%= if Enum.any?(@page) do %> - <%= render_many(@page, EpisodeView, "_item.html") %> - <%= render(SharedView, "_more_button.html", assigns) %> -<% else %> -

Nothing to see here. Move along.

-<% end %> diff --git a/lib/changelog_web/templates/podcast/_feed.html.heex b/lib/changelog_web/templates/podcast/_feed.html.heex new file mode 100644 index 0000000000..8dc58fffaa --- /dev/null +++ b/lib/changelog_web/templates/podcast/_feed.html.heex @@ -0,0 +1,32 @@ +<%= if @podcast.status == :inactive do %> +

This podcast is not in production. Please browse and enjoy the archive below.

+<% end %> + + + +<%= if Enum.any?(@page) do %> + <%= render_many(@page, EpisodeView, "_item.html") %> + <%= render(SharedView, "_more_button.html", assigns) %> +<% else %> +

Nothing to see here. Move along.

+<% end %> diff --git a/lib/changelog_web/templates/podcast/_subscribe_buttons.html.heex b/lib/changelog_web/templates/podcast/_subscribe_buttons.html.heex index 52578851df..190fb76d58 100644 --- a/lib/changelog_web/templates/podcast/_subscribe_buttons.html.heex +++ b/lib/changelog_web/templates/podcast/_subscribe_buttons.html.heex @@ -4,11 +4,16 @@ <%= link("RSS", to: subscribe_via_rss_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--rss", title: "Subscribe via RSS") %> <%= if @podcast.apple_url do %> <%= link("Apple", to: subscribe_on_apple_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--apple", title: "Subscribe on Apple") %> - <%= link("Overcast", to: subscribe_on_overcast_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--overcast", title: "Subscribe on Overcast") %> - <%= link("Pocket Casts", to: subscribe_on_pocket_casts_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--pocket-casts", title: "Subscribe on Pocket Casts") %> <% end %> <%= if @podcast.spotify_url do %> <%= link("Spotify", to: subscribe_on_spotify_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--spotify", title: "Subscribe on Spotify") %> + <% end %> + <%= if @podcast.youtube_url do %> + <%= link("YouTube", to: subscribe_on_youtube_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--youtube", title: "Subscribe on YouTube") %> + <% end %> + <%= if @podcast.apple_url do %> + <%= link("Overcast", to: subscribe_on_overcast_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--overcast", title: "Subscribe on Overcast") %> + <%= link("Pocket Casts", to: subscribe_on_pocket_casts_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--pocket-casts", title: "Subscribe on Pocket Casts") %> <% end %> <%= link("Android", to: subscribe_on_android_url(@podcast), class: "show-header-subscribe-buttons-item show-header-subscribe-buttons-item--android", title: "Subscribe on Android") %> <%= if @podcast.mastodon_handle do %> diff --git a/lib/changelog_web/templates/podcast/_subscribe_tooltip.html.heex b/lib/changelog_web/templates/podcast/_subscribe_tooltip.html.heex index a4e24a9912..d4230e0fd7 100644 --- a/lib/changelog_web/templates/podcast/_subscribe_tooltip.html.heex +++ b/lib/changelog_web/templates/podcast/_subscribe_tooltip.html.heex @@ -6,11 +6,16 @@
  • <%= link("Direct (RSS)", to: subscribe_via_rss_url(@podcast)) %>
  • <%= if @podcast.apple_url do %>
  • <%= link("Apple Podcasts", to: subscribe_on_apple_url(@podcast)) %>
  • -
  • <%= link("Overcast", to: subscribe_on_overcast_url(@podcast)) %>
  • -
  • <%= link("Pocket Casts", to: subscribe_on_pocket_casts_url(@podcast)) %>
  • <% end %> <%= if @podcast.spotify_url do %>
  • <%= link("Spotify", to: subscribe_on_spotify_url(@podcast)) %>
  • + <% end %> + <%= if @podcast.youtube_url do %> +
  • <%= link("YouTube", to: subscribe_on_youtube_url(@podcast)) %>
  • + <% end %> + <%= if @podcast.apple_url do %> +
  • <%= link("Overcast", to: subscribe_on_overcast_url(@podcast)) %>
  • +
  • <%= link("Pocket Casts", to: subscribe_on_pocket_casts_url(@podcast)) %>
  • <% end %>
  • <%= link("Android", to: subscribe_on_android_url(@podcast)) %>
  • <%= if @podcast.mastodon_handle do %> diff --git a/lib/changelog_web/views/podcast_view.ex b/lib/changelog_web/views/podcast_view.ex index 3765e0d225..91ddd0f6ac 100644 --- a/lib/changelog_web/views/podcast_view.ex +++ b/lib/changelog_web/views/podcast_view.ex @@ -136,6 +136,11 @@ defmodule ChangelogWeb.PodcastView do def subscribe_on_spotify_url(podcast), do: podcast.spotify_url + def subscribe_on_youtube_url(%{vanity_domain: vanity}) when not is_nil(vanity), + do: vanity <> "/youtube" + + def subscribe_on_youtube_url(podcast), do: podcast.youtube_url + def subscribe_via_rss_url(%{vanity_domain: vanity}) when not is_nil(vanity), do: vanity <> "/rss" diff --git a/priv/repo/migrations/20240813144053_add_youtube_urls_to_podcasts.exs b/priv/repo/migrations/20240813144053_add_youtube_urls_to_podcasts.exs new file mode 100644 index 0000000000..bd0a1dc195 --- /dev/null +++ b/priv/repo/migrations/20240813144053_add_youtube_urls_to_podcasts.exs @@ -0,0 +1,11 @@ +defmodule Changelog.Repo.Migrations.AddYoutubeUrlsToPodcasts do + use Ecto.Migration + + def change do + alter table(:podcasts) do + add :youtube_url, :string + add :clips_url, :string + remove :chartable_id + end + end +end