Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TunesTakeout #22

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
679d790
Created models and controllers.
abrown152 May 18, 2016
9e57fa5
Added Spotify API configuration.
abrown152 May 18, 2016
5e08361
Merge commit.
abrown152 May 18, 2016
dbefe0f
Completed Spotify redirect and callback.
abrown152 May 19, 2016
5590266
Fixed bug that prevented Spotify UID from showing up.
abrown152 May 19, 2016
b224843
Added columns for required User information.
abrown152 May 19, 2016
22ed85b
Added login/logout capability.
abrown152 May 19, 2016
f4b31ec
Added TunesTakeoutWrapper to lib directory.
abrown152 May 20, 2016
fc09364
Added show method to suggestions controller.
abrown152 May 20, 2016
6a51ffa
Created TunesTakeoutWrapper, updated suggestions controller, and crea…
abrown152 May 20, 2016
b84aeb4
PR
abrown152 May 23, 2016
582537e
Undo some messy suggestions controller code to take a different appro…
abrown152 May 29, 2016
a39730a
Refactored suggestions controller methods.
abrown152 May 29, 2016
06e6425
Updated Top 20 method and view to show only suggestion info.
abrown152 May 29, 2016
73b302e
Created Spotify wrapper.
abrown152 May 30, 2016
11e2375
Top twenty now returns names of artists, albums, and tracks.
abrown152 May 30, 2016
1b12e5c
Top twenty view shows total number of artist followers(favorites) and…
abrown152 May 30, 2016
ddfbedb
Added all required album info to the top 20 view.
abrown152 Jun 1, 2016
ffef0e3
Added all required artist info to the top 20 view. Unable to pull the…
abrown152 Jun 1, 2016
034c40e
Added all required track info to the top 20 view. No image URL for tr…
abrown152 Jun 1, 2016
f43c5bc
Attempted to move the Spotify info gathering from the top 20 view pag…
abrown152 Jun 2, 2016
02c9208
Added required Yelp business info to view.
abrown152 Jun 3, 2016
0030548
Push to Charles.
abrown152 Jun 3, 2016
8db8396
As a user, I can search pairings.
abrown152 Jun 3, 2016
c3381d3
Refactored view.
abrown152 Jun 3, 2016
80c13c5
Created favorites routes, methods, and view.
abrown152 Jun 3, 2016
1ddca0d
Fixed nav and heading links.
abrown152 Jun 3, 2016
bac4293
Got the favorite method working.
abrown152 Jun 4, 2016
2864e2f
User can now favorite a suggestion.
abrown152 Jun 4, 2016
380517c
Refactor.
abrown152 Jun 4, 2016
70835c5
Removed option to favorite a pair from the guest view.
abrown152 Jun 5, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Ignore bundler config.
/.bundle

/.env

