Have single result searches go to the show pages for certain controllers #4204
This commit is contained in:
@@ -37,14 +37,12 @@ class ArtistsController < ApplicationController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@artists = Artist.includes(:urls).search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])
|
@artists = Artist.includes(:urls).paginated_search(params)
|
||||||
respond_with(@artists) do |format|
|
|
||||||
format.xml do
|
if params[:redirect].to_s.truthy? && @artists.one? && @artists.first.name == Artist.normalize_name(params[:search][:any_name_or_url_matches])
|
||||||
render :xml => @artists.to_xml(:include => [:urls], :root => "artists")
|
redirect_to @artists.first
|
||||||
end
|
else
|
||||||
format.json do
|
respond_with @artists
|
||||||
render :json => @artists.to_json(:include => [:urls])
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,12 @@ class PoolsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@pools = Pool.includes(:creator).paginated_search(params, count_pages: true)
|
@pools = Pool.includes(:creator).paginated_search(params, count_pages: true)
|
||||||
respond_with(@pools)
|
|
||||||
|
if params[:redirect].to_s.truthy? && @pools.one? && Pool.normalize_name_for_search(@pools.first.name) == Pool.normalize_name_for_search(params[:search][:name_matches])
|
||||||
|
redirect_to @pools.first
|
||||||
|
else
|
||||||
|
respond_with @pools
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def gallery
|
def gallery
|
||||||
|
|||||||
@@ -28,9 +28,14 @@ class UsersController < ApplicationController
|
|||||||
if params[:name].present?
|
if params[:name].present?
|
||||||
@user = User.find_by_name!(params[:name])
|
@user = User.find_by_name!(params[:name])
|
||||||
redirect_to user_path(@user)
|
redirect_to user_path(@user)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@users = User.paginated_search(params)
|
||||||
|
if params[:redirect].to_s.truthy? && @users.one? && User.normalize_name(@users.first.name) == User.normalize_name(params[:search][:name_matches])
|
||||||
|
redirect_to @users.first
|
||||||
else
|
else
|
||||||
@users = User.paginated_search(params)
|
respond_with @users
|
||||||
respond_with(@users)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class WikiPagesController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@wiki_pages = WikiPage.paginated_search(params)
|
@wiki_pages = WikiPage.paginated_search(params)
|
||||||
|
|
||||||
if params[:redirect].to_s.truthy? && @wiki_pages.one?
|
if params[:redirect].to_s.truthy? && @wiki_pages.one? && @wiki_pages.first.title == WikiPage.normalize_title(params[:search][:title])
|
||||||
redirect_to @wiki_pages.first
|
redirect_to @wiki_pages.first
|
||||||
else
|
else
|
||||||
respond_with(@wiki_pages)
|
respond_with(@wiki_pages)
|
||||||
|
|||||||
@@ -169,8 +169,10 @@ module ApplicationHelper
|
|||||||
def quick_search_form_for(attribute, url, name, autocomplete: nil, &block)
|
def quick_search_form_for(attribute, url, name, autocomplete: nil, &block)
|
||||||
tag.li do
|
tag.li do
|
||||||
search_form_for(url, classes: "quick-search-form one-line-form") do |f|
|
search_form_for(url, classes: "quick-search-form one-line-form") do |f|
|
||||||
out = tag.input type: :hidden, name: :redirect, value: "1"
|
out = f.input attribute, label: false, placeholder: "Search #{name}", input_html: { id: nil, "data-autocomplete": autocomplete }
|
||||||
out += f.input attribute, label: false, placeholder: "Search #{name}", input_html: { id: nil, "data-autocomplete": autocomplete }
|
out += tag.input type: :hidden, name: :redirect, value: 1
|
||||||
|
out += capture { yield f } if block_given?
|
||||||
|
out
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ class Artist < ApplicationRecord
|
|||||||
|
|
||||||
attr_accessor :url_string_changed
|
attr_accessor :url_string_changed
|
||||||
array_attribute :other_names
|
array_attribute :other_names
|
||||||
|
api_attributes including: [:urls]
|
||||||
|
|
||||||
before_validation :normalize_name
|
before_validation :normalize_name
|
||||||
before_validation :normalize_other_names
|
before_validation :normalize_other_names
|
||||||
|
|||||||
Reference in New Issue
Block a user