2020-05-08 04:10:54 +02:00
|
|
|
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)
|
2019-12-18 01:42:50 +01:00
|
|
|
|> scope(conn, "del", :del)
|
2020-08-13 17:32:35 +02:00
|
|
|
|> scope(conn, "sort", :sort)
|
2019-12-18 01:42:50 +01:00
|
|
|
|> 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
|
2019-12-18 01:42:50 +01:00
|
|
|
end
|