From c138c1a74b6f300c0c6163ab8d73ec96f93dbcc5 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Mon, 26 Sep 2011 09:22:18 +0400 Subject: [PATCH] Player functionality restored --- app/assets/javascripts/player.coffee | 9 ++------- app/controllers/artist_controller.rb | 11 +++++------ app/models/music/artist.rb | 2 +- app/views/artist/_page.html.haml | 8 ++------ 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/app/assets/javascripts/player.coffee b/app/assets/javascripts/player.coffee index 0d42ada..1028749 100644 --- a/app/assets/javascripts/player.coffee +++ b/app/assets/javascripts/player.coffee @@ -88,7 +88,6 @@ class window.Player false getTrackInfo: (id) -> - console.log(id) for track in _player.playlist if parseInt(track.id, 10) == parseInt(id, 10) return track @@ -226,12 +225,8 @@ $('.playlist li').live 'click', -> $('.add-album').live 'click', -> artist = $('.artist-info h2').text() album = _player.albums[$(this).attr('data-album-id')] - for item in album.tracks.album + for item in album.tracks item['artist'] = artist item['album'] = album.name - _player.addTracks album.tracks.album - for item in album.tracks.bonus - item['artist'] = artist - item['album'] = album.name - _player.addTracks album.tracks.bonus + _player.addTracks album.tracks false diff --git a/app/controllers/artist_controller.rb b/app/controllers/artist_controller.rb index 12fc340..c524a2d 100644 --- a/app/controllers/artist_controller.rb +++ b/app/controllers/artist_controller.rb @@ -90,19 +90,18 @@ class ArtistController < ApplicationController @artist[:albums] = [] artist.albums.each do |album| if true # media_types.include? album.album_type.downcase.to_sym and album.status == 1 - tmp_album = {id: album.id, name: album.name, year: album.year, pic: album.pic_url} - album_tracks = [] - bonus_tracks = [] + tmp_album = {:id => album.id, :name => album.name, :year => album.year, :pic => album.pic_url, :tracks => []} album.tracks.each do |track| tmp_track = {id: track.id, name: track.name, live: track.live, acoustic: track.acoustic} tmp_track[:length] = (track.length / 1000).round unless track.length.nil? tmp_track[:duration] = formatTrackDuration(track.length) tmp_track[:position] = track.position.to_s 36 # tmp_track[:mbid] = track.mbid - (track.bonus == 0 ? album_tracks : bonus_tracks) << tmp_track + # (track.bonus == 0 ? album_tracks : bonus_tracks) << tmp_track + tmp_album[:tracks] << tmp_track end - tmp_album[:tracks] = {album: album_tracks, bonus: bonus_tracks} - @artist[:albums] << tmp_album if (album_tracks+bonus_tracks).length > 0 + # tmp_album[:tracks] = {album: album_tracks, bonus: bonus_tracks} + @artist[:albums] << tmp_album unless tmp_album[:tracks].empty? end end diff --git a/app/models/music/artist.rb b/app/models/music/artist.rb index d1eaddb..7365c24 100644 --- a/app/models/music/artist.rb +++ b/app/models/music/artist.rb @@ -1,5 +1,5 @@ class Artist < ActiveRecord::Base - has_many :albums, :order => 'has_pic DESC, year ASC, id ASC', :dependent => :destroy + has_many :albums, :conditions => ['has_pic = 1'], :order => 'year ASC', :dependent => :destroy has_many :artist_links, :dependent => :destroy has_many :artist_aliases, :dependent => :destroy has_many :tracks, :through => :track_artists diff --git a/app/views/artist/_page.html.haml b/app/views/artist/_page.html.haml index 5f2ed71..5b727b1 100644 --- a/app/views/artist/_page.html.haml +++ b/app/views/artist/_page.html.haml @@ -18,11 +18,7 @@ .span7.columns.tracks %h3= album[:name] + " (" + album[:year].to_s + ")" %table.zebra-striped.tracklist - - album[:tracks][:album].each do |track| + - album[:tracks].each do |track| %tr %td.song-title= track[:name] - %td.song-duration= track[:duration] - - album[:tracks][:bonus].each do |track| - %tr - %td.song-title= track[:name] - %td.song-duration= track[:duration] + %td.song-duration= track[:duration] \ No newline at end of file