1
0
Fork 0

Minor fixes

This commit is contained in:
magnolia-fan 2011-12-01 10:09:18 +04:00
parent f76dea062c
commit bc98085090
8 changed files with 50 additions and 26 deletions

View File

@ -8,7 +8,7 @@ GIT
PATH PATH
remote: vendor/plugins/gems/musicbrainz remote: vendor/plugins/gems/musicbrainz
specs: specs:
musicbrainz (0.5.2) musicbrainz (0.5.4)
nokogiri nokogiri
GEM GEM
@ -45,7 +45,7 @@ GEM
multi_json (~> 1.0) multi_json (~> 1.0)
addressable (2.2.6) addressable (2.2.6)
arel (2.2.1) arel (2.2.1)
awesome_print (0.4.0) awesome_print (1.0.1)
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
bitmask_attributes (0.2.4) bitmask_attributes (0.2.4)
activerecord (~> 3.0) activerecord (~> 3.0)
@ -67,7 +67,7 @@ GEM
erubis (2.7.0) erubis (2.7.0)
execjs (1.2.9) execjs (1.2.9)
multi_json (~> 1.0) multi_json (~> 1.0)
haml (3.1.3) haml (3.1.4)
heroku (2.14.0) heroku (2.14.0)
launchy (>= 0.3.2) launchy (>= 0.3.2)
rest-client (~> 1.6.1) rest-client (~> 1.6.1)
@ -80,7 +80,7 @@ GEM
jquery-rails (1.0.19) jquery-rails (1.0.19)
railties (~> 3.0) railties (~> 3.0)
thor (~> 0.14) thor (~> 0.14)
json (1.6.1) json (1.6.2)
kgio (2.6.0) kgio (2.6.0)
launchy (2.0.5) launchy (2.0.5)
addressable (~> 2.2.6) addressable (~> 2.2.6)
@ -90,7 +90,7 @@ GEM
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
mime-types (1.17.2) mime-types (1.17.2)
multi_json (1.0.3) multi_json (1.0.4)
mysql2 (0.3.7) mysql2 (0.3.7)
nokogiri (1.5.0) nokogiri (1.5.0)
pg (0.11.0) pg (0.11.0)
@ -126,7 +126,7 @@ GEM
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
rubyzip (0.9.5) rubyzip (0.9.5)
sass (3.1.10) sass (3.1.11)
sass-rails (3.1.5) sass-rails (3.1.5)
actionpack (~> 3.1.0) actionpack (~> 3.1.0)
railties (~> 3.1.0) railties (~> 3.1.0)

View File

@ -55,10 +55,11 @@ class window.Player
if not autoplay? if not autoplay?
autoplay = false autoplay = false
initial_count = $('.playlist li').length initial_count = $('.playlist li').length
$('.playlist').append this.generateTrackHtml track c = this.generateTrackHtml track
$('.playlist').append c.html
$('.playlist').sortable "refresh" $('.playlist').sortable "refresh"
if initial_count == 0 and not _player.hasTrack() unless _player.currentTrack()?
_player.setTrack($('.playlist li').first().attr('id').split('i')[1]) _player.setTrack(c.uid)
false false
generateTrackHtml: (track) -> generateTrackHtml: (track) ->
@ -67,12 +68,16 @@ class window.Player
s = len - Math.floor(len / 60) * 60 s = len - Math.floor(len / 60) * 60
duration = m + ':' + (if s < 10 then '0' else '') + s duration = m + ':' + (if s < 10 then '0' else '') + s
item_class = (if track.available == false then 'unavailable' else '') item_class = (if track.available == false then 'unavailable' else '')
"<li id='i#{Math.round(Math.random() * 999999)}' data-id='#{track.id}' class='#{item_class}'> uid = Math.round(Math.random() * 999999)
<div class='song-duration'>#{duration}</div> {
<div class='label important remove'>remove</div> html: "<li id='i#{uid}' data-id='#{track.id}' class='#{item_class}'>
<div class='artist-name'><a class='data artist'>#{track.artist}</a></div> <div class='song-duration'>#{duration}</div>
<div class='song-title'>#{track.name}</div> <div class='label important remove'>remove</div>
</li>" <div class='artist-name'><a class='data artist'>#{track.artist}</a></div>
<div class='song-title'>#{track.name}</div>
</li>"
uid: uid
}
getDataFromLi: (obj) -> getDataFromLi: (obj) ->
id = $(obj).attr 'data-id' id = $(obj).attr 'data-id'
@ -91,13 +96,18 @@ class window.Player
$obj.addClass 'now' $obj.addClass 'now'
_vk_music.search track.artist, track.name, track.length, (audio) -> _vk_music.search track.artist, track.name, track.length, (audio) ->
if audio is null if audio is null
_session.query '/track/report', { id: track.id }, (r) -> _session.query '/track/report_available', { id: track.id, available: false }, (r) ->
if r.result is 'success' if r.result is 'success' or r.status is 'success'
$(".playlist li[data-id='#{track.id}']").addClass("unavailable") $(".playlist li[data-id='#{track.id}']").addClass("unavailable")
$($(".album div[data-id='#{track.id}']").siblings()[0]).addClass("unavailable") $(".s-add[data-id='#{track.id}']").parent().parent().addClass("unavailable")
_player.setTrack _player.nextTrack() _player.setTrack _player.nextTrack()
else else
_player.playSource audio.url _player.playSource audio.url
if track.available == false
_session.query '/track/report_available', { id: track.id, available: true }, (r) ->
if r.result is 'success' or r.status is 'success'
$(".playlist li[data-id='#{track.id}']").removeClass("unavailable")
$(".s-add[data-id='#{track.id}']").parent().parent().removeClass("unavailable")
if track.length == 0 if track.length == 0
len = parseInt(audio.duration, 10) len = parseInt(audio.duration, 10)
m = Math.floor(len / 60) m = Math.floor(len / 60)
@ -128,6 +138,11 @@ class window.Player
true true
false false
currentTrack: ->
current_track = $('.playlist li.now')
false unless current_track?
@library[$(current_track).data('id')]
playSource: (url) -> playSource: (url) ->
@scrobbled = false @scrobbled = false
$('#jplayer').jPlayer 'setMedia', mp3: url $('#jplayer').jPlayer 'setMedia', mp3: url
@ -253,7 +268,8 @@ $ ->
cursor: 'move' cursor: 'move'
stop: (e, ui) -> stop: (e, ui) ->
if $(ui.item).prop("tagName") == "TR" if $(ui.item).prop("tagName") == "TR"
ui.item.replaceWith(_player.generateTrackHtml(_player.library[$(ui.item).find('.s-add').data('id')])) c = _player.generateTrackHtml(_player.library[$(ui.item).find('.s-add').data('id')])
ui.item.replaceWith(c.html)
false false
$('.playlist').droppable $('.playlist').droppable
accept: '.track' accept: '.track'

