From 92eff82f1ad0346765653652ada490e0ff6995d6 Mon Sep 17 00:00:00 2001 From: Pfingstfrosch Date: Tue, 12 May 2020 19:19:04 +0200 Subject: [PATCH] refactored favorites: instead of using a fav page for each content, use a general favorites pane where the user can select which favs shall be shown --- app/assets/stylesheets/favorites.scss | 25 +++++++++++++++++++ app/assets/stylesheets/people_crawler.scss | 18 +++++++++++++ .../favorites/favorite_person_controller.rb | 6 ----- app/controllers/favorites_controller.rb | 23 +++++++++++++++++ app/controllers/people_crawler_controller.rb | 2 +- .../favorites/favorite_person_helper.rb | 2 -- app/helpers/favorites/favorites_helper.rb | 2 ++ app/views/favorites/_nav.html.erb | 6 +++++ app/views/favorites/courses.html.erb | 3 +++ app/views/favorites/index.html.erb | 2 ++ .../index.html.erb => people.html.erb} | 2 ++ app/views/favorites/projects.html.erb | 3 +++ app/views/favorites/theses.html.erb | 3 +++ 13 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 app/assets/stylesheets/favorites.scss delete mode 100644 app/controllers/favorites/favorite_person_controller.rb create mode 100644 app/controllers/favorites_controller.rb delete mode 100644 app/helpers/favorites/favorite_person_helper.rb create mode 100644 app/helpers/favorites/favorites_helper.rb create mode 100644 app/views/favorites/_nav.html.erb create mode 100644 app/views/favorites/courses.html.erb create mode 100644 app/views/favorites/index.html.erb rename app/views/favorites/{favorite_person/index.html.erb => people.html.erb} (95%) create mode 100644 app/views/favorites/projects.html.erb create mode 100644 app/views/favorites/theses.html.erb diff --git a/app/assets/stylesheets/favorites.scss b/app/assets/stylesheets/favorites.scss new file mode 100644 index 0000000..2baf7cb --- /dev/null +++ b/app/assets/stylesheets/favorites.scss @@ -0,0 +1,25 @@ +// Place all the styles related to the favorites controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: https://sass-lang.com/ + +.favNav { + + display: flex; + + a:link, a:visited { + font-family: Helvetica, sans-serif; + transition: .3s all ease-in-out; + font-size: 18px; + background-color: #3F51B5; + color: white; + padding: 5px 10px; + text-align: center; + text-decoration: none; + display: inline-block; + flex-grow: 1; + } + + a:hover, a:active { + background-color: #009688; + } +} \ No newline at end of file diff --git a/app/assets/stylesheets/people_crawler.scss b/app/assets/stylesheets/people_crawler.scss index 6c2d8b9..8e3c767 100644 --- a/app/assets/stylesheets/people_crawler.scss +++ b/app/assets/stylesheets/people_crawler.scss @@ -2,6 +2,24 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: https://sass-lang.com/ +h5 { + font-weight: normal; + opacity: 0.8; +} + +.profile-picture { + float: right; + width: 25%; + + img { + width: 100%; + max-width: 260px; + height: auto; + object-fit: contain; + } +} + + .people-list { list-style: none; padding: 0; diff --git a/app/controllers/favorites/favorite_person_controller.rb b/app/controllers/favorites/favorite_person_controller.rb deleted file mode 100644 index 4f75668..0000000 --- a/app/controllers/favorites/favorite_person_controller.rb +++ /dev/null @@ -1,6 +0,0 @@ -class Favorites::FavoritePersonController < ApplicationController - def index - @favoritePeople = FavoritePerson.all - @host = 'https://tiss.tuwien.ac.at' - end -end diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb new file mode 100644 index 0000000..4f12524 --- /dev/null +++ b/app/controllers/favorites_controller.rb @@ -0,0 +1,23 @@ +class FavoritesController < ApplicationController + + def index + + end + + def people + @favoritePeople = FavoritePerson.all + @host = 'https://tiss.tuwien.ac.at' + end + + def courses + + end + + def theses + + end + + def projects + + end +end diff --git a/app/controllers/people_crawler_controller.rb b/app/controllers/people_crawler_controller.rb index 375125f..2812373 100644 --- a/app/controllers/people_crawler_controller.rb +++ b/app/controllers/people_crawler_controller.rb @@ -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 favorites_favorite_person_index_url, notice: 'Favorite person stored' } + format.html { redirect_to favorite_person_index_url, notice: 'Favorite person stored' } end else flash[:alert] = "Person is already favorited!" diff --git a/app/helpers/favorites/favorite_person_helper.rb b/app/helpers/favorites/favorite_person_helper.rb deleted file mode 100644 index 36e581b..0000000 --- a/app/helpers/favorites/favorite_person_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Favorites::FavoritePersonHelper -end diff --git a/app/helpers/favorites/favorites_helper.rb b/app/helpers/favorites/favorites_helper.rb new file mode 100644 index 0000000..df9cc82 --- /dev/null +++ b/app/helpers/favorites/favorites_helper.rb @@ -0,0 +1,2 @@ +module Favorites::FavoritesHelper +end diff --git a/app/views/favorites/_nav.html.erb b/app/views/favorites/_nav.html.erb new file mode 100644 index 0000000..00728b8 --- /dev/null +++ b/app/views/favorites/_nav.html.erb @@ -0,0 +1,6 @@ +
+ <%= link_to 'People', favorites_people_url%> + <%= link_to 'Courses', favorites_courses_url %> + <%= link_to 'Theses', favorites_theses_url %> + <%= link_to 'Projects', favorites_projects_url %> +
\ No newline at end of file diff --git a/app/views/favorites/courses.html.erb b/app/views/favorites/courses.html.erb new file mode 100644 index 0000000..8509c2d --- /dev/null +++ b/app/views/favorites/courses.html.erb @@ -0,0 +1,3 @@ +<%= render(:partial => "nav")%> + +

Fav Courses

\ No newline at end of file diff --git a/app/views/favorites/index.html.erb b/app/views/favorites/index.html.erb new file mode 100644 index 0000000..945b593 --- /dev/null +++ b/app/views/favorites/index.html.erb @@ -0,0 +1,2 @@ +<%= render(:partial => "nav")%> + diff --git a/app/views/favorites/favorite_person/index.html.erb b/app/views/favorites/people.html.erb similarity index 95% rename from app/views/favorites/favorite_person/index.html.erb rename to app/views/favorites/people.html.erb index a304a14..b66520d 100644 --- a/app/views/favorites/favorite_person/index.html.erb +++ b/app/views/favorites/people.html.erb @@ -1,3 +1,5 @@ +<%= render(:partial => "nav")%> +

Favorite People