diff --git a/lib/pinchflat_web/controllers/sources/source_html.ex b/lib/pinchflat_web/controllers/sources/source_html.ex index b93b754..a5a7545 100644 --- a/lib/pinchflat_web/controllers/sources/source_html.ex +++ b/lib/pinchflat_web/controllers/sources/source_html.ex @@ -28,4 +28,20 @@ defmodule PinchflatWeb.Sources.SourceHTML do def rss_feed_url(conn, source) do url(conn, ~p"/sources/#{source.uuid}/feed") <> ".xml" end + + def output_path_template_override_placeholders(media_profiles) do + media_profiles + |> Enum.map(&{&1.id, &1.output_path_template}) + |> Map.new() + |> Phoenix.json_library().encode!() + end + + def output_path_template_override_help do + help_button_classes = "underline decoration-bodydark decoration-1 hover:decoration-white cursor-pointer" + help_button = ~s{Click here} + + """ + Must end with .{{ ext }}. Same rules as Media Profile output path templates. #{help_button} to load your media profile's output template + """ + end end diff --git a/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex b/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex index a36e2d8..33ea259 100644 --- a/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex +++ b/lib/pinchflat_web/controllers/sources/source_html/source_form.html.heex @@ -9,113 +9,139 @@ Oops, something went wrong! Please check the errors below. -
-

- General Options -

- - Editing Mode: - -
+
+
+

+ General Options +

+ + Editing Mode: + +
- <.input - field={f[:custom_name]} - type="text" - label="Custom Name" - help="Something descriptive. Does not impact indexing or downloading" - /> - - <.input field={f[:original_url]} type="text" label="Source URL" help="URL of a channel or playlist (required)" /> - - <.input - field={f[:media_profile_id]} - options={Enum.map(@media_profiles, &{&1.name, &1.id})} - type="select" - label="Media Profile" - help="Sets your preferences for what media to look for and how to store it" - /> - -

- Indexing Options -

- -
<.input - field={f[:index_frequency_minutes]} - options={friendly_index_frequencies()} - type="select" - label="Index Frequency" - x-bind:disabled="fastIndexingEnabled == true" - x-init="$watch('fastIndexingEnabled', v => v && ($el.value = 30 * 24 * 60))" - help="Indexing is the process of checking for media to download. Sets the time between one index of this source finishing and the next one starting" + field={f[:custom_name]} + type="text" + label="Custom Name" + help="Something descriptive. Does not impact indexing or downloading" /> -
+ <.input field={f[:original_url]} type="text" label="Source URL" help="URL of a channel or playlist (required)" /> + + <.input + field={f[:media_profile_id]} + options={Enum.map(@media_profiles, &{&1.name, &1.id})} + type="select" + label="Media Profile" + help="Sets your preferences for what media to look for and how to store it" + x-model.fill="mediaProfileId" + /> + +

+ Indexing Options +

+ +
<.input - field={f[:fast_index]} - type="toggle" - label="Use Fast Indexing" - label_suffix="(pro)" - help="Experimental. Overrides 'Index Frequency'. Recommended for large channels that upload frequently. Does not work with private playlists. See below for more info" - x-init=" + field={f[:index_frequency_minutes]} + options={friendly_index_frequencies()} + type="select" + label="Index Frequency" + x-bind:disabled="fastIndexingEnabled == true" + x-init="$watch('fastIndexingEnabled', v => v && ($el.value = 30 * 24 * 60))" + help="Indexing is the process of checking for media to download. Sets the time between one index of this source finishing and the next one starting" + /> + +
+ <.input + field={f[:fast_index]} + type="toggle" + label="Use Fast Indexing" + label_suffix="(pro)" + help="Experimental. Overrides 'Index Frequency'. Recommended for large channels that upload frequently. Does not work with private playlists. See below for more info" + x-init=" // `enabled` is the data attribute that the toggle uses internally fastIndexingEnabled = enabled $watch('enabled', value => fastIndexingEnabled = !!value) " - /> -
-
+ /> +
+
-

- Downloading Options -

- - <.input - field={f[:download_media]} - type="toggle" - label="Download Media" - help="Unchecking still indexes media but it won't be downloaded until you enable this option" - /> - - <.input - field={f[:download_cutoff_date]} - type="text" - label="Download Cutoff Date" - placeholder="YYYY-MM-DD" - maxlength="10" - pattern="((?:19|20)[0-9][0-9])-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])" - title="YYYY-MM-DD" - help="Only download media uploaded after this date. Leave blank to download all media. Must be in YYYY-MM-DD format" - /> - - <.input - field={f[:retention_period_days]} - type="number" - label="Retention Period (days)" - min="0" - help="Days between when media is *downloaded* and when it's deleted. Leave blank to keep media indefinitely" - /> - -

- Advanced Options + Downloading Options

-

- Tread carefully -

<.input - field={f[:title_filter_regex]} - type="text" - label="Title Filter Regex" - placeholder="(?i)^How to Bike$" - help="A PCRE-compatible regex. Only media with titles that match this regex will be downloaded. Look up 'SQLean Regex docs' for more" + field={f[:download_media]} + type="toggle" + label="Download Media" + help="Unchecking still indexes media but it won't be downloaded until you enable this option" /> + + <.input + field={f[:download_cutoff_date]} + type="text" + label="Download Cutoff Date" + placeholder="YYYY-MM-DD" + maxlength="10" + pattern="((?:19|20)[0-9][0-9])-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])" + title="YYYY-MM-DD" + help="Only download media uploaded after this date. Leave blank to download all media. Must be in YYYY-MM-DD format" + /> + + <.input + field={f[:retention_period_days]} + type="number" + label="Retention Period (days)" + min="0" + help="Days between when media is *downloaded* and when it's deleted. Leave blank to keep media indefinitely" + /> + +
+

+ Advanced Options +

+

+ Tread carefully +

+ + <.input + field={f[:title_filter_regex]} + type="text" + label="Title Filter Regex" + placeholder="(?i)^How to Bike$" + help="A PCRE-compatible regex. Only media with titles that match this regex will be downloaded. Look up 'SQLean Regex docs' for more" + /> + +
+ <.input + field={f[:output_path_template_override]} + type="text" + inputclass="font-mono" + label="Output path template override" + help={output_path_template_override_help()} + html_help={true} + x-bind:placeholder="placeholders[mediaProfileId]" + x-model.fill="inputValue" + /> +
+
+ + <.button class="my-10 sm:mb-7.5 w-full sm:w-auto" rounding="rounded-lg">Save Source + +
+ <.fast_indexing_help /> +
- - <.button class="my-10 sm:mb-7.5 w-full sm:w-auto" rounding="rounded-lg">Save Source - -
- <.fast_indexing_help /> -