64 lines
2.0 KiB
Ruby
64 lines
2.0 KiB
Ruby
class Crawlers::PeopleCrawlerController < Crawlers::TissCrawlerController
|
|
|
|
def show_basic
|
|
params[:api] = '/api/person/v22/psuche'
|
|
params[:search_parameter] = 'q'
|
|
puts params[:search_context]
|
|
@host = TissCrawler.host
|
|
|
|
result = TissCrawler.search(params)
|
|
|
|
if result.has_key? :error
|
|
flash[:alert] = 'Something went wrong! ' + result[:error]
|
|
redirect_back(fallback_location: crawlers_tiss_crawler_search_path)
|
|
else
|
|
# TissCrawler performs general search over the available people
|
|
@people = result[:content]
|
|
end
|
|
|
|
end
|
|
|
|
def show_detail
|
|
params[:api] = '/api/person/v22/id/'
|
|
params[:tiss_id] = params[:tiss_id]
|
|
|
|
@personal_annotation = get_stored_annotation FavoritePerson, {tiss_id: params[:tiss_id]}
|
|
@personal_keyword = get_stored_keyword FavoritePerson, {tiss_id: params[:tiss_id]}
|
|
|
|
puts params
|
|
# TissCrawler fetches the person's detail information
|
|
@person = TissCrawler.get_details(params)
|
|
# Host is needed for image rendering
|
|
@host = TissCrawler.host
|
|
end
|
|
|
|
def add_to_fav
|
|
params[:api] = '/api/person/v22/id/'
|
|
puts params[:tiss_id]
|
|
@person = TissCrawler.get_details(params)
|
|
|
|
# create stores the object to the db after creation
|
|
favorite_hash = {tiss_id: @person['tiss_id'],
|
|
# the user who is currently active
|
|
user_id: current_user.id,
|
|
first_name: @person['first_name'],
|
|
last_name: @person['last_name'],
|
|
picture_uri: @person['picture_uri']}
|
|
if FavoritePerson.create(favorite_hash).valid?
|
|
FavoritePerson.create(favorite_hash)
|
|
flash[:alert] = 'Person added to your favorites!'
|
|
else
|
|
flash[:alert] = 'Person is already favorited!'
|
|
end
|
|
redirect_back(fallback_location: crawlers_tiss_crawler_search_path)
|
|
end
|
|
|
|
def add_annotation
|
|
store_annotation FavoritePerson, 'Person', {tiss_id: params[:id]}
|
|
end
|
|
|
|
def add_keyword
|
|
store_keyword FavoritePerson, 'Person', {tiss_id: params[:id]}
|
|
end
|
|
end
|