Implement basic search for courses

This commit is contained in:
Tobias Eidelpes 2020-05-09 12:16:20 +02:00
parent 0314b75b24
commit 74bd875427
6 changed files with 82 additions and 0 deletions

View File

@ -1,3 +1,49 @@
// Place all the styles related to the CoursesCrawler controller here. // Place all the styles related to the CoursesCrawler controller here.
// They will automatically be included in application.css. // They will automatically be included in application.css.
// You can use Sass (SCSS) here: https://sass-lang.com/ // You can use Sass (SCSS) here: https://sass-lang.com/
.courses-list {
list-style: none;
padding: 0;
margin: 0;
a {
text-decoration: none;
color: black;
}
.course {
line-height: 72px;
width: 100%;
padding: 8px 0 8px 0;
.list-link {
float: left;
width: 89%;
height: 72px;
}
.course-title {
width: 100%;
display: inline-block;
text-align: left;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.add-to-fav {
display: inline-block;
vertical-align: middle;
float: right;
width: 36px;
height: 36px;
svg {
width: 100%;
height: auto;
vertical-align: middle;
}
}
}
}

View File

@ -1,6 +1,13 @@
class CoursesCrawlerController < TissCrawlerController class CoursesCrawlerController < TissCrawlerController
def show_basic def show_basic
params[:api] = '/api/search/course/v1.0/quickSearch'
params[:search_parameter] = 'searchterm'
puts params[:search_context]
@host = TissCrawler.get_host
# TissCrawler performs general search over the available courses
@courses = TissCrawler.search(params)
end end
def show_detail def show_detail

View File

@ -13,6 +13,8 @@ class TissCrawlerController < ApplicationController
# redirect to people_show_basic, propagate the search_term # 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 => 'people_crawler', :action => :show_basic, :search_term => params[:search_term]
when 'Courses' when 'Courses'
# redirect to courses_show_basic, propagate the search_term
redirect_to :controller => 'courses_crawler', :action => :show_basic, :search_term => params[:search_term]
when 'Theses' when 'Theses'
when 'Projects' when 'Projects'
else else

View File

@ -0,0 +1,20 @@
<h1>Results for "<%= params[:search_term] %>"</h1>
<ul class="courses-list">
<% @courses.each_with_index do |course| %>
<li class="course">
<%= link_to courses_crawler_show_detail_url(:title => course['title'], :detail_url => course['detail_url']) do %>
<span class="list-link">
<span class="course-title">
<%= course['title'] %>
</span>
</span>
<% end %>
<span class="add-to-fav">
<%= link_to courses_crawler_add_to_fav_url(:title => course['title'], :detail_url => course['detail_url']) do %>
<%= show_svg('favorite-24px.svg') %>
<% end %>
</span>
</li>
<% end %>
</ul>

View File

@ -5,12 +5,19 @@ Rails.application.routes.draw do
get 'login/index' get 'login/index'
get 'tiss_crawler/search' get 'tiss_crawler/search'
get 'people_crawler/show_basic' get 'people_crawler/show_basic'
get 'people_crawler/show_detail' get 'people_crawler/show_detail'
post 'people_crawler/show_detail' post 'people_crawler/show_detail'
get 'people_crawler/add_to_fav' get 'people_crawler/add_to_fav'
post 'people_crawler/add_to_fav' post 'people_crawler/add_to_fav'
get 'courses_crawler/show_basic'
get 'courses_crawler/show_detail'
post 'courses_crawler/show_detail'
get 'courses_crawler/add_to_fav'
post 'courses_crawler/add_to_fav'
namespace :favorites do namespace :favorites do
get 'favorite_person/index' get 'favorite_person/index'
end end