Search by genre
Can also click on genres in detail views.
This commit is contained in:
@@ -64,6 +64,10 @@ defmodule MusicLibrary.Records do
|
|||||||
search
|
search
|
||||||
|> where(fragment("records_search_index match 'title : ?*'", literal(^album)))
|
|> where(fragment("records_search_index match 'title : ?*'", literal(^album)))
|
||||||
|
|
||||||
|
{:genre, genre}, search ->
|
||||||
|
search
|
||||||
|
|> where(fragment("records_search_index match 'genres : ?*'", literal(^genre)))
|
||||||
|
|
||||||
{:mbid, mbid}, search ->
|
{:mbid, mbid}, search ->
|
||||||
search
|
search
|
||||||
|> where(fragment("records_search_index = '?*'", literal(^mbid)))
|
|> where(fragment("records_search_index = '?*'", literal(^mbid)))
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ defmodule MusicLibrary.Records.SearchParser do
|
|||||||
mbid_filter = ignore(string("mbid:"))
|
mbid_filter = ignore(string("mbid:"))
|
||||||
mbid = concat(mbid_filter, query) |> tag(:mbid)
|
mbid = concat(mbid_filter, query) |> tag(:mbid)
|
||||||
|
|
||||||
|
genre_filter = ignore(string("genre:"))
|
||||||
|
genre = concat(genre_filter, query) |> tag(:genre)
|
||||||
|
|
||||||
format_filter = ignore(string("format:"))
|
format_filter = ignore(string("format:"))
|
||||||
|
|
||||||
formats =
|
formats =
|
||||||
@@ -56,7 +59,7 @@ defmodule MusicLibrary.Records.SearchParser do
|
|||||||
choice([concat(type_filter, types), ignore(invalid_type)])
|
choice([concat(type_filter, types), ignore(invalid_type)])
|
||||||
|> tag(:type)
|
|> tag(:type)
|
||||||
|
|
||||||
search = repeat(choice([artist, album, mbid, space, format, type, query]))
|
search = repeat(choice([artist, album, mbid, genre, space, format, type, query]))
|
||||||
|
|
||||||
defparsecp(:search_parser, search)
|
defparsecp(:search_parser, search)
|
||||||
|
|
||||||
@@ -75,6 +78,8 @@ defmodule MusicLibrary.Records.SearchParser do
|
|||||||
{:ok, %{artist: "the pineapple thief", query: "wilderness"}}
|
{:ok, %{artist: "the pineapple thief", query: "wilderness"}}
|
||||||
iex> MusicLibrary.Records.SearchParser.parse(~s(artist:"the pineapple thief" format:cd))
|
iex> MusicLibrary.Records.SearchParser.parse(~s(artist:"the pineapple thief" format:cd))
|
||||||
{:ok, %{artist: "the pineapple thief", format: :cd}}
|
{:ok, %{artist: "the pineapple thief", format: :cd}}
|
||||||
|
iex> MusicLibrary.Records.SearchParser.parse(~s(genre:"psychedelic rock"))
|
||||||
|
{:ok, %{genre: "psychedelic rock"}}
|
||||||
iex> MusicLibrary.Records.SearchParser.parse("format:vin")
|
iex> MusicLibrary.Records.SearchParser.parse("format:vin")
|
||||||
{:ok, %{query: ""}}
|
{:ok, %{query: ""}}
|
||||||
iex> MusicLibrary.Records.SearchParser.parse("type:alb")
|
iex> MusicLibrary.Records.SearchParser.parse("type:alb")
|
||||||
@@ -111,6 +116,9 @@ defmodule MusicLibrary.Records.SearchParser do
|
|||||||
{:mbid, [{:query, [value]}]}, acc ->
|
{:mbid, [{:query, [value]}]}, acc ->
|
||||||
Map.put(acc, :mbid, value)
|
Map.put(acc, :mbid, value)
|
||||||
|
|
||||||
|
{:genre, [{:query, [value]}]}, acc ->
|
||||||
|
Map.put(acc, :genre, value)
|
||||||
|
|
||||||
{:format, [value]}, acc ->
|
{:format, [value]}, acc ->
|
||||||
Map.put(acc, :format, value)
|
Map.put(acc, :format, value)
|
||||||
|
|
||||||
|
|||||||
@@ -77,7 +77,13 @@
|
|||||||
<%= gettext("Genres") %>
|
<%= gettext("Genres") %>
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
||||||
<%= Enum.join(@record.genres, ", ") %>
|
<.link
|
||||||
|
:for={genre <- @record.genres}
|
||||||
|
class="mr-2 text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300"
|
||||||
|
patch={~p"/collection?#{%{query: ~s(genre:"#{genre}")}}"}
|
||||||
|
>
|
||||||
|
<%= genre %>
|
||||||
|
</.link>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
||||||
|
|||||||
@@ -78,7 +78,13 @@
|
|||||||
<%= gettext("Genres") %>
|
<%= gettext("Genres") %>
|
||||||
</dt>
|
</dt>
|
||||||
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
<dd class="mt-1 text-sm leading-6 text-zinc-700 dark:text-zinc-300 sm:col-span-2 sm:mt-0">
|
||||||
<%= Enum.join(@record.genres, ", ") %>
|
<.link
|
||||||
|
:for={genre <- @record.genres}
|
||||||
|
class="mr-2 text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300"
|
||||||
|
patch={~p"/wishlist?#{%{query: ~s(genre:"#{genre}")}}"}
|
||||||
|
>
|
||||||
|
<%= genre %>
|
||||||
|
</.link>
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
<div class="py-2 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-0">
|
||||||
|
|||||||
+15
-15
@@ -29,12 +29,12 @@ msgstr ""
|
|||||||
msgid "Attempting to reconnect"
|
msgid "Attempting to reconnect"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex:155
|
#: lib/music_library_web/live/collection_live/show.html.heex:161
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Back to records"
|
msgid "Back to records"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:148
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:154
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Back to wishlist"
|
msgid "Back to wishlist"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -128,8 +128,8 @@ msgstr ""
|
|||||||
msgid "Import from MusicBrainz"
|
msgid "Import from MusicBrainz"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex:130
|
#: lib/music_library_web/live/collection_live/show.html.heex:136
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:123
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:129
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Inserted at"
|
msgid "Inserted at"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -154,9 +154,9 @@ msgstr ""
|
|||||||
msgid "Logout"
|
msgid "Logout"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex:85
|
#: lib/music_library_web/live/collection_live/show.html.heex:91
|
||||||
#: lib/music_library_web/live/record_live/form_component.ex:47
|
#: lib/music_library_web/live/record_live/form_component.ex:47
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:86
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:92
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "MusicBrainz ID"
|
msgid "MusicBrainz ID"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -204,7 +204,7 @@ msgstr ""
|
|||||||
msgid "Purchased at"
|
msgid "Purchased at"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex:107
|
#: lib/music_library_web/live/collection_live/show.html.heex:113
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Purchased on"
|
msgid "Purchased on"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -311,8 +311,8 @@ msgstr ""
|
|||||||
msgid "Types"
|
msgid "Types"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex:138
|
#: lib/music_library_web/live/collection_live/show.html.heex:144
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:131
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:137
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Updated at"
|
msgid "Updated at"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -350,14 +350,14 @@ msgstr ""
|
|||||||
msgid "close"
|
msgid "close"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex:95
|
#: lib/music_library_web/live/collection_live/show.html.heex:101
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:96
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:102
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Copy MusicBrainz ID to clipboard"
|
msgid "Copy MusicBrainz ID to clipboard"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex:149
|
#: lib/music_library_web/live/collection_live/show.html.heex:155
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:142
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:148
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "MusicBrainz data"
|
msgid "MusicBrainz data"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
@@ -391,8 +391,8 @@ msgstr ""
|
|||||||
msgid "Number of included records"
|
msgid "Number of included records"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: lib/music_library_web/live/collection_live/show.html.heex:118
|
#: lib/music_library_web/live/collection_live/show.html.heex:124
|
||||||
#: lib/music_library_web/live/wishlist_live/show.html.heex:111
|
#: lib/music_library_web/live/wishlist_live/show.html.heex:117
|
||||||
#, elixir-autogen, elixir-format
|
#, elixir-autogen, elixir-format
|
||||||
msgid "Includes"
|
msgid "Includes"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|||||||
Reference in New Issue
Block a user