diff --git a/lib/philomena_web/controllers/search_controller.ex b/lib/philomena_web/controllers/search_controller.ex index d31f25c5..0c07fb7e 100644 --- a/lib/philomena_web/controllers/search_controller.ex +++ b/lib/philomena_web/controllers/search_controller.ex @@ -24,10 +24,11 @@ defmodule PhilomenaWeb.SearchController do conn |> render("index.html", images: images, search_query: params["q"]) else - {:error, _msg} -> + {:error, msg} -> conn |> render("index.html", images: [], + error: msg, search_query: params["q"] ) end diff --git a/lib/philomena_web/templates/search/index.html.slime b/lib/philomena_web/templates/search/index.html.slime index 88819f06..b3b87319 100644 --- a/lib/philomena_web/templates/search/index.html.slime +++ b/lib/philomena_web/templates/search/index.html.slime @@ -1 +1,10 @@ -= render PhilomenaWeb.ImageView, "index.html", conn: @conn, images: @images, route: fn p -> Routes.search_path(@conn, :index, p) end, params: [q: @search_query] \ No newline at end of file += cond do + - Enum.any?(@images) -> + = render PhilomenaWeb.ImageView, "index.html", conn: @conn, images: @images, route: fn p -> Routes.search_path(@conn, :index, p) end, params: [q: @search_query] + - assigns[:error] -> + p + ' Oops, there was an error evaluating your query: + pre = assigns[:error] + - true -> + p + ' No images found! \ No newline at end of file