Use image list layout in reverse search

This commit is contained in:
Liam 2024-08-25 23:50:33 -04:00
parent 5da5d086c8
commit c81b991b88
3 changed files with 45 additions and 41 deletions

View file

@ -87,7 +87,7 @@ defmodule Philomena.DuplicateReports do
{intensities, aspect} {intensities, aspect}
|> find_duplicates(dist: dist, aspect_dist: dist, limit: limit) |> find_duplicates(dist: dist, aspect_dist: dist, limit: limit)
|> preload([:user, :intensity, [:sources, tags: :aliases]]) |> preload([:user, :intensity, [:sources, tags: :aliases]])
|> Repo.all() |> Repo.paginate(page_size: 50)
{:ok, images} {:ok, images}

View file

@ -16,15 +16,32 @@ defmodule PhilomenaWeb.Search.ReverseController do
case DuplicateReports.execute_search_query(image_params) do case DuplicateReports.execute_search_query(image_params) do
{:ok, images} -> {:ok, images} ->
changeset = DuplicateReports.change_search_query(%SearchQuery{}) changeset = DuplicateReports.change_search_query(%SearchQuery{})
render(conn, "index.html", title: "Reverse Search", images: images, changeset: changeset)
render(conn, "index.html",
title: "Reverse Search",
layout_class: "layout--wide",
images: images,
changeset: changeset
)
{:error, changeset} -> {:error, changeset} ->
render(conn, "index.html", title: "Reverse Search", images: nil, changeset: changeset) render(conn, "index.html",
title: "Reverse Search",
layout_class: "layout--wide",
images: nil,
changeset: changeset
)
end end
end end
def create(conn, _params) do def create(conn, _params) do
changeset = DuplicateReports.change_search_query(%SearchQuery{}) changeset = DuplicateReports.change_search_query(%SearchQuery{})
render(conn, "index.html", title: "Reverse Search", images: nil, changeset: changeset)
render(conn, "index.html",
title: "Reverse Search",
layout_class: "layout--wide",
images: nil,
changeset: changeset
)
end end
end end

View file

@ -1,6 +1,7 @@
h1 Reverse Search h1 Reverse Search
= form_for @changeset, ~p"/search/reverse", [multipart: true, as: :image], fn f -> = form_for @changeset, ~p"/search/reverse", [multipart: true, as: :image], fn f ->
.walloftext
p p
' Basic image similarity search. Finds uploaded images similar to the one ' Basic image similarity search. Finds uploaded images similar to the one
' provided based on simple intensities and uses the median frame of ' provided based on simple intensities and uses the median frame of
@ -40,42 +41,28 @@ h1 Reverse Search
= cond do = cond do
- is_nil(@images) -> - is_nil(@images) ->
/ Don't render anything.
- Enum.any?(@images) -> - Enum.any?(@images) ->
h2 Results .block#imagelist-container
section.block__header.page__header.flex
span.block__header__title.page__title.hide-mobile
' Search by uploaded image
table .block__content.js-resizable-media-container
tr = for image <- @images do
th &nbsp; = render PhilomenaWeb.ImageView, "_image_box.html", image: image, link: ~p"/images/#{image}", size: :thumb, conn: @conn
th Image
th &nbsp;
= for match <- @images do .block__header.block__header--light.page__header.flex
tr span.block__header__title.page__info
th = render PhilomenaWeb.PaginationView, "_pagination_info.html", page: @images
h3 = link "##{match.id}", to: ~p"/images/#{match}"
p
= if image_has_sources(match) do
span.source_url
= link "Source", to: image_first_source(match)
- else
' Unknown source
th .flex__right.page__options
= render PhilomenaWeb.ImageView, "_image_container.html", image: match, size: :thumb, conn: @conn a href="/settings/edit" title="Display Settings"
i.fa.fa-cog
th span.hide-mobile.hide-limited-desktop<>
h3 ' Display Settings
= match.image_width
| x
=> match.image_height
' -
=> round(match.image_size / 1024)
' KiB
= render PhilomenaWeb.TagView, "_tag_list.html", tags: Tag.display_order(match.tags), conn: @conn
- true -> - true ->
h2 Results
p p
' We couldn't find any images matching this in our image database. ' No images found!