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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
As a user, I can search pairings.
abrown152 committed Jun 3, 2016
commit 8db83963eb1d38f52a9afe3d2361bb6f0728d79a
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -47,6 +47,8 @@ group :development, :test do
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'

5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -39,6 +39,10 @@ GEM
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)
@@ -216,6 +220,7 @@ PLATFORMS
ruby

DEPENDENCIES
better_errors
byebug
coffee-rails (~> 4.1.0)
dotenv-rails
32 changes: 3 additions & 29 deletions app/controllers/suggestions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,11 @@
class SuggestionsController < ApplicationController


# def show
# @results = TunesTakeoutWrapper.search(params[:keyword])
# end

def index
results = TunesTakeoutWrapper.top_twenty
@results = results["suggestions"]
# results["suggestions"].map do |suggestion_id|
# suggestion = TunesTakeoutWrapper.suggestion_info(suggestion_id)["suggestion"]
# logger.info suggestion
#
# {
# music: get_music(suggestion),
# # food: get_food(suggestion),
# }
# end
end

# def get_music(suggestion, music_type)
# case suggestion["music_type"]
# when "artist"
# RSpotify::Artist.find(suggestion["music_id"])
# when "track"
# RSpotify::Track.find(suggestion["music_id"])
# when "album"
# RSpotify::Album.find(suggestion["music_id"])
# end
# end

# def get_food(suggestion)
# "food"
# end

def search
@search_results = TunesTakeoutWrapper.search(params[:q])["suggestions"]
end
end
9 changes: 3 additions & 6 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
@@ -14,14 +14,11 @@

<% if current_user %>
<nav>
<%= RSpotify::User.find(current_user.name).id %>
<%= RSpotify::User.find(current_user.name).external_urls["spotify"] %>
<%= link_to href: 'https://www.spotify.com/us/' do %>
<%= image_tag 'https://cdn2.iconfinder.com/data/icons/windows-8-metro-style/512/guest.png', width: 60, height: 60, alt: 'Spotify Icon'%>
<% end %>
<%= RSpotify::User.find(current_user.name).id %><br>
<%= RSpotify::User.find(current_user.name).external_urls["spotify"] %><br>
<%= link_to "Log Out", "/logout" %>
</nav>
<%= form_tag top_twenty_results_path do %>
<%= form_tag search_path do %>
<%= label_tag(:q, "Search for:") %>
<%= text_field_tag(:q) %>
<%= submit_tag("Search") %>
Empty file.
40 changes: 40 additions & 0 deletions app/views/suggestions/search.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<h1>Results</h1>

<% @search_results.each do |pair| %>
<p>
<% business = Yelp.client.business(pair["food_id"]).business %>
<%= business.name %>
<%= business.id %>
<%= business.image_url %>
<%= business.rating %>
<%= business.url %>

<% if pair["music_type"] == "album" %>
<% album = RSpotify::Album.find(pair["music_id"]) %>
<%= album.name %><br>
<%= album.uri %><br>
<%= album.images[0]["url"] %><br>
<%= album.album_type %><br>
<%= album.external_urls['spotify'] %>
<br><br><br>

<% elsif pair["music_type"] == "artist" %>
<% artist = RSpotify::Artist.find(pair["music_id"]) %>
<%= artist.name %><br>
<%= artist.uri %><br>
<%= artist.images[0] %><br>
<%= artist.type %><br>
<%= artist.external_urls['spotify'] %><br><br><br>

<% elsif pair["music_type"] == "track" %>
<% track = RSpotify::Track.find(pair["music_id"]) %>
<%= track.name %><br>
<%= track.uri %><br>
<%= track.type %><br>
<%= track.external_urls['spotify'] %><br><br><br>

<% else %>
<%= "Invalid music type." %>
<% end %>
</p>
<% end %>
5 changes: 4 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -10,7 +10,10 @@
get '/auth/spotify/callback', :to => 'sessions#create'
get '/logout', :to => 'sessions#destroy'
resources :food, :music
# Confirm these are the correct resources. What is this line even doing???????

get '/top_twenty', :to => 'suggestions#index'
post '/top_twenty/show', :to => 'suggestions#show', as: 'top_twenty_results'
# Confirm these are the correct resources. What is this line even doing???????

post '/v1/suggestions/search', :to => 'suggestions#search', as: 'search'
end
3 changes: 1 addition & 2 deletions lib/TunesTakeoutWrapper.rb
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@ def self.top_twenty
end

def self.suggestion_info(id)
HTTParty.get(BASE_URL + "/v1/suggestions/" + id).parsed_response
# SpotifyWrapper.top_twenty
HTTParty.get(BASE_URL + "/v1/suggestions/" + id["id"]).parsed_response
end
end