diff --git a/lib/pinchflat/workers/media_indexing_worker.ex b/lib/pinchflat/workers/media_indexing_worker.ex index e8e5b37..52b4849 100644 --- a/lib/pinchflat/workers/media_indexing_worker.ex +++ b/lib/pinchflat/workers/media_indexing_worker.ex @@ -48,6 +48,7 @@ defmodule Pinchflat.Workers.MediaIndexingWorker do defp index_media_and_reschedule(source) do SourceTasks.index_media_items(source) + # This method handles the case where a source is set to not download media SourceTasks.enqueue_pending_media_downloads(source) source diff --git a/lib/pinchflat_web/controllers/media/media_item_controller.ex b/lib/pinchflat_web/controllers/media/media_item_controller.ex new file mode 100644 index 0000000..3db81d4 --- /dev/null +++ b/lib/pinchflat_web/controllers/media/media_item_controller.ex @@ -0,0 +1,11 @@ +defmodule PinchflatWeb.Media.MediaItemController do + use PinchflatWeb, :controller + + alias Pinchflat.Media + + def show(conn, %{"id" => id}) do + media_item = Media.get_media_item!(id) + + render(conn, :show, media_item: media_item) + end +end diff --git a/lib/pinchflat_web/controllers/media/media_item_html.ex b/lib/pinchflat_web/controllers/media/media_item_html.ex new file mode 100644 index 0000000..d0c0667 --- /dev/null +++ b/lib/pinchflat_web/controllers/media/media_item_html.ex @@ -0,0 +1,5 @@ +defmodule PinchflatWeb.Media.MediaItemHTML do + use PinchflatWeb, :html + + embed_templates "media_item_html/*" +end diff --git a/lib/pinchflat_web/controllers/media/media_item_html/show.html.heex b/lib/pinchflat_web/controllers/media/media_item_html/show.html.heex new file mode 100644 index 0000000..ac65a28 --- /dev/null +++ b/lib/pinchflat_web/controllers/media/media_item_html/show.html.heex @@ -0,0 +1,18 @@ +
Nothing Here!
+ <% end %> + +Nothing Here!
+ <% end %> diff --git a/lib/pinchflat_web/router.ex b/lib/pinchflat_web/router.ex index 3610003..55f177a 100644 --- a/lib/pinchflat_web/router.ex +++ b/lib/pinchflat_web/router.ex @@ -20,7 +20,11 @@ defmodule PinchflatWeb.Router do get "/", PageController, :home resources "/media_profiles", MediaProfiles.MediaProfileController - resources "/sources", MediaSources.SourceController + resources "/media", Media.MediaItemController, only: [:show] + + resources "/sources", MediaSources.SourceController do + resources "/media", Media.MediaItemController, only: [:show] + end end # Other scopes may use custom stacks. diff --git a/test/pinchflat_web/controllers/media_item_controller_test.exs b/test/pinchflat_web/controllers/media_item_controller_test.exs new file mode 100644 index 0000000..eb0eab2 --- /dev/null +++ b/test/pinchflat_web/controllers/media_item_controller_test.exs @@ -0,0 +1,19 @@ +defmodule PinchflatWeb.MediaItemControllerTest do + use PinchflatWeb.ConnCase + + import Pinchflat.MediaFixtures + + describe "show media" do + setup [:create_media_item] + + test "renders the page", %{conn: conn, media_item: media_item} do + conn = get(conn, ~p"/media/#{media_item}") + assert html_response(conn, 200) =~ "Media Item ##{media_item.id}" + end + end + + defp create_media_item(_) do + media_item = media_item_fixture() + %{media_item: media_item} + end +end