diff --git a/app/controllers/courses_controller.rb b/app/controllers/favorites/courses_controller.rb similarity index 100% rename from app/controllers/courses_controller.rb rename to app/controllers/favorites/courses_controller.rb diff --git a/app/controllers/people_controller.rb b/app/controllers/favorites/people_controller.rb similarity index 100% rename from app/controllers/people_controller.rb rename to app/controllers/favorites/people_controller.rb diff --git a/app/controllers/projects_controller.rb b/app/controllers/favorites/projects_controller.rb similarity index 100% rename from app/controllers/projects_controller.rb rename to app/controllers/favorites/projects_controller.rb diff --git a/app/controllers/theses_controller.rb b/app/controllers/favorites/theses_controller.rb similarity index 100% rename from app/controllers/theses_controller.rb rename to app/controllers/favorites/theses_controller.rb diff --git a/app/controllers/tiss_crawler_controller.rb b/app/controllers/tiss_crawler_controller.rb index 5289d42..95b9f1c 100644 --- a/app/controllers/tiss_crawler_controller.rb +++ b/app/controllers/tiss_crawler_controller.rb @@ -5,33 +5,19 @@ class TissCrawlerController < ApplicationController def index end - def show_basic + def people_search end - def show_detail - end - - def search - context = params[:context] - case context - 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.write[:alert] = "Unknown search context" - end - - end - - require 'tiss/tiss_crawler' - - def show_basic + def people_show_basic result = TissCrawler.search(params) - @people = result.map { |person| Tiss::Person.new(person) } - # render(people_show_path, detail: false) - render template: people_show_basic_path + $people = result.map { |person| Tiss::Person.new(person) } + @people = $people + end + + def people_show_detail + people = $people + index = params[:index] + @person = people[Integer(index)] end end diff --git a/app/services/tiss.rb b/app/services/tiss.rb index 3d64c9f..03251a4 100644 --- a/app/services/tiss.rb +++ b/app/services/tiss.rb @@ -1,6 +1,10 @@ module Tiss class Base + def base_uri + 'https://tiss.tuwien.ac.at/' + end + def initialize(args = {}) args.each do |name, value| attr_name = name.to_s.underscore diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7f24372..1fef818 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -21,10 +21,10 @@
<%= link_to 'Home', root_path %> - <%= link_to 'People', people_index_path %> - <%= link_to 'Courses', courses_index_path %> - <%= link_to 'Projects', projects_index_path %> - <%= link_to 'Theses', theses_index_path %> + <%= link_to 'People', tiss_crawler_people_search_path %> + <%#= link_to 'Courses', courses_index_path %> + <%#= link_to 'Projects', projects_index_path %> + <%#= link_to 'Theses', theses_index_path %>
<% if user_signed_in? %> diff --git a/app/views/tiss_crawler/search_people.html.erb b/app/views/tiss_crawler/people_search.html.erb similarity index 60% rename from app/views/tiss_crawler/search_people.html.erb rename to app/views/tiss_crawler/people_search.html.erb index be84d5c..17adb44 100644 --- a/app/views/tiss_crawler/search_people.html.erb +++ b/app/views/tiss_crawler/people_search.html.erb @@ -1,8 +1,8 @@ -<%= form_tag('/tiss_crawler/search', :method => "get") do %> +<%= form_tag('/tiss_crawler/people_show_basic', :method => "get") do %> <%= hidden_field_tag(:context, 'People') %> <%= hidden_field_tag(:api, '/api/person/v22/psuche') %> <%= hidden_field_tag(:search_parameter, 'q') %> - <%= label_tag(:search_term, "Search for:") %> + <%= label_tag(:search_term, "Search for people @TU Vienna:") %> <%= text_field_tag(:search_term) %> <%= submit_tag("Search") %> <% end %> \ No newline at end of file diff --git a/app/views/tiss_crawler/show_people.html.erb b/app/views/tiss_crawler/people_show_basic.html.erb similarity index 51% rename from app/views/tiss_crawler/show_people.html.erb rename to app/views/tiss_crawler/people_show_basic.html.erb index 42cc75c..2dad564 100644 --- a/app/views/tiss_crawler/show_people.html.erb +++ b/app/views/tiss_crawler/people_show_basic.html.erb @@ -1,8 +1,9 @@ This is the result for your basic people search: -<% @people.each do |person| %> +<% @people.each_with_index do |person, index| %>

<%= person.first_name %> <%= person.last_name %> + <%= button_to 'Details', action: :people_show_detail, index: index %>

<% end %> diff --git a/app/views/tiss_crawler/people_show_detail.html.erb b/app/views/tiss_crawler/people_show_detail.html.erb new file mode 100644 index 0000000..18f2a0d --- /dev/null +++ b/app/views/tiss_crawler/people_show_detail.html.erb @@ -0,0 +1,14 @@ +Chosen person in detail view: + +<% if @person != nil %> + <% if @person.picture_uri != nil %> + <%= image_tag @person.base_uri + @person.picture_uri %> + <% end %> +

<%= @person.preceding_titles %> <%= @person.first_name %> <%= @person.last_name %>, + <%= @person.gender %> <%= @person.postpositioned_titles %>

+

Phone: <%= @person.main_phone_number %>

+

Mail: <%= @person.main_email %>

+

Other mails: <%= @person.other_emails %>

+

Main addresses: <%= @person.main_addresses %>

+ +<% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 92709e4..893d67d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,20 +1,12 @@ Rails.application.routes.draw do devise_for :users, path_names: {sign_in: 'log_in', sign_out: 'log out'} - get 'people/index' - get 'people/show_basic' - post 'people/show_detailed' - get 'theses/index' - get 'theses/show_basic' - get 'theses/show_detailed' - get 'projects/index' - get 'projects/show_basic' - get 'projects/show_detailed' - get 'courses/index' - get 'courses/show_basic' - get 'courses/show_detailed' - get 'login/index' - get 'tiss_crawler/search' + + get 'login/index' + get 'tiss_crawler/people_search' + get 'tiss_crawler/people_show_basic' + get 'tiss_crawler/people_show_detail' + post 'tiss_crawler/people_show_detail' # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html root 'login#index'