# Ignore all logfiles and tempfiles.
/log/*
!/log/.keep
Expand Down
22 changes: 17 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ruby '2.3.1'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.6'
gem 'omniauth-oauth2', '1.3.1' #reverted back to an older version to resolve route issue
# Use postgresql as the database for Active Record
gem 'pg', '~> 0.15'
# Use SCSS for stylesheets
Expand All @@ -20,10 +21,13 @@ gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Spotify API wrapper
gem 'rspotify'
# Yelp API wrapper
gem 'yelp', require: 'yelp'
gem 'omniauth'
gem 'omniauth-spotify'
gem 'httparty'
# Use Unicorn as the app server
# gem 'unicorn'

Expand All @@ -33,13 +37,21 @@ gem 'sdoc', '~> 0.4.0', group: :doc
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
gem 'minitest-vcr'
gem 'minitest-reporters'
gem 'pry-rails'
gem 'webmock'
gem 'dotenv-rails'
gem 'minitest-rails'

end

group :development do
gem "better_errors"

# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'

# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

99 changes: 97 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,18 @@ GEM
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.4.0)
ansi (1.5.0)
arel (6.0.3)
better_errors (2.1.1)
coderay (>= 1.0.0)
erubis (>= 2.6.6)
rack (>= 0.9.0)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (8.2.5)
coderay (1.1.1)
coffee-rails (4.1.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.1.x)
Expand All @@ -49,11 +56,26 @@ GEM
execjs
coffee-script-source (1.10.0)
concurrent-ruby (1.0.2)
crack (0.4.3)
safe_yaml (~> 1.0.0)
debug_inspector (0.0.2)
dotenv (2.1.1)
dotenv-rails (2.1.1)
dotenv (= 2.1.1)
railties (>= 4.0, < 5.1)
erubis (2.7.0)
execjs (2.6.0)
faraday (0.9.2)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.10.0)
faraday (>= 0.7.4, < 0.10)
globalid (0.3.6)
activesupport (>= 4.1.0)
hashdiff (0.3.0)
hashie (3.4.4)
httparty (0.13.7)
json (~> 1.8)
multi_xml (>= 0.5.2)
i18n (0.7.0)
jbuilder (2.4.1)
activesupport (>= 3.0.0, < 5.1)
Expand All @@ -63,19 +85,58 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
jwt (1.5.1)
loofah (2.0.3)
nokogiri (>= 1.5.9)
mail (2.6.4)
mime-types (>= 1.16, < 4)
method_source (0.8.2)
mime-types (3.0)
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0221)
mini_portile2 (2.0.0)
minispec-metadata (2.0.0)
minitest
minitest (5.8.4)
multi_json (1.12.0)
minitest-rails (2.2.1)
minitest (~> 5.7)
railties (~> 4.1)
minitest-reporters (1.1.9)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
minitest-vcr (1.4.0)
minispec-metadata (~> 2.0)
minitest (>= 4.7.5)
vcr (>= 2.9)
multi_json (1.12.1)
multi_xml (0.5.5)
multipart-post (2.0.0)
netrc (0.7.9)
nokogiri (1.6.7.2)
mini_portile2 (~> 2.0.0.rc2)
oauth2 (1.1.0)
faraday (>= 0.8, < 0.10)
jwt (~> 1.0, < 1.5.2)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
omniauth (1.3.1)
hashie (>= 1.2, < 4)
rack (>= 1.0, < 3)
omniauth-oauth2 (1.3.1)
oauth2 (~> 1.0)
omniauth (~> 1.2)
omniauth-spotify (0.0.9)
omniauth-oauth2 (~> 1.1)
pg (0.18.4)
pry (0.10.3)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
Expand Down Expand Up @@ -106,6 +167,13 @@ GEM
rake (11.1.2)
rdoc (4.2.2)
json (~> 1.4)
rest_client (1.8.3)
netrc (~> 0.7.7)
rspotify (1.10.0)
omniauth-oauth2 (~> 1.1)
rest_client (~> 1.8)
ruby-progressbar (1.8.1)
safe_yaml (1.0.4)
sass (3.4.22)
sass-rails (5.0.4)
railties (>= 4.0.0, < 5.0)
Expand All @@ -116,6 +184,8 @@ GEM
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
simple_oauth (0.3.1)
slop (3.6.0)
spring (1.7.1)
sprockets (3.6.0)
concurrent-ruby (~> 1.0)
Expand All @@ -131,27 +201,52 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.0)
execjs (>= 0.3.0, < 3)
vcr (3.0.1)
web-console (2.3.0)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
webmock (2.0.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
hashdiff
yelp (2.1.2)
faraday (~> 0.8, >= 0.8.0)
faraday_middleware (~> 0.8, >= 0.8.0)
simple_oauth (~> 0.3.1)

PLATFORMS
ruby

DEPENDENCIES
better_errors
byebug
coffee-rails (~> 4.1.0)
dotenv-rails
httparty
jbuilder (~> 2.0)
jquery-rails
minitest-rails
minitest-reporters
minitest-vcr
omniauth
omniauth-oauth2 (= 1.3.1)
omniauth-spotify
pg (~> 0.15)
pry-rails
rails (= 4.2.6)
rspotify
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
spring
uglifier (>= 1.3.0)
web-console (~> 2.0)
webmock
yelp

RUBY VERSION
ruby 2.3.1p112

BUNDLED WITH
1.12.3
1.12.4
3 changes: 3 additions & 0 deletions app/assets/javascripts/sessions.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/javascripts/suggestions.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/sessions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/suggestions.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the Suggestions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
11 changes: 11 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
helper_method :current_user

def current_user
@current_user ||= User.find_by(id: session[:user_id])
end

def current_user_name
@current_user ||= User.find_by(id: session[:user_id])
@current_user.name
end

end
23 changes: 23 additions & 0 deletions app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class SessionsController < ApplicationController

def create
auth_hash = request.env['omniauth.auth']
if auth_hash["uid"]
@user = User.find_or_create_from_omniauth(auth_hash)
if @user
session[:user_id] = @user.id
redirect_to root_path
else
redirect_to root_path, notice: "Failed to save the user"
end
else
redirect_to root_path, notice: "Failed to authenticate"
end
end

def destroy
session.delete :user_id
redirect_to root_path
end

end
28 changes: 28 additions & 0 deletions app/controllers/suggestions_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class SuggestionsController < ApplicationController

def index
results = TunesTakeoutWrapper.top_twenty
@results = results["suggestions"]
end

def search
@search_results = TunesTakeoutWrapper.search(params[:q])["suggestions"]
end

def show

end

def favorites
@favorites = TunesTakeoutWrapper.favorites
# shows all suggestions favorited by the signed-in User
end

def unfavorite
end

def favorite
TunesTakeoutWrapper.favorite(params[:id])
end

end
2 changes: 2 additions & 0 deletions app/helpers/sessions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SessionsHelper
end
2 changes: 2 additions & 0 deletions app/helpers/suggestions_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module SuggestionsHelper
end
2 changes: 2 additions & 0 deletions app/models/food.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Food < ActiveRecord::Base
end
2 changes: 2 additions & 0 deletions app/models/music.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class Music < ActiveRecord::Base
end
40 changes: 40 additions & 0 deletions app/models/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
class User < ActiveRecord::Base
validates :email, :name, :uid, :provider, presence: true

def initialize
@favorites = []
end

def self.find_or_create_from_omniauth(auth_hash)
# Find or create a user
user = self.find_by(uid: auth_hash["uid"], provider: auth_hash["provider"])
if user
return user
else
user = User.new
user.uid = auth_hash["uid"]
user.provider = auth_hash["provider"]
user.name = auth_hash["info"]["name"]
user.email = auth_hash["info"]["email"]

if user.save
return user
else
return nil
end
end
end

def add_favorite(pair_id)
@favorites << pair_id
end

def unfavorite(id)
@favorites.each do |pair|
if pair["id"] == id
# remove the pair ID from the array here
end
end
end

end
Loading