Skip to content

Commit

Permalink
change opml endpoint to be more inline with the other routes
Browse files Browse the repository at this point in the history
  • Loading branch information
robs committed Dec 19, 2024
1 parent 4cf7d35 commit 1f41042
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion lib/pinchflat_web/controllers/sources/source_html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions lib/pinchflat_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/pinchflat_web/controllers/podcast_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1f41042

Please sign in to comment.