philomena/lib/philomena_web/image_scope.ex

20 lines
427 B
Elixir
Raw Normal View History

defmodule PhilomenaWeb.ImageScope do
2019-11-30 03:33:15 +01:00
def scope(conn) do
[]
2019-11-30 23:40:53 +01:00
|> scope(conn, "q", :q)
|> scope(conn, "sf", :sf)
2019-12-08 19:01:25 +01:00
|> scope(conn, "sd", :sd)
|> scope(conn, "del", :del)
|> scope(conn, "sort", :sort)
|> scope(conn, "hidden", :hidden)
2019-11-30 03:33:15 +01:00
end
2019-11-30 23:40:53 +01:00
defp scope(list, conn, key, key_atom) do
2019-11-30 03:33:15 +01:00
case conn.params[key] do
nil -> list
2020-01-11 05:20:19 +01:00
"" -> list
2019-11-30 23:40:53 +01:00
val -> [{key_atom, val} | list]
2019-11-30 03:33:15 +01:00
end
end
end