refactoring of "abstract" search controller
This commit is contained in:
@@ -1,28 +1,51 @@
|
||||
class TissCrawlerController < ApplicationController
|
||||
|
||||
# self designed lib to call the Tiss API
|
||||
require 'tiss/tiss_crawler'
|
||||
|
||||
def index
|
||||
end
|
||||
def search
|
||||
# search context like 'People', 'Courses', etc is mandatory
|
||||
$search_context = params[:search_context]
|
||||
|
||||
def people_search
|
||||
# evaluate the proper action regarding to the $search_context
|
||||
case $search_context
|
||||
when 'People'
|
||||
# redirect to people_show_basic, propagate the search_term
|
||||
redirect_to :action => 'people_show_basic', :search_term => params[:search_term]
|
||||
when 'Courses'
|
||||
when 'Theses'
|
||||
when 'Projects'
|
||||
else
|
||||
puts 'Undefined search context'
|
||||
end
|
||||
end
|
||||
|
||||
def people_show_basic
|
||||
params[:api] = '/api/person/v22/psuche'
|
||||
params[:search_parameter] = 'q'
|
||||
puts params[:search_context]
|
||||
|
||||
# TissCrawler performs general search over the available people
|
||||
@people = TissCrawler.search(params)
|
||||
end
|
||||
|
||||
def person_show_detail
|
||||
params[:api] = '/api/person/v22/id/'
|
||||
|
||||
# TissCrawler fetches the person's detail information
|
||||
@person = TissCrawler.get_details(params)
|
||||
# Host is needed for image rendering
|
||||
@host = TissCrawler.get_host
|
||||
end
|
||||
|
||||
def person_add_to_fav
|
||||
puts params[:tiss_id]
|
||||
person = FavoritePerson.create(tiss_id: params[:tiss_id])
|
||||
# create stores the object to the db after creation
|
||||
FavoritePerson.create(tiss_id: params[:tiss_id])
|
||||
# redirect and respond with success message
|
||||
respond_to do |format|
|
||||
format.html { redirect_to favorites_favorite_person_index_url, notice: 'Favorite person stored' }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user