Haml templates, artist page renderer
This commit is contained in:
@@ -8,7 +8,7 @@ class ArtistController < ApplicationController
|
||||
render :json => {status: 'loading_failed', pics: []}
|
||||
return
|
||||
end
|
||||
name = params[:name].gsub('%20', ' ').gsub('+', ' ')
|
||||
name = params[:name].gsub('%20', ' ').gsub('+', ' ').gsub('.html', '')
|
||||
artist = Artist.find_by_name(name)
|
||||
if artist and artist.status == 0
|
||||
pics = []
|
||||
@@ -46,8 +46,8 @@ class ArtistController < ApplicationController
|
||||
return
|
||||
end
|
||||
end
|
||||
data['artist'] = {id: artist.id, name: artist.name, desc: ActionController::Base.helpers.strip_tags(artist.desc), pic: artist.pic_url}
|
||||
data['albums'] = []
|
||||
data[:artist] = {id: artist.id, name: artist.name, desc: ActionController::Base.helpers.strip_tags(artist.desc), pic: artist.pic_url}
|
||||
data[:albums] = []
|
||||
albums = artist.albums
|
||||
albums.each do |album|
|
||||
if @@default_album_types.include? album.album_type
|
||||
@@ -60,17 +60,21 @@ class ArtistController < ApplicationController
|
||||
time = (track.length / 1000).round
|
||||
time_m = (time / 60).floor
|
||||
time_s = time - time_m * 60
|
||||
tmp_track['duration'] = time_m.to_s + ':' + (time_s < 10 ? '0' : '') + time_s.to_s
|
||||
tmp_track[:duration] = time_m.to_s + ':' + (time_s < 10 ? '0' : '') + time_s.to_s
|
||||
else
|
||||
tmp_track['duration'] = '0:00'
|
||||
tmp_track[:duration] = '0:00'
|
||||
end
|
||||
(track.bonus == 0 ? album_tracks : bonus_tracks) << tmp_track
|
||||
end
|
||||
tmp_album['tracks'] = {album: album_tracks, bonus: bonus_tracks}
|
||||
data['albums'] << tmp_album
|
||||
tmp_album[:tracks] = {album: album_tracks, bonus: bonus_tracks}
|
||||
data[:albums] << tmp_album
|
||||
end
|
||||
end
|
||||
render :json => data
|
||||
@data = data
|
||||
respond_to do |format|
|
||||
format.html { render :partial => 'data' }
|
||||
format.json { render :json => @data }
|
||||
end
|
||||
end
|
||||
|
||||
def autocomplete
|
||||
|
||||
Reference in New Issue
Block a user