diff --git a/app/assets/stylesheets/people_crawler.scss b/app/assets/stylesheets/people_crawler.scss new file mode 100644 index 0000000..4c45939 --- /dev/null +++ b/app/assets/stylesheets/people_crawler.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the PeopleCrawler controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: https://sass-lang.com/ diff --git a/app/controllers/tiss_crawler_controller.rb b/app/controllers/crawlers/people_crawler_controller.rb similarity index 52% rename from app/controllers/tiss_crawler_controller.rb rename to app/controllers/crawlers/people_crawler_controller.rb index 3f5d05a..10c483b 100644 --- a/app/controllers/tiss_crawler_controller.rb +++ b/app/controllers/crawlers/people_crawler_controller.rb @@ -1,26 +1,6 @@ -class TissCrawlerController < ApplicationController +class PeopleCrawlerController < TissCrawlerController - # self designed lib to call the Tiss API - require 'tiss/tiss_crawler' - - def search - # search context like 'People', 'Courses', etc is mandatory - $search_context = params[:search_context] - - # 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 + def show_basic params[:api] = '/api/person/v22/psuche' params[:search_parameter] = 'q' puts params[:search_context] @@ -29,7 +9,7 @@ class TissCrawlerController < ApplicationController @people = TissCrawler.search(params) end - def person_show_detail + def show_detail params[:api] = '/api/person/v22/id/' # TissCrawler fetches the person's detail information @@ -38,7 +18,7 @@ class TissCrawlerController < ApplicationController @host = TissCrawler.get_host end - def person_add_to_fav + def add_to_fav puts params[:tiss_id] # create stores the object to the db after creation FavoritePerson.create(tiss_id: params[:tiss_id]) diff --git a/app/controllers/crawlers/tiss_crawler_controller.rb b/app/controllers/crawlers/tiss_crawler_controller.rb new file mode 100644 index 0000000..8efe580 --- /dev/null +++ b/app/controllers/crawlers/tiss_crawler_controller.rb @@ -0,0 +1,32 @@ +class TissCrawlerController < ApplicationController + + # self designed lib to call the Tiss API + require 'tiss/tiss_crawler' + + def search + # search context like 'People', 'Courses', etc is mandatory + $search_context = params[:search_context] + + # 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 show_basic + end + + def show_detail + end + + def add_to_fav + end + +end diff --git a/app/helpers/people_crawler_helper.rb b/app/helpers/people_crawler_helper.rb new file mode 100644 index 0000000..f0357b4 --- /dev/null +++ b/app/helpers/people_crawler_helper.rb @@ -0,0 +1,2 @@ +module PeopleCrawlerHelper +end diff --git a/test/controllers/people_crawler_controller_test.rb b/test/controllers/people_crawler_controller_test.rb new file mode 100644 index 0000000..0c8b164 --- /dev/null +++ b/test/controllers/people_crawler_controller_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class PeopleCrawlerControllerTest < ActionDispatch::IntegrationTest + # test "the truth" do + # assert true + # end +end