From d34a3d583c9849cff0466486c731b77bf7724573 Mon Sep 17 00:00:00 2001 From: Pfingstfrosch Date: Tue, 12 May 2020 19:49:18 +0200 Subject: [PATCH] refactored crawler controllers and bundled them in crawlers namespace --- .../courses_crawler_controller.rb | 2 +- .../people_crawler_controller.rb | 4 +-- .../projects_crawler_controller.rb | 2 +- .../theses_crawler_controller.rb | 2 +- .../{ => crawlers}/tiss_crawler_controller.rb | 6 ++-- .../courses_crawler/show_basic.html.erb | 4 +-- .../courses_crawler/show_detail.html.erb | 0 .../people_crawler/show_basic.html.erb | 4 +-- .../people_crawler/show_detail.html.erb | 0 .../tiss_crawler/search.html.erb | 2 +- app/views/favorites/people.html.erb | 2 +- app/views/layouts/application.html.erb | 2 +- config/routes.rb | 36 ++++++++++--------- 13 files changed, 34 insertions(+), 32 deletions(-) rename app/controllers/{ => crawlers}/courses_crawler_controller.rb (94%) rename app/controllers/{ => crawlers}/people_crawler_controller.rb (89%) rename app/controllers/{ => crawlers}/projects_crawler_controller.rb (54%) rename app/controllers/{ => crawlers}/theses_crawler_controller.rb (55%) rename app/controllers/{ => crawlers}/tiss_crawler_controller.rb (67%) rename app/views/{ => crawlers}/courses_crawler/show_basic.html.erb (62%) rename app/views/{ => crawlers}/courses_crawler/show_detail.html.erb (100%) rename app/views/{ => crawlers}/people_crawler/show_basic.html.erb (78%) rename app/views/{ => crawlers}/people_crawler/show_detail.html.erb (100%) rename app/views/{ => crawlers}/tiss_crawler/search.html.erb (85%) diff --git a/app/controllers/courses_crawler_controller.rb b/app/controllers/crawlers/courses_crawler_controller.rb similarity index 94% rename from app/controllers/courses_crawler_controller.rb rename to app/controllers/crawlers/courses_crawler_controller.rb index 7e4a342..69f47ea 100644 --- a/app/controllers/courses_crawler_controller.rb +++ b/app/controllers/crawlers/courses_crawler_controller.rb @@ -1,4 +1,4 @@ -class CoursesCrawlerController < TissCrawlerController +class Crawlers::CoursesCrawlerController < TissCrawlerController def show_basic params[:api] = '/api/search/course/v1.0/quickSearch' diff --git a/app/controllers/people_crawler_controller.rb b/app/controllers/crawlers/people_crawler_controller.rb similarity index 89% rename from app/controllers/people_crawler_controller.rb rename to app/controllers/crawlers/people_crawler_controller.rb index 2812373..20d2ce1 100644 --- a/app/controllers/people_crawler_controller.rb +++ b/app/controllers/crawlers/people_crawler_controller.rb @@ -1,4 +1,4 @@ -class PeopleCrawlerController < TissCrawlerController +class Crawlers::PeopleCrawlerController < TissCrawlerController def show_basic params[:api] = '/api/person/v22/psuche' @@ -30,7 +30,7 @@ class PeopleCrawlerController < TissCrawlerController if FavoritePerson.create(tiss_id: @person['tiss_id'], first_name: @person['first_name'], last_name: @person['last_name'], picture_uri: @person['picture_uri']).valid? FavoritePerson.create(tiss_id: @person['tiss_id'], first_name: @person['first_name'], last_name: @person['last_name'], picture_uri: @person['picture_uri']) respond_to do |format| - format.html { redirect_to favorite_person_index_url, notice: 'Favorite person stored' } + format.html { redirect_to favorites_people_url, notice: 'Favorite person stored' } end else flash[:alert] = "Person is already favorited!" diff --git a/app/controllers/projects_crawler_controller.rb b/app/controllers/crawlers/projects_crawler_controller.rb similarity index 54% rename from app/controllers/projects_crawler_controller.rb rename to app/controllers/crawlers/projects_crawler_controller.rb index c090dda..d5f9089 100644 --- a/app/controllers/projects_crawler_controller.rb +++ b/app/controllers/crawlers/projects_crawler_controller.rb @@ -1,4 +1,4 @@ -class ProjectsCrawlerController < TissCrawlerController +class Crawlers::ProjectsCrawlerController < TissCrawlerController def show_basic end diff --git a/app/controllers/theses_crawler_controller.rb b/app/controllers/crawlers/theses_crawler_controller.rb similarity index 55% rename from app/controllers/theses_crawler_controller.rb rename to app/controllers/crawlers/theses_crawler_controller.rb index 600592a..9e2df8e 100644 --- a/app/controllers/theses_crawler_controller.rb +++ b/app/controllers/crawlers/theses_crawler_controller.rb @@ -1,4 +1,4 @@ -class ThesesCrawlerController < TissCrawlerController +class Crawlers::ThesesCrawlerController < TissCrawlerController def show_basic end diff --git a/app/controllers/tiss_crawler_controller.rb b/app/controllers/crawlers/tiss_crawler_controller.rb similarity index 67% rename from app/controllers/tiss_crawler_controller.rb rename to app/controllers/crawlers/tiss_crawler_controller.rb index aab42a1..fac3647 100644 --- a/app/controllers/tiss_crawler_controller.rb +++ b/app/controllers/crawlers/tiss_crawler_controller.rb @@ -1,4 +1,4 @@ -class TissCrawlerController < ApplicationController +class Crawlers::TissCrawlerController < ApplicationController # self designed lib to call the Tiss API require 'tiss/tiss_crawler' @@ -11,10 +11,10 @@ class TissCrawlerController < ApplicationController case $search_context when 'People' # redirect to people_show_basic, propagate the search_term - redirect_to :controller => 'people_crawler', :action => :show_basic, :search_term => params[:search_term] + redirect_to :controller => 'crawlers/people_crawler', :action => :show_basic, :search_term => params[:search_term] when 'Courses' # redirect to courses_show_basic, propagate the search_term - redirect_to :controller => 'courses_crawler', :action => :show_basic, :search_term => params[:search_term] + redirect_to :controller => 'crawlers/courses_crawler', :action => :show_basic, :search_term => params[:search_term] when 'Theses' when 'Projects' else diff --git a/app/views/courses_crawler/show_basic.html.erb b/app/views/crawlers/courses_crawler/show_basic.html.erb similarity index 62% rename from app/views/courses_crawler/show_basic.html.erb rename to app/views/crawlers/courses_crawler/show_basic.html.erb index f95b839..01baf24 100644 --- a/app/views/courses_crawler/show_basic.html.erb +++ b/app/views/crawlers/courses_crawler/show_basic.html.erb @@ -3,7 +3,7 @@