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
|
||||
artists_string = Enum.map_join(record.artists, " ", & &1.name)
|
||||
format_string = Atom.to_string(record.format)
|
||||
|
||||
template.url_template
|
||||
|> String.replace("{artist}", URI.encode(artists_string))
|
||||
|> String.replace("{title}", URI.encode(record.title))
|
||||
|> String.replace("{format}", URI.encode(format_string))
|
||||
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>
|
||||
- {gettext("Record title")}
|
||||
</p>
|
||||
<p>
|
||||
<code class="bg-gray-200 dark:bg-gray-700 px-1 rounded">{"{format}"}</code>
|
||||
- {gettext("Record format")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -74,7 +78,11 @@ defmodule MusicLibraryWeb.OnlineStoreTemplateLive.FormComponent do
|
||||
|
||||
@impl true
|
||||
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,
|
||||
socket
|
||||
|
||||
@@ -1265,3 +1265,8 @@ msgstr ""
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Manage templates for generating links to online record stores."
|
||||
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
|
||||
msgid "Manage templates for generating links to online record stores."
|
||||
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