Add format to online store templates
This commit is contained in:
@@ -68,9 +68,11 @@ defmodule MusicLibrary.OnlineStoreTemplates do
|
|||||||
"""
|
"""
|
||||||
def generate_url(template, record) do
|
def generate_url(template, record) do
|
||||||
artists_string = Enum.map_join(record.artists, " ", & &1.name)
|
artists_string = Enum.map_join(record.artists, " ", & &1.name)
|
||||||
|
format_string = Atom.to_string(record.format)
|
||||||
|
|
||||||
template.url_template
|
template.url_template
|
||||||
|> String.replace("{artist}", URI.encode(artists_string))
|
|> String.replace("{artist}", URI.encode(artists_string))
|
||||||
|> String.replace("{title}", URI.encode(record.title))
|
|> String.replace("{title}", URI.encode(record.title))
|
||||||
|
|> String.replace("{format}", URI.encode(format_string))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -59,6 +59,10 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.FormComponent do
|
|||||||
<code class="bg-gray-200 dark:bg-gray-700 px-1 rounded">{"{title}"}</code>
|
<code class="bg-gray-200 dark:bg-gray-700 px-1 rounded">{"{title}"}</code>
|
||||||
- {gettext("Record title")}
|
- {gettext("Record title")}
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<code class="bg-gray-200 dark:bg-gray-700 px-1 rounded">{"{format}"}</code>
|
||||||
|
- {gettext("Record format")}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -74,7 +78,11 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.FormComponent do
|
|||||||
|
|
||||||
@impl true
|
@impl true
|
||||||
def update(%{template: template} = assigns, socket) do
|
def update(%{template: template} = assigns, socket) do
|
||||||
test_record = %Record{title: "Dark Side of the Moon", artists: [%Artist{name: "Pink Floyd"}]}
|
test_record = %Record{
|
||||||
|
title: "Dark Side of the Moon",
|
||||||
|
artists: [%Artist{name: "Pink Floyd"}],
|
||||||
|
format: :vinyl
|
||||||
|
}
|
||||||
|
|
||||||
{:ok,
|
{:ok,
|
||||||
socket
|
socket
|
||||||
|
|||||||
@@ -1265,3 +1265,8 @@ msgstr ""
|
|||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Manage templates for generating links to online record stores."
|
msgid "Manage templates for generating links to online record stores."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: lib/music_library_web/live/online_store_template_live/form_component.ex
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
msgid "Record format"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
@@ -1265,3 +1265,8 @@ msgstr ""
|
|||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Manage templates for generating links to online record stores."
|
msgid "Manage templates for generating links to online record stores."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: lib/music_library_web/live/online_store_template_live/form_component.ex
|
||||||
|
#, elixir-autogen, elixir-format
|
||||||
|
msgid "Record format"
|
||||||
|
msgstr ""
|
||||||
|
|||||||
Reference in New Issue
Block a user