From 585941b0a562d8fc670478a9db83187bf0a1c793 Mon Sep 17 00:00:00 2001 From: Micah D Date: Sat, 5 Dec 2020 19:49:33 +0100 Subject: [PATCH] Add no results message / fix clothes tree links --- lib/shop_local/cache_provider.ex | 8 +-- .../clothing_tree_search_provider.ex | 7 +++ .../templates/page/index.html.eex | 62 ++++++++++--------- priv/static/css/app.css | 6 ++ 4 files changed, 48 insertions(+), 35 deletions(-) diff --git a/lib/shop_local/cache_provider.ex b/lib/shop_local/cache_provider.ex index 47214c2..ff25744 100644 --- a/lib/shop_local/cache_provider.ex +++ b/lib/shop_local/cache_provider.ex @@ -16,17 +16,13 @@ defmodule ShopLocal.CacheProvider do defp search_map(cache, s_params) do Enum.filter_map(cache, fn ({ key, value }) -> - Enum.all?(s_params, &( - String.contains?(String.downcase(value.search), &1) - || String.contains?(String.downcase(value.desc), &1) - || String.contains?(String.downcase(value.name), &1) - )) + Enum.all?(s_params, &(String.contains?(String.downcase(value.search), &1))) end, fn ({ key, value }) -> value end) end # If we miss x number of searches, stop asking for a while - @no_search_threshold 2 + @no_search_threshold 1 defp missed?(missed, s_params) do missed diff --git a/lib/shop_local/clothing_tree_search_provider.ex b/lib/shop_local/clothing_tree_search_provider.ex index 23779e5..297869e 100644 --- a/lib/shop_local/clothing_tree_search_provider.ex +++ b/lib/shop_local/clothing_tree_search_provider.ex @@ -18,6 +18,8 @@ defmodule ShopLocal.ClothingTreeSearchProvider do link = k |> Floki.find("a.product-item__link") |> Floki.attribute("href") + |> List.first + image_src = k |> Floki.find("img.product-item__image") |> Floki.attribute("src") @@ -37,6 +39,11 @@ defmodule ShopLocal.ClothingTreeSearchProvider do _ -> nil end + link = case String.starts_with?(link, "http") do + false -> "https://www.clothes-tree.com/" <> link + true -> link + end + %{ provider: "Clothes Tree", name: name, diff --git a/lib/shop_local_web/templates/page/index.html.eex b/lib/shop_local_web/templates/page/index.html.eex index 80b9abf..23548e9 100644 --- a/lib/shop_local_web/templates/page/index.html.eex +++ b/lib/shop_local_web/templates/page/index.html.eex @@ -42,32 +42,39 @@ <% end %>
-
@@ -95,18 +102,15 @@
  • Browsers Bookstore (Corvallis)
  • -
  • - Grassroots Bookstore -
  • -
  • - The Merri Artist -
  • The Clothes Tree
  • Conundrum House
  • +
  • + Grassroots Bookstore +
  • The Merri Artist
  • diff --git a/priv/static/css/app.css b/priv/static/css/app.css index c2aa29c..f9714c2 100644 --- a/priv/static/css/app.css +++ b/priv/static/css/app.css @@ -70,3 +70,9 @@ form { .product-image { width: 100%; } + +.no-results { + text-align: center; + width: 100%; + padding-bottom: 50px; +} -- 2.30.1