Top 50 playlists, last.fm and youtube links
This commit is contained in:
parent
705b4cfbc2
commit
4ade7fa77f
|
@ -63,7 +63,7 @@ GEM
|
||||||
haml (3.1.3)
|
haml (3.1.3)
|
||||||
hike (1.2.1)
|
hike (1.2.1)
|
||||||
i18n (0.6.0)
|
i18n (0.6.0)
|
||||||
jquery-rails (1.0.18)
|
jquery-rails (1.0.19)
|
||||||
railties (~> 3.0)
|
railties (~> 3.0)
|
||||||
thor (~> 0.14)
|
thor (~> 0.14)
|
||||||
json (1.6.1)
|
json (1.6.1)
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
|
@ -32,7 +32,7 @@ class ArtistController < ApplicationController
|
||||||
return render json: { status: 'fail', html: render_compact_partial(:fail) }
|
return render json: { status: 'fail', html: render_compact_partial(:fail) }
|
||||||
end
|
end
|
||||||
|
|
||||||
response.headers['Cache-Control'] = 'public, max-age='+1.week.seconds.to_s
|
# response.headers['Cache-Control'] = 'public, max-age='+1.week.seconds.to_s
|
||||||
render json: {
|
render json: {
|
||||||
status: @artist.status_str,
|
status: @artist.status_str,
|
||||||
artist: @artist,
|
artist: @artist,
|
||||||
|
|
|
@ -79,6 +79,14 @@ class LastFmController < ApplicationController
|
||||||
render :json => { :status => r['error'].nil? ? 'success' : r }
|
render :json => { :status => r['error'].nil? ? 'success' : r }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.top_playlist artist
|
||||||
|
playlist = Playlist.create(name: "#{artist.name}: Last.fm TOP")
|
||||||
|
LastFM::Artist.get_top_tracks(artist: artist.name)["toptracks"]["track"].each do |track|
|
||||||
|
tracks = Track.joins(:album, :artists).where(name: track["name"], "track_artists.artist_id" => artist.id)
|
||||||
|
PlaylistItem.create(playlist_id: playlist.id, track_id: tracks.first.id) unless tracks.empty?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def autocomplete
|
def autocomplete
|
||||||
autocomplete = getSuggestions(params[:query])
|
autocomplete = getSuggestions(params[:query])
|
||||||
return render :nothing => true if autocomplete.nil?
|
return render :nothing => true if autocomplete.nil?
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Playlist < ActiveRecord::Base
|
class Playlist < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
has_many :playlist_tracks
|
has_many :playlist_items
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,14 +8,23 @@
|
||||||
%h2
|
%h2
|
||||||
=@artist.name
|
=@artist.name
|
||||||
%small= " "+@artist.original_name.to_s
|
%small= " "+@artist.original_name.to_s
|
||||||
= @artist.desc.html_safe unless @artist.desc.nil?
|
%p= @artist.desc.html_safe unless @artist.desc.nil?
|
||||||
- unless @artist.artist_links.empty?
|
- unless @artist.artist_links.empty?
|
||||||
.service-icons
|
.service-icons
|
||||||
|
%a.foreign-link{ :href => "http://last.fm/artist/#{@artist.name.gsub(" ", "+")}", :target => '_blank' }
|
||||||
|
= image_tag 'services/lastfm.ico'
|
||||||
- @artist.artist_links.each do |service|
|
- @artist.artist_links.each do |service|
|
||||||
- if ['wikipedia', 'microblog', 'official_homepage', 'social_network'].include?service.service
|
- if ['wikipedia', 'microblog', 'official_homepage', 'social_network', 'youtube'].include?(service.service)
|
||||||
%a.foreign-link{ :href => service.url, :target => '_blank' }
|
%a.foreign-link{ :href => service.url, :target => '_blank' }
|
||||||
= image_tag 'services/'+service.service+(service.service == 'official_homepage' ? '.png' : '.ico')
|
= image_tag 'services/'+service.service+(service.service == 'official_homepage' ? '.png' : '.ico')
|
||||||
|
|
||||||
|
.row
|
||||||
|
.span7.offset4
|
||||||
|
%h3 Playlists
|
||||||
|
%table.zebra-striped
|
||||||
|
%tr
|
||||||
|
%td
|
||||||
|
%a{ href: "" } Last.fm TOP
|
||||||
|
|
||||||
- @artist.albums.each do |album|
|
- @artist.albums.each do |album|
|
||||||
.row.album
|
.row.album
|
||||||
|
@ -33,4 +42,4 @@
|
||||||
%td.song-title= track.name
|
%td.song-title= track.name
|
||||||
%td.song-duration
|
%td.song-duration
|
||||||
.s-duration= (track.duration != '0:00' ? track.duration : ' '.html_safe)
|
.s-duration= (track.duration != '0:00' ? track.duration : ' '.html_safe)
|
||||||
.s-add{ :'data-album-id' => album.id, :'data-id' => track.id }= I18n.t 'player.add_one'
|
%span.label.success.s-add{ :'data-album-id' => album.id, :'data-id' => track.id }= I18n.t 'player.add_one'
|
||||||
|
|
Loading…
Reference in New Issue