Improve page titles
- When showing a single record, use record details - Split title into logical breadcrumbs
This commit is contained in:
@@ -6,14 +6,18 @@ defmodule MusicLibraryWeb.SessionController do
|
||||
def new(conn, _params) do
|
||||
conn
|
||||
|> delete_session(:logged_in)
|
||||
|> render(:new, form: @empty_form, layout: {MusicLibraryWeb.Layouts, "unauthenticated"})
|
||||
|> render(:new,
|
||||
page_title: gettext("Login"),
|
||||
form: @empty_form,
|
||||
layout: {MusicLibraryWeb.Layouts, "unauthenticated"}
|
||||
)
|
||||
end
|
||||
|
||||
def create(conn, %{"password" => request_password}) do
|
||||
if Plug.Crypto.secure_compare(password(), request_password) do
|
||||
conn
|
||||
|> put_session(:logged_in, true)
|
||||
|> redirect(to: "/")
|
||||
|> redirect(to: ~p"/")
|
||||
else
|
||||
conn
|
||||
|> put_flash(:error, gettext("Invalid password"))
|
||||
|
||||
@@ -4,6 +4,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
|
||||
alias MusicLibrary.Records
|
||||
alias MusicLibrary.Collection
|
||||
alias MusicLibraryWeb.CollectionLive.Show
|
||||
|
||||
@default_records_list_params %{
|
||||
query: "",
|
||||
@@ -38,7 +39,7 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
end
|
||||
|
||||
socket
|
||||
|> assign(:page_title, gettext("Import from MusicBrainz"))
|
||||
|> assign(:page_title, gettext("Import from MusicBrainz · Collection"))
|
||||
|> assign(:record, nil)
|
||||
end
|
||||
|
||||
@@ -51,9 +52,11 @@ defmodule MusicLibraryWeb.CollectionLive.Index do
|
||||
socket
|
||||
end
|
||||
|
||||
record = Records.get_record!(id)
|
||||
|
||||
socket
|
||||
|> assign(:page_title, gettext("Edit"))
|
||||
|> assign(:record, Records.get_record!(id))
|
||||
|> assign(:page_title, Show.page_title(socket.assigns.live_action, record))
|
||||
|> assign(:record, record)
|
||||
end
|
||||
|
||||
defp apply_action(socket, :index, params) do
|
||||
|
||||
@@ -31,7 +31,7 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:nav_section, :records)
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action))
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|
||||
|> assign(:record, record)}
|
||||
end
|
||||
|
||||
@@ -88,8 +88,42 @@ defmodule MusicLibraryWeb.CollectionLive.Show do
|
||||
{:noreply, assign(socket, :record, record)}
|
||||
end
|
||||
|
||||
defp page_title(:show), do: gettext("Show")
|
||||
defp page_title(:edit), do: gettext("Edit")
|
||||
def page_title(:show, record) do
|
||||
artist_names = Enum.map(record.artists, & &1.name)
|
||||
|
||||
Enum.join(
|
||||
[
|
||||
Enum.join(artist_names, ", "),
|
||||
"-",
|
||||
record.title,
|
||||
"·",
|
||||
gettext("Details"),
|
||||
"·",
|
||||
gettext("Collection")
|
||||
],
|
||||
" "
|
||||
)
|
||||
end
|
||||
|
||||
def page_title(action, record) do
|
||||
artist_names = Enum.map(record.artists, & &1.name)
|
||||
|
||||
Enum.join(
|
||||
[
|
||||
Enum.join(artist_names, ", "),
|
||||
"-",
|
||||
record.title,
|
||||
"·",
|
||||
title_segment(action),
|
||||
"·",
|
||||
gettext("Collection")
|
||||
],
|
||||
" "
|
||||
)
|
||||
end
|
||||
|
||||
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}"
|
||||
|
||||
@@ -4,6 +4,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
||||
|
||||
alias MusicLibrary.Wishlist
|
||||
alias MusicLibrary.Records
|
||||
alias MusicLibraryWeb.WishlistLive.Show
|
||||
|
||||
@default_records_list_params %{
|
||||
query: "",
|
||||
@@ -38,7 +39,7 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
||||
end
|
||||
|
||||
socket
|
||||
|> assign(:page_title, gettext("Import from MusicBrainz"))
|
||||
|> assign(:page_title, gettext("Import from MusicBrainz · Wishlist"))
|
||||
|> assign(:record, nil)
|
||||
end
|
||||
|
||||
@@ -51,9 +52,11 @@ defmodule MusicLibraryWeb.WishlistLive.Index do
|
||||
socket
|
||||
end
|
||||
|
||||
record = Records.get_record!(id)
|
||||
|
||||
socket
|
||||
|> assign(:page_title, gettext("Edit"))
|
||||
|> assign(:record, Records.get_record!(id))
|
||||
|> assign(:page_title, Show.page_title(socket.assigns.live_action, record))
|
||||
|> assign(:record, record)
|
||||
end
|
||||
|
||||
defp apply_action(socket, :index, params) do
|
||||
|
||||
@@ -26,11 +26,13 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
|
||||
@impl true
|
||||
def handle_params(%{"id" => id}, _, socket) do
|
||||
record = Records.get_record!(id)
|
||||
|
||||
{:noreply,
|
||||
socket
|
||||
|> assign(:nav_section, :wishlist)
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action))
|
||||
|> assign(:record, Records.get_record!(id))}
|
||||
|> assign(:page_title, page_title(socket.assigns.live_action, record))
|
||||
|> assign(:record, record)}
|
||||
end
|
||||
|
||||
@impl true
|
||||
@@ -86,8 +88,25 @@ defmodule MusicLibraryWeb.WishlistLive.Show do
|
||||
{:noreply, assign(socket, :record, record)}
|
||||
end
|
||||
|
||||
defp page_title(:show), do: gettext("Show")
|
||||
defp page_title(:edit), do: gettext("Edit")
|
||||
def page_title(action, record) do
|
||||
artist_names = Enum.map(record.artists, & &1.name)
|
||||
|
||||
Enum.join(
|
||||
[
|
||||
Enum.join(artist_names, ", "),
|
||||
"-",
|
||||
record.title,
|
||||
"·",
|
||||
title_segment(action),
|
||||
"·",
|
||||
gettext("Wishlist")
|
||||
],
|
||||
" "
|
||||
)
|
||||
end
|
||||
|
||||
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}"
|
||||
|
||||
+38
-27
@@ -51,7 +51,9 @@ msgid "Choose a value"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/components/layouts/app.html.heex:13
|
||||
#: lib/music_library_web/live/collection_live/index.ex:74
|
||||
#: lib/music_library_web/live/collection_live/index.ex:77
|
||||
#: lib/music_library_web/live/collection_live/show.ex:102
|
||||
#: lib/music_library_web/live/collection_live/show.ex:119
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Collection"
|
||||
msgstr ""
|
||||
@@ -69,23 +71,21 @@ msgstr ""
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/index.ex:55
|
||||
#: lib/music_library_web/live/collection_live/index.html.heex:176
|
||||
#: lib/music_library_web/live/collection_live/show.ex:92
|
||||
#: lib/music_library_web/live/collection_live/show.ex:126
|
||||
#: lib/music_library_web/live/collection_live/show.html.heex:32
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:55
|
||||
#: lib/music_library_web/live/wishlist_live/index.html.heex:176
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:90
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:109
|
||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:32
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Edit"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/index.ex:121
|
||||
#: lib/music_library_web/live/collection_live/index.ex:124
|
||||
#: lib/music_library_web/live/stats_live/index.ex:67
|
||||
#: lib/music_library_web/live/stats_live/index.ex:73
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:117
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:124
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:120
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:127
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Error importing record"
|
||||
msgstr ""
|
||||
@@ -122,19 +122,13 @@ msgstr ""
|
||||
msgid "Import"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/index.ex:41
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:41
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Import from MusicBrainz"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.html.heex:136
|
||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:129
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Inserted at"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/controllers/session_controller.ex:19
|
||||
#: lib/music_library_web/controllers/session_controller.ex:23
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Invalid password"
|
||||
msgstr ""
|
||||
@@ -144,6 +138,7 @@ msgstr ""
|
||||
msgid "Latest purchase"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/controllers/session_controller.ex:10
|
||||
#: lib/music_library_web/controllers/session_html/new.html.heex:44
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Login"
|
||||
@@ -209,15 +204,15 @@ msgstr ""
|
||||
msgid "Purchased on"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/index.ex:112
|
||||
#: lib/music_library_web/live/collection_live/index.ex:115
|
||||
#: lib/music_library_web/live/stats_live/index.ex:59
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:109
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:112
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Record imported successfully"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/record_live/form_component.ex:123
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:137
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:140
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Record updated successfully"
|
||||
msgstr ""
|
||||
@@ -254,9 +249,9 @@ msgid "Search for records"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/index.html.heex:156
|
||||
#: lib/music_library_web/live/collection_live/show.ex:91
|
||||
#: lib/music_library_web/live/collection_live/show.ex:125
|
||||
#: lib/music_library_web/live/wishlist_live/index.html.heex:156
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:89
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:108
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Show"
|
||||
msgstr ""
|
||||
@@ -283,9 +278,9 @@ msgstr ""
|
||||
msgid "Success!"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/index.ex:18
|
||||
#: lib/music_library_web/live/collection_live/index.ex:19
|
||||
#: lib/music_library_web/live/collection_live/show.ex:19
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:18
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:19
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "The application has been updated, please reload."
|
||||
@@ -334,7 +329,8 @@ msgid "Welcome to your Music Library"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/components/layouts/app.html.heex:19
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:72
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:75
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:102
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Wishlist"
|
||||
msgstr ""
|
||||
@@ -398,13 +394,13 @@ msgid "Includes"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.ex:61
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:59
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:61
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Error refreshing MusicBrainz data"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.ex:53
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:51
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:53
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "MusicBrainz data refreshed successfully"
|
||||
msgstr ""
|
||||
@@ -415,7 +411,7 @@ msgid "Refresh LastFm Feed"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.ex:73
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:71
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:73
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Cover refreshed successfully"
|
||||
msgstr ""
|
||||
@@ -440,7 +436,7 @@ msgstr ""
|
||||
msgid "Refresh"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:79
|
||||
#: lib/music_library_web/live/wishlist_live/show.ex:81
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Error refreshing Cover"
|
||||
msgstr ""
|
||||
@@ -454,3 +450,18 @@ msgstr ""
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "No MB ID"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/show.ex:100
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Details"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/collection_live/index.ex:42
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Import from MusicBrainz · Collection"
|
||||
msgstr ""
|
||||
|
||||
#: lib/music_library_web/live/wishlist_live/index.ex:42
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "Import from MusicBrainz · Wishlist"
|
||||
msgstr ""
|
||||
|
||||
Reference in New Issue
Block a user