From 1f4104236b6840a2b29473672873e09263f11fba Mon Sep 17 00:00:00 2001 From: robs Date: Thu, 19 Dec 2024 22:34:23 +0100 Subject: [PATCH] change opml endpoint to be more inline with the other routes --- .../controllers/sources/source_html.ex | 2 +- lib/pinchflat_web/router.ex | 28 +++++++++---------- .../controllers/podcast_controller_test.exs | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/lib/pinchflat_web/controllers/sources/source_html.ex b/lib/pinchflat_web/controllers/sources/source_html.ex index 02c42c0..4692a04 100644 --- a/lib/pinchflat_web/controllers/sources/source_html.ex +++ b/lib/pinchflat_web/controllers/sources/source_html.ex @@ -44,7 +44,7 @@ defmodule PinchflatWeb.Sources.SourceHTML do end def opml_feed_url(conn) do - url(conn, ~p"/podcasts/opml") <> ".xml" + url(conn, ~p"/sources/opml") <> ".xml" end def output_path_template_override_placeholders(media_profiles) do diff --git a/lib/pinchflat_web/router.ex b/lib/pinchflat_web/router.ex index afcbe24..f7b7875 100644 --- a/lib/pinchflat_web/router.ex +++ b/lib/pinchflat_web/router.ex @@ -23,6 +23,20 @@ defmodule PinchflatWeb.Router do plug :maybe_basic_auth end + # Routes in here _may not be_ protected by basic auth. This is necessary for + # media streaming to work for RSS podcast feeds. + scope "/", PinchflatWeb do + pipe_through :feeds + # has to match before /sources/:id + get "/sources/opml", Podcasts.PodcastController, :opml_feed + + get "/sources/:uuid/feed", Podcasts.PodcastController, :rss_feed + get "/sources/:uuid/feed_image", Podcasts.PodcastController, :feed_image + get "/media/:uuid/episode_image", Podcasts.PodcastController, :episode_image + + get "/media/:uuid/stream", MediaItems.MediaItemController, :stream + end + scope "/", PinchflatWeb do pipe_through :browser @@ -48,20 +62,6 @@ defmodule PinchflatWeb.Router do end end - # Routes in here _may not be_ protected by basic auth. This is necessary for - # media streaming to work for RSS podcast feeds. - scope "/", PinchflatWeb do - pipe_through :feeds - - get "/podcasts/opml", Podcasts.PodcastController, :opml_feed - - get "/sources/:uuid/feed", Podcasts.PodcastController, :rss_feed - get "/sources/:uuid/feed_image", Podcasts.PodcastController, :feed_image - get "/media/:uuid/episode_image", Podcasts.PodcastController, :episode_image - - get "/media/:uuid/stream", MediaItems.MediaItemController, :stream - end - # No auth or CSRF protection for the health check endpoint scope "/", PinchflatWeb do pipe_through :api diff --git a/test/pinchflat_web/controllers/podcast_controller_test.exs b/test/pinchflat_web/controllers/podcast_controller_test.exs index ec79b76..ada823d 100644 --- a/test/pinchflat_web/controllers/podcast_controller_test.exs +++ b/test/pinchflat_web/controllers/podcast_controller_test.exs @@ -8,7 +8,7 @@ defmodule PinchflatWeb.PodcastControllerTest do test "renders the XML document", %{conn: conn} do source = source_fixture() - conn = get(conn, ~p"/podcasts/opml" <> ".xml") + conn = get(conn, ~p"/sources/opml" <> ".xml") assert conn.status == 200 assert {"content-type", "application/opml+xml; charset=utf-8"} in conn.resp_headers