pinchflat/lib/pinchflat_web/controllers/sources/source_html.ex
Kieran 98c2812ee8
[Enhancement] Allow forcing a refresh of source metadata (#194)
* Stopped sources from fetching metadata on every update

* Added action button to force a metadata refresh
2024-04-18 15:35:53 -07:00

56 lines
1.7 KiB
Elixir

defmodule PinchflatWeb.Sources.SourceHTML do
use PinchflatWeb, :html
embed_templates "source_html/*"
@doc """
Renders a source form.
"""
attr :changeset, Ecto.Changeset, required: true
attr :action, :string, required: true
attr :media_profiles, :list, required: true
def source_form(assigns)
def friendly_index_frequencies do
[
{"Only once when first created", -1},
{"1 Hour", 60},
{"3 Hours", 3 * 60},
{"6 Hours", 6 * 60},
{"12 Hours", 12 * 60},
{"Daily (recommended)", 24 * 60},
{"Weekly", 7 * 24 * 60},
{"Monthly", 30 * 24 * 60}
]
end
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 title_filter_regex_help do
url = "https://github.com/nalgeon/sqlean/blob/main/docs/regexp.md#supported-syntax"
classes = "underline decoration-bodydark decoration-1 hover:decoration-white"
"""
A PCRE-compatible regex. Only media with titles that match this regex will be downloaded. <a href="#{url}" class="#{classes}" target="_blank">See here</a> for syntax
"""
end
def output_path_template_override_help do
help_button_classes = "underline decoration-bodydark decoration-1 hover:decoration-white cursor-pointer"
help_button = ~s{<span class="#{help_button_classes}" x-on:click="$dispatch('load-template')">Click here</span>}
"""
Must end with .{{ ext }}. Same rules as Media Profile output path templates. #{help_button} to load your media profile's output template
"""
end
end