From 7879e7202f9fbf761a8bf3cde57f6e2fce2a7129 Mon Sep 17 00:00:00 2001 From: Kieran Eglin Date: Tue, 26 Mar 2024 10:23:15 -0700 Subject: [PATCH] [WIP] Adding UI for getting RSS feed --- .../components/core_components.ex | 5 +- .../custom_components/button_components.ex | 52 +++++++++++++++- .../custom_components/tab_components.ex | 31 ++++++---- .../controllers/sources/source_html.ex | 7 +++ .../sources/source_html/show.html.heex | 61 ++++++++++++------- lib/pinchflat_web/router.ex | 2 +- 6 files changed, 120 insertions(+), 38 deletions(-) diff --git a/lib/pinchflat_web/components/core_components.ex b/lib/pinchflat_web/components/core_components.ex index 52295d0..ee4c4da 100644 --- a/lib/pinchflat_web/components/core_components.ex +++ b/lib/pinchflat_web/components/core_components.ex @@ -14,7 +14,7 @@ defmodule PinchflatWeb.CoreComponents do Icons are provided by [heroicons](https://heroicons.com). See `icon/1` for usage. """ - use Phoenix.Component + use Phoenix.Component, global_prefixes: ~w(x-) import PinchflatWeb.Gettext @@ -654,10 +654,11 @@ defmodule PinchflatWeb.CoreComponents do """ attr :name, :string, required: true attr :class, :string, default: nil + attr :rest, :global def icon(%{name: "hero-" <> _} = assigns) do ~H""" - + """ end diff --git a/lib/pinchflat_web/components/custom_components/button_components.ex b/lib/pinchflat_web/components/custom_components/button_components.ex index c6f6e01..5e9ebe7 100644 --- a/lib/pinchflat_web/components/custom_components/button_components.ex +++ b/lib/pinchflat_web/components/custom_components/button_components.ex @@ -1,6 +1,8 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do @moduledoc false - use Phoenix.Component + use Phoenix.Component, global_prefixes: ~w(x-) + + alias PinchflatWeb.CoreComponents @doc """ Render a button @@ -39,4 +41,52 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do """ end + + @doc """ + Render a dropdown based off a button + + ## Examples + + <.button_dropdown text="Actions"> + <:option>TEST + + """ + attr :text, :string, required: true + attr :class, :string, default: "" + + slot :option, required: true + + def button_dropdown(assigns) do + ~H""" +
+ + <%= @text %> + + +
+
    +
  • + + <%= render_slot(option) %> + +
  • +
+
+
+ """ + end end diff --git a/lib/pinchflat_web/components/custom_components/tab_components.ex b/lib/pinchflat_web/components/custom_components/tab_components.ex index 1b0ae22..3e6876d 100644 --- a/lib/pinchflat_web/components/custom_components/tab_components.ex +++ b/lib/pinchflat_web/components/custom_components/tab_components.ex @@ -9,24 +9,31 @@ defmodule PinchflatWeb.CustomComponents.TabComponents do attr :title, :string, required: true end + slot :tab_append, required: false + def tabbed_layout(assigns) do ~H"""
- -
+
+ +
+ <%= render_slot(@tab_append) %> +
+
+
<%= render_slot(tab) %>
diff --git a/lib/pinchflat_web/controllers/sources/source_html.ex b/lib/pinchflat_web/controllers/sources/source_html.ex index dcb6b05..b7afe45 100644 --- a/lib/pinchflat_web/controllers/sources/source_html.ex +++ b/lib/pinchflat_web/controllers/sources/source_html.ex @@ -24,4 +24,11 @@ defmodule PinchflatWeb.Sources.SourceHTML do {"Monthly", 30 * 24 * 60} ] end + + def rss_feed_url(source) do + url_base = Application.get_env(:pinchflat, :url_base) + path = ~p"/sources/#{source.uuid}/feed" + + Path.join(url_base, "#{path}.rss") + end end diff --git a/lib/pinchflat_web/controllers/sources/source_html/show.html.heex b/lib/pinchflat_web/controllers/sources/source_html/show.html.heex index 8474d64..1ad1642 100644 --- a/lib/pinchflat_web/controllers/sources/source_html/show.html.heex +++ b/lib/pinchflat_web/controllers/sources/source_html/show.html.heex @@ -19,6 +19,45 @@
<.tabbed_layout> + <:tab_append> + <.button_dropdown text="Actions" class="justify-center w-full sm:w-50"> + <:option> + copied = false, 4000); + "} + > + Copy RSS Feed <.icon name="hero-check" class="ml-2 h-4 w-4" /> + + + <:option> +
+ + <:option> + <.link + href={~p"/sources/#{@source}"} + method="delete" + data-confirm="Are you sure you want to delete this source (leaving files in place)? This cannot be undone." + > + Delete Source + + + <:option> + <.link + href={~p"/sources/#{@source}?delete_files=true"} + method="delete" + data-confirm="Are you sure you want to delete this source and it's files on disk? This cannot be undone." + class="mt-5 md:mt-0" + > + Delete Source + Files + + + + + <:tab title="Attributes">

Attributes

@@ -31,28 +70,6 @@ <.list_items_from_map map={Map.from_struct(@source)} />
- -
- <.link - href={~p"/sources/#{@source}"} - method="delete" - data-confirm="Are you sure you want to delete this source (leaving files in place)? This cannot be undone." - > - <.button color="bg-meta-1" rounding="rounded-lg"> - Delete Source - - - <.link - href={~p"/sources/#{@source}?delete_files=true"} - method="delete" - data-confirm="Are you sure you want to delete this source and it's files on disk? This cannot be undone." - class="mt-5 md:mt-0" - > - <.button color="bg-meta-1" rounding="rounded-lg"> - Delete Source and Files - - -
<:tab title="Pending Media"> <%= if match?([_|_], @pending_media) do %> diff --git a/lib/pinchflat_web/router.ex b/lib/pinchflat_web/router.ex index 3c8cc67..ac166ff 100644 --- a/lib/pinchflat_web/router.ex +++ b/lib/pinchflat_web/router.ex @@ -36,7 +36,7 @@ defmodule PinchflatWeb.Router do # TODO: consider putting the basic auth here behind a config flag # so people that want RSS feeds to work can enable it. scope "/", PinchflatWeb do - get "/sources/:uuid/rss_feed", Podcasts.PodcastController, :rss_feed + get "/sources/:uuid/feed", Podcasts.PodcastController, :rss_feed get "/sources/:uuid/feed_image", Podcasts.PodcastController, :feed_image get "/media/:uuid/stream", MediaItems.MediaItemController, :stream