Remove duplication around MusicBrainz URL generation
This commit is contained in:
@@ -14,6 +14,10 @@ defmodule MusicBrainz.ReleaseGroup do
|
||||
}
|
||||
end
|
||||
|
||||
def url(id) do
|
||||
"https://musicbrainz.org/release-group/#{id}"
|
||||
end
|
||||
|
||||
defp parse_subtype("Album"), do: :album
|
||||
defp parse_subtype("EP"), do: :ep
|
||||
defp parse_subtype("Live"), do: :live
|
||||
|
||||
@@ -139,7 +139,7 @@ defmodule MusicLibraryWeb.RecordComponents do
|
||||
{gettext("Show")}
|
||||
</.link>
|
||||
<a
|
||||
href={musicbrainz_url(record)}
|
||||
href={MusicBrainz.ReleaseGroup.url(record.musicbrainz_id)}
|
||||
target=".blank"
|
||||
class="block px-3 py-1 text-sm leading-6 text-zinc-900 dark:text-zinc-400 hover:bg-zinc-50 dark:hover:text-zinc-300 dark:hover:bg-zinc-700"
|
||||
role="menuitem"
|
||||
@@ -188,10 +188,6 @@ defmodule MusicLibraryWeb.RecordComponents do
|
||||
"""
|
||||
end
|
||||
|
||||
defp musicbrainz_url(record) do
|
||||
"https://musicbrainz.org/release-group/#{record.musicbrainz_id}"
|
||||
end
|
||||
|
||||
defp toggle_actions_menu(record_id) do
|
||||
JS.toggle(to: "#actions-#{record_id}")
|
||||
|> JS.toggle_class("pointer-events-none", to: "#records > li")
|
||||
|
||||
@@ -145,10 +145,6 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
defp title_segment(:show), do: gettext("Show")
|
||||
defp title_segment(:edit), do: gettext("Edit")
|
||||
|
||||
defp musicbrainz_url(record) do
|
||||
"https://musicbrainz.org/release-group/#{record.musicbrainz_id}"
|
||||
end
|
||||
|
||||
defp human_datetime(dt) do
|
||||
"#{dt.day}/#{dt.month}/#{dt.year}"
|
||||
end
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
{gettext("MusicBrainz ID")}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm flex justify-between leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
||||
<a href={musicbrainz_url(@record)}>
|
||||
<a href={MusicBrainz.ReleaseGroup.url(@record.musicbrainz_id)}>
|
||||
<code id={"mb-#{@record.musicbrainz_id}"}>{@record.musicbrainz_id}</code>
|
||||
</a>
|
||||
<button phx-click={
|
||||
|
||||
@@ -128,10 +128,6 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
defp title_segment(:show), do: gettext("Show")
|
||||
defp title_segment(:edit), do: gettext("Edit")
|
||||
|
||||
defp musicbrainz_url(record) do
|
||||
"https://musicbrainz.org/release-group/#{record.musicbrainz_id}"
|
||||
end
|
||||
|
||||
defp human_datetime(dt) do
|
||||
"#{dt.day}/#{dt.month}/#{dt.year}"
|
||||
end
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
{gettext("MusicBrainz ID")}
|
||||
</dt>
|
||||
<dd class="mt-1 text-sm flex justify-between leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
||||
<a href={musicbrainz_url(@record)}>
|
||||
<a href={MusicBrainz.ReleaseGroup.url(@record.musicbrainz_id)}>
|
||||
<code id={"mb-#{@record.musicbrainz_id}"}>{@record.musicbrainz_id}</code>
|
||||
</a>
|
||||
<button phx-click={
|
||||
|
||||
Reference in New Issue
Block a user