View File

@ -80,7 +80,7 @@
.playlist { .playlist {
margin: 20px 0 0 0; margin: 20px 0 0 0;
min-height: 300px; padding-bottom: 200px;
li { li {
list-style: none; list-style: none;
background-color: #ffffff; background-color: #ffffff;

View File

@ -15,10 +15,11 @@ class TrackController < ApplicationController
render :json => { :result => :failed } render :json => { :result => :failed }
end end
def report_unavailable def report_available
track = Track.find(params[:id]) track = Track.find(params[:id])
unless track.nil? or track.available available = params[:available] == "false" ? false : true
track.available = false unless track.nil?
track.available = available
track.save track.save
return render :json => { :status => :success } return render :json => { :status => :success }
end end

View File

@ -14,7 +14,7 @@ Beathaven::Application.routes.draw do
match 'lastfm/scrobble' => 'last_fm#scrobble' match 'lastfm/scrobble' => 'last_fm#scrobble'
match 'track/update_length' => 'track#update_length' match 'track/update_length' => 'track#update_length'
match 'track/report' => 'track#report_unavailable' match 'track/report_available' => 'track#report_available'
match 'playlist/(:id)' => 'playlist#data' match 'playlist/(:id)' => 'playlist#data'
match 'playlist/lastfm-top50/(:artist)' => 'playlist#lastfm_top50', constraints: { artist: /.*/ } match 'playlist/lastfm-top50/(:artist)' => 'playlist#lastfm_top50', constraints: { artist: /.*/ }

View File

@ -1 +1 @@
0.5.2 0.5.4

View File

@ -59,6 +59,13 @@ module MusicBrainz
:type => self.safe_get_attr(a, nil, 'type'), :type => self.safe_get_attr(a, nil, 'type'),
:mbid => self.safe_get_attr(a, nil, 'id') :mbid => self.safe_get_attr(a, nil, 'id')
} }
if artist[:type] == "Group"
m = artist[:sort_name].match(/(.*?),\sThe$/)
artist[:name] = artist[:sort_name] = "The #{m[1]}" if m
elsif artist[:type] == "Person"
m = artist[:sort_name].match(/(.+?),\s([^,]+?)$/)
artist[:name] = artist[:sort_name] = "#{m[2]} #{m[1]}" if m
end
aliases = a.css('alias-list > alias').map{ |item| item.text } aliases = a.css('alias-list > alias').map{ |item| item.text }
if aliases.include? name if aliases.include? name
artist[:weight] += 20 artist[:weight] += 20

View File

@ -5,7 +5,7 @@
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = %q{musicbrainz} s.name = %q{musicbrainz}
s.version = "0.5.2" s.version = "0.5.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Gregory Eremin"] s.authors = ["Gregory Eremin"]