diff --git a/app/controllers/tiss_crawler_controller.rb b/app/controllers/tiss_crawler_controller.rb index 8482bec..3f5d05a 100644 --- a/app/controllers/tiss_crawler_controller.rb +++ b/app/controllers/tiss_crawler_controller.rb @@ -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 diff --git a/app/views/courses/index.html.erb b/app/views/courses/index.html.erb deleted file mode 100644 index 1d072e8..0000000 --- a/app/views/courses/index.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -
Find me in app/views/courses/index.html.erb
diff --git a/app/views/favorites/favorite_person/index.html.erb b/app/views/favorites/favorite_person/index.html.erb index 604245e..3e21932 100644 --- a/app/views/favorites/favorite_person/index.html.erb +++ b/app/views/favorites/favorite_person/index.html.erb @@ -2,5 +2,5 @@For now only the tiss_ids are stored and shown
<% @favoritePeople.each do |favPerson| %> - Tiss_id: <%= favPerson.tiss_id %> +Tiss_id: <%= favPerson.tiss_id %>
<% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 5cfbd1c..d7c5d1d 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,7 +21,7 @@ tiss2go