artists: fix quick search to search urls.

ref: https://danbooru.donmai.us/forum_topics/9127?page=265#forum_post_153124
This commit is contained in:
evazion
2018-12-16 12:05:35 -06:00
parent 004f1e630d
commit d2f92b7aa7
2 changed files with 13 additions and 1 deletions

View File

@@ -490,6 +490,14 @@ class Artist < ApplicationRecord
end
end
def any_name_or_url_matches(query)
if query =~ %r!\Ahttps?://!i
url_matches(query)
else
any_name_matches(query)
end
end
def search(params)
q = super
@@ -504,6 +512,10 @@ class Artist < ApplicationRecord
q = q.any_name_matches(params[:any_name_matches])
end
if params[:any_name_or_url_matches].present?
q = q.any_name_or_url_matches(params[:any_name_or_url_matches])
end
if params[:url_matches].present?
q = q.url_matches(params[:url_matches])
end

View File

@@ -1,3 +1,3 @@
<%= form_tag(artists_path, :method => :get) do %>
<%= text_field "search", "name", id: "quick_search_name", placeholder: "Search artists", data: { autocomplete: "artist" } %>
<%= text_field "search", "any_name_or_url_matches", id: "quick_search_name", placeholder: "Search artists", "data-autocomplete": "artist" %>
<% end %>