mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-12-02 15:48:00 +01:00
24 lines
746 B
Elixir
24 lines
746 B
Elixir
defmodule PhilomenaWeb.Search.ReverseController do
|
|
use PhilomenaWeb, :controller
|
|
|
|
alias PhilomenaWeb.ImageReverse
|
|
alias Philomena.SpoilerExecutor
|
|
|
|
plug PhilomenaWeb.ScraperCachePlug
|
|
plug PhilomenaWeb.ScraperPlug, params_key: "image", params_name: "image"
|
|
|
|
def index(conn, params) do
|
|
create(conn, params)
|
|
end
|
|
|
|
def create(conn, %{"image" => image_params}) when is_map(image_params) do
|
|
images = ImageReverse.images(image_params)
|
|
spoilers = SpoilerExecutor.execute_spoiler(conn.assigns.compiled_spoiler, images)
|
|
|
|
render(conn, "index.html", title: "Reverse Search", images: images, spoilers: spoilers)
|
|
end
|
|
|
|
def create(conn, _params) do
|
|
render(conn, "index.html", title: "Reverse Search", images: nil)
|
|
end
|
|
end
|