Search
<%= form_for :search, ~p"/search", [id: "searchform", method: "get", class: "js-search-form", enforce_utf8: false], fn f -> %>
<%= text_input(f, :q, class: "input input--wide js-search-field", placeholder: "Search terms are chained with commas", autocapitalize: "none", name: "q", value: @conn.params["q"]) %>
is a Boolean-valued field. It only accepts the values
true
and
false
.
Example:
to find images which are not animated, you would use
animated:false
.
is a numerical range field. Four qualifiers,
gte
(greater than or equal),
lte
(less than or equal),
gt
(greater than), and
lt
(less than), can be applied to the desired value.
Example:
to find images with a score greater than 100, you would use
score.gt:100
.
is a date/time field. It accepts a
tweaked subset of the ISO 8601 standard
, as well as relative dates
(X minutes/hours/days/months/years ago)
. Four qualifiers,
gte
(greater than or equal),
lte
(less than or equal),
gt
(greater than), and
lt
(less than), can be applied to the desired value.
Example:
to find images created before 2013, you would use
created_at.lt:2013
.
is a literal field. You can apply apply a wildcard
*
as a substitute for zero or more characters.
Example:
to find images from DeviantArt, you would use
source_url:*deviantart.com*
.
<%= submit("Search", class: "button button--state-primary") %>
<% # = submit_tag "I'm Feeling Poni", class: 'button button--separate-left spacing-right', name: 'random_image' %>
<%
random_is_selected = to_string(@conn.params["sf"]) =~ ~r/\Arandom(:\d+)?\z/
random_seed =
if random_is_selected do
@conn.params["sf"]
else
"random:#{:rand.uniform(4_294_967_296)}"
end
sort_fields = [
"Sort by initial post date": :first_seen_at,
"Sort by image ID": :id,
"Sort by last modification date": :updated_at,
"Sort by aspect ratio": :aspect_ratio,
"Sort by fave count": :faves,
"Sort by upvotes": :upvotes,
"Sort by downvotes": :downvotes,
"Sort by score": :score,
"Sort by Wilson score": :wilson_score,
"Sort by relevance": :_score,
"Sort by width": :width,
"Sort by height": :height,
"Sort by comments": :comment_count,
"Sort by tag count": :tag_count,
"Sort by pixels": :pixels,
"Sort by file size": :size,
"Sort by duration": :duration,
Random!: random_seed
]
sort_directions = [Descending: :desc, Ascending: :asc]
sort_hidden = ["Exclude Deleted": "", "Include Deleted/Merged": "1", "Deleted Only": "deleted", "Deleted/Merged Only": "only"]
%>
<%= select(f, :sf, sort_fields, class: "input input--separate-left", name: "sf", autocomplete: "off", selected: @conn.params["sf"]) %>
<%= select(f, :sd, sort_directions, class: "input input--separate-left", name: "sd", autocomplete: "off", selected: @conn.params["sd"]) %>
<%= if present?(@conn.params["hidden"]) do %>
<%= hidden_input(f, :hidden, name: "hidden", value: @conn.params["hidden"]) %>
<% end %>
<%= if hides_images?(@conn) do %>
<%= select(f, :del, sort_hidden, class: "input input--separate-left", name: "del", autocomplete: "off", selected: @conn.params["del"]) %>
<% end %>
<% end %>