mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-23 20:18:00 +01:00
Use image list layout in reverse search
This commit is contained in:
parent
5da5d086c8
commit
c81b991b88
3 changed files with 45 additions and 41 deletions
|
@ -87,7 +87,7 @@ defmodule Philomena.DuplicateReports do
|
|||
{intensities, aspect}
|
||||
|> find_duplicates(dist: dist, aspect_dist: dist, limit: limit)
|
||||
|> preload([:user, :intensity, [:sources, tags: :aliases]])
|
||||
|> Repo.all()
|
||||
|> Repo.paginate(page_size: 50)
|
||||
|
||||
{:ok, images}
|
||||
|
||||
|
|
|
@ -16,15 +16,32 @@ defmodule PhilomenaWeb.Search.ReverseController do
|
|||
case DuplicateReports.execute_search_query(image_params) do
|
||||
{:ok, images} ->
|
||||
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} ->
|
||||
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
|
||||
|
||||
def create(conn, _params) do
|
||||
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
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
h1 Reverse Search
|
||||
|
||||
= form_for @changeset, ~p"/search/reverse", [multipart: true, as: :image], fn f ->
|
||||
.walloftext
|
||||
p
|
||||
' Basic image similarity search. Finds uploaded images similar to the one
|
||||
' provided based on simple intensities and uses the median frame of
|
||||
|
@ -40,42 +41,28 @@ h1 Reverse Search
|
|||
|
||||
= cond do
|
||||
- is_nil(@images) ->
|
||||
/ Don't render anything.
|
||||
|
||||
- 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
|
||||
tr
|
||||
th
|
||||
th Image
|
||||
th
|
||||
.block__content.js-resizable-media-container
|
||||
= for image <- @images do
|
||||
= render PhilomenaWeb.ImageView, "_image_box.html", image: image, link: ~p"/images/#{image}", size: :thumb, conn: @conn
|
||||
|
||||
= for match <- @images do
|
||||
tr
|
||||
th
|
||||
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
|
||||
.block__header.block__header--light.page__header.flex
|
||||
span.block__header__title.page__info
|
||||
= render PhilomenaWeb.PaginationView, "_pagination_info.html", page: @images
|
||||
|
||||
th
|
||||
= render PhilomenaWeb.ImageView, "_image_container.html", image: match, size: :thumb, conn: @conn
|
||||
|
||||
th
|
||||
h3
|
||||
= 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
|
||||
.flex__right.page__options
|
||||
a href="/settings/edit" title="Display Settings"
|
||||
i.fa.fa-cog
|
||||
span.hide-mobile.hide-limited-desktop<>
|
||||
' Display Settings
|
||||
|
||||
- true ->
|
||||
h2 Results
|
||||
p
|
||||
' We couldn't find any images matching this in our image database.
|
||||
' No images found!
|
||||
|
|
Loading…
Reference in a new issue