diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 679dda3..c28a694 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -3,22 +3,10 @@ class CoursesController < TissCrawlerController def index end - def show + def show_basic end - def new - end - - def edit - end - - def create - end - - def update - end - - def destroy + def show_detailed end end diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 4c4f7ee..a14d5ea 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -3,22 +3,10 @@ class PeopleController < TissCrawlerController def index end - def show + def show_basic end - def new - end - - def edit - end - - def create - end - - def update - end - - def destroy + def show_detail end end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 9b5a756..87fa09d 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -3,22 +3,10 @@ class ProjectsController < TissCrawlerController def index end - def show + def show_basic end - def new - end - - def edit - end - - def create - end - - def update - end - - def destroy + def show_detailed end end diff --git a/app/controllers/theses_controller.rb b/app/controllers/theses_controller.rb index 77423cd..1712ca1 100644 --- a/app/controllers/theses_controller.rb +++ b/app/controllers/theses_controller.rb @@ -3,22 +3,10 @@ class ThesesController < TissCrawlerController def index end - def show + def show_basic end - def new - end - - def edit - end - - def create - end - - def update - end - - def destroy + def show_detailed end end diff --git a/app/controllers/tiss_crawler_controller.rb b/app/controllers/tiss_crawler_controller.rb index b792b48..7d55aab 100644 --- a/app/controllers/tiss_crawler_controller.rb +++ b/app/controllers/tiss_crawler_controller.rb @@ -1,76 +1,18 @@ class TissCrawlerController < ApplicationController - require 'httparty' - - $host = 'https://tiss.tuwien.ac.at' + require 'tiss/tiss_crawler' def search - url = _build_search_url(params) - context = _get_context(params) - - response = HTTParty.get(url) + context = params[:context] case context - when 'People' - _search_people_result(response) + when "People" + result = TissCrawler.search(params) + @people = result.map { |person| Tiss::Person.new(person) } + # render(people_show_path, detail: false) + render template: people_show_basic_path else - flash.now[:alert] = 'Unknown Tiss Crawler Context' + flash.write[:alert] = "Unknown search context" end - end - - def _build_search_url(params) - if params[:api].blank? - flash.now[:alert] = 'No api configured!' - return - else - # get the api ... e.g. /'api/person/v22/psuche' - api = params[:api] - end - - if params[:search_parameter].blank? - flash.now[:alert] = 'No search_parameter configured!' - return - else - # get the search param ... e.g. 'q' - search_parameter = params[:search_parameter] - end - - if params[:search_term].blank? - flash.now[:alert] = 'No search_term configured!' - return - else - # get and parameterize search term q, replace whitespaces with + - search_term = params[:search_term].parameterize(separator: '+') - end - - # concat and return the api call url ... e.g. https://tiss.tuwien.ac.at/api/person/v22/psuche?q=max+mustermann - $host + api + '?' + search_parameter + '=' + search_term - end - - def _get_context(params) - if params[:context].blank? - flash.now[:alert] = 'No context configured!' - else - # return the context - params[:context] - end - end - - def _search_people_result(response) - # redirect_to(controller: 'people', :action => 'show', flash: {response: response}) - @response = "Test" - puts('got here', response) - end - - - - - - - - - - - def details end diff --git a/app/services/tiss.rb b/app/services/tiss.rb new file mode 100644 index 0000000..3d64c9f --- /dev/null +++ b/app/services/tiss.rb @@ -0,0 +1,39 @@ +module Tiss + class Base + + def initialize(args = {}) + args.each do |name, value| + attr_name = name.to_s.underscore + send("#{attr_name}=", value) if respond_to?("#{attr_name}=") + end + end + + end + + class Person < Base + + # tiss json properties + attr_accessor :tiss_id, + :oid, + :old_tiss_ids, + :first_name, + :last_name, + :gender, + :pseudoperson, + :preceding_titles, + :postpositioned_titles, + :orcid, + :card_uri, + :picture_uri, + :main_phone_number, + :main_email, + :other_emails, + :main_addresses, + :employee + + def initialize(args = {}) + super(args) + end + + end +end \ No newline at end of file diff --git a/app/views/courses/create.html.erb b/app/views/courses/create.html.erb deleted file mode 100644 index 0c42b4e..0000000 --- a/app/views/courses/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -
Find me in app/views/courses/create.html.erb
diff --git a/app/views/courses/destroy.html.erb b/app/views/courses/destroy.html.erb deleted file mode 100644 index b6e568a..0000000 --- a/app/views/courses/destroy.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/courses/destroy.html.erb
diff --git a/app/views/courses/edit.html.erb b/app/views/courses/edit.html.erb deleted file mode 100644 index 20dc4d9..0000000 --- a/app/views/courses/edit.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/courses/edit.html.erb
diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb deleted file mode 100644 index aea750a..0000000 --- a/app/views/courses/new.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/courses/new.html.erb
diff --git a/app/views/courses/show.html.erb b/app/views/courses/show_basic.html.erb similarity index 64% rename from app/views/courses/show.html.erb rename to app/views/courses/show_basic.html.erb index 6c14168..824ffbd 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show_basic.html.erb @@ -1,2 +1,2 @@ -Find me in app/views/courses/show.html.erb
diff --git a/app/views/courses/show_detailed.html.erb b/app/views/courses/show_detailed.html.erb new file mode 100644 index 0000000..8615080 --- /dev/null +++ b/app/views/courses/show_detailed.html.erb @@ -0,0 +1,2 @@ +Find me in app/views/courses/show.html.erb
diff --git a/app/views/courses/update.html.erb b/app/views/courses/update.html.erb deleted file mode 100644 index d681fa8..0000000 --- a/app/views/courses/update.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/courses/update.html.erb
diff --git a/app/views/people/create.html.erb b/app/views/people/create.html.erb deleted file mode 100644 index eaa521a..0000000 --- a/app/views/people/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/people/create.html.erb
diff --git a/app/views/people/destroy.html.erb b/app/views/people/destroy.html.erb deleted file mode 100644 index 42a6ded..0000000 --- a/app/views/people/destroy.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/people/destroy.html.erb
diff --git a/app/views/people/edit.html.erb b/app/views/people/edit.html.erb deleted file mode 100644 index b807532..0000000 --- a/app/views/people/edit.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/people/edit.html.erb
diff --git a/app/views/people/new.html.erb b/app/views/people/new.html.erb deleted file mode 100644 index 783270e..0000000 --- a/app/views/people/new.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/people/new.html.erb
diff --git a/app/views/people/show.html.erb b/app/views/people/show_basic.html.erb similarity index 53% rename from app/views/people/show.html.erb rename to app/views/people/show_basic.html.erb index 0de3090..df30083 100644 --- a/app/views/people/show.html.erb +++ b/app/views/people/show_basic.html.erb @@ -1,2 +1,4 @@ -Find me in app/views/people/show.html.erb
+ +<%= @people %> \ No newline at end of file diff --git a/app/views/people/show_detailed.html.erb b/app/views/people/show_detailed.html.erb new file mode 100644 index 0000000..f810ca6 --- /dev/null +++ b/app/views/people/show_detailed.html.erb @@ -0,0 +1,4 @@ +Find me in app/views/people/show.html.erb
+ +<%= @people %> \ No newline at end of file diff --git a/app/views/people/update.html.erb b/app/views/people/update.html.erb deleted file mode 100644 index 79a6b9f..0000000 --- a/app/views/people/update.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/people/update.html.erb
diff --git a/app/views/projects/create.html.erb b/app/views/projects/create.html.erb deleted file mode 100644 index b3ed4df..0000000 --- a/app/views/projects/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/projects/create.html.erb
diff --git a/app/views/projects/destroy.html.erb b/app/views/projects/destroy.html.erb deleted file mode 100644 index 4e38ae4..0000000 --- a/app/views/projects/destroy.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/projects/destroy.html.erb
diff --git a/app/views/projects/edit.html.erb b/app/views/projects/edit.html.erb deleted file mode 100644 index 73b7bae..0000000 --- a/app/views/projects/edit.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/projects/edit.html.erb
diff --git a/app/views/projects/new.html.erb b/app/views/projects/new.html.erb deleted file mode 100644 index 1ad84ab..0000000 --- a/app/views/projects/new.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/projects/new.html.erb
diff --git a/app/views/projects/show.html.erb b/app/views/projects/show_basic.html.erb similarity index 63% rename from app/views/projects/show.html.erb rename to app/views/projects/show_basic.html.erb index f45b075..960cc1c 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show_basic.html.erb @@ -1,2 +1,2 @@ -Find me in app/views/projects/show.html.erb
diff --git a/app/views/projects/show_detailed.html.erb b/app/views/projects/show_detailed.html.erb new file mode 100644 index 0000000..c3f4286 --- /dev/null +++ b/app/views/projects/show_detailed.html.erb @@ -0,0 +1,2 @@ +Find me in app/views/projects/show.html.erb
diff --git a/app/views/projects/update.html.erb b/app/views/projects/update.html.erb deleted file mode 100644 index a88e7ce..0000000 --- a/app/views/projects/update.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/projects/update.html.erb
diff --git a/app/views/theses/create.html.erb b/app/views/theses/create.html.erb deleted file mode 100644 index 21455db..0000000 --- a/app/views/theses/create.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/theses/create.html.erb
diff --git a/app/views/theses/destroy.html.erb b/app/views/theses/destroy.html.erb deleted file mode 100644 index b3278fd..0000000 --- a/app/views/theses/destroy.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/theses/destroy.html.erb
diff --git a/app/views/theses/edit.html.erb b/app/views/theses/edit.html.erb deleted file mode 100644 index 770d958..0000000 --- a/app/views/theses/edit.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/theses/edit.html.erb
diff --git a/app/views/theses/new.html.erb b/app/views/theses/new.html.erb deleted file mode 100644 index 9e8d1b5..0000000 --- a/app/views/theses/new.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/theses/new.html.erb
diff --git a/app/views/theses/show.html.erb b/app/views/theses/show.basic.erb similarity index 64% rename from app/views/theses/show.html.erb rename to app/views/theses/show.basic.erb index 32bdd00..4e9ae09 100644 --- a/app/views/theses/show.html.erb +++ b/app/views/theses/show.basic.erb @@ -1,2 +1,2 @@ -Find me in app/views/theses/show.html.erb
diff --git a/app/views/theses/show_detailed.html.erb b/app/views/theses/show_detailed.html.erb new file mode 100644 index 0000000..595099b --- /dev/null +++ b/app/views/theses/show_detailed.html.erb @@ -0,0 +1,2 @@ +Find me in app/views/theses/show.html.erb
diff --git a/app/views/theses/update.html.erb b/app/views/theses/update.html.erb deleted file mode 100644 index eeab523..0000000 --- a/app/views/theses/update.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -Find me in app/views/theses/update.html.erb
diff --git a/app/views/tiss_crawler/search.html.erb b/app/views/tiss_crawler/search.html.erb index 5b628fa..e69de29 100644 --- a/app/views/tiss_crawler/search.html.erb +++ b/app/views/tiss_crawler/search.html.erb @@ -1 +0,0 @@ -<% render @response %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index fb2a15b..feb2cde 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,40 +1,17 @@ Rails.application.routes.draw do devise_for :users, path_names: {sign_in: 'log_in', sign_out: 'log out'} get 'theses/index' - get 'theses/show' - get 'theses/new' - get 'theses/edit' - get 'theses/create' - get 'theses/update' - get 'theses/destroy' + get 'theses/show_basic' + get 'theses/show_detailed' get 'projects/index' - get 'projects/show' - get 'projects/new' - get 'projects/edit' - get 'projects/create' - get 'projects/update' - get 'projects/destroy' + get 'projects/show_basic' + get 'projects/show_detailed' get 'people/index' - get 'people/show' - get 'people/new' - get 'people/edit' - get 'people/create' - get 'people/update' - get 'people/destroy' - get 'login/index' - get 'login/show' - get 'login/new' - get 'login/edit' - get 'login/create' - get 'login/update' - get 'login/destroy' + get 'people/show_basic' + get 'people/show_detailed' get 'courses/index' - get 'courses/show' - get 'courses/new' - get 'courses/edit' - get 'courses/create' - get 'courses/update' - get 'courses/destroy' + get 'courses/show_basic' + get 'courses/show_detailed' get 'login/index' get 'tisscrawler/search', :to => 'tiss_crawler#search' diff --git a/lib/tiss/tiss_crawler.rb b/lib/tiss/tiss_crawler.rb new file mode 100644 index 0000000..f43baa0 --- /dev/null +++ b/lib/tiss/tiss_crawler.rb @@ -0,0 +1,23 @@ +class TissCrawler + + require 'httparty' + + $host = 'https://tiss.tuwien.ac.at' + + def self.search(params) + api = params[:api] + search_parameter = params[:search_parameter] + search_term = params[:search_term].parameterize(separator: '+') + url = $host + api + '?' + search_parameter + '=' + search_term + puts(url) + + response = HTTParty.get(url) + JSON.parse(response.body)["results"] + end + + + def details + + end + +end \ No newline at end of file diff --git a/test/controllers/courses_controller_test.rb b/test/controllers/courses_controller_test.rb index b87a5ad..b50ae71 100644 --- a/test/controllers/courses_controller_test.rb +++ b/test/controllers/courses_controller_test.rb @@ -6,7 +6,7 @@ class CoursesControllerTest < ActionDispatch::IntegrationTest assert_response :success end - test "should get show" do + test "should get show_basic" do get courses_show_url assert_response :success end diff --git a/test/controllers/login_controller_test.rb b/test/controllers/login_controller_test.rb index c3a6335..4ad1396 100644 --- a/test/controllers/login_controller_test.rb +++ b/test/controllers/login_controller_test.rb @@ -6,7 +6,7 @@ class LoginControllerTest < ActionDispatch::IntegrationTest assert_response :success end - test "should get show" do + test "should get show_basic" do get login_show_url assert_response :success end diff --git a/test/controllers/people_controller_test.rb b/test/controllers/people_controller_test.rb index 7930378..776a757 100644 --- a/test/controllers/people_controller_test.rb +++ b/test/controllers/people_controller_test.rb @@ -6,7 +6,7 @@ class PeopleControllerTest < ActionDispatch::IntegrationTest assert_response :success end - test "should get show" do + test "should get show_basic" do get people_show_url assert_response :success end diff --git a/test/controllers/projects_controller_test.rb b/test/controllers/projects_controller_test.rb index 47126ce..53d1d19 100644 --- a/test/controllers/projects_controller_test.rb +++ b/test/controllers/projects_controller_test.rb @@ -6,7 +6,7 @@ class ProjectsControllerTest < ActionDispatch::IntegrationTest assert_response :success end - test "should get show" do + test "should get show_basic" do get projects_show_url assert_response :success end diff --git a/test/controllers/theses_controller_test.rb b/test/controllers/theses_controller_test.rb index 75d3567..1596012 100644 --- a/test/controllers/theses_controller_test.rb +++ b/test/controllers/theses_controller_test.rb @@ -6,7 +6,7 @@ class ThesesControllerTest < ActionDispatch::IntegrationTest assert_response :success end - test "should get show" do + test "should get show_basic" do get theses_show_url assert_response :success end