Minor fixes
This commit is contained in:
parent
f76dea062c
commit
bc98085090
12
Gemfile.lock
12
Gemfile.lock
|
@ -8,7 +8,7 @@ GIT
|
|||
PATH
|
||||
remote: vendor/plugins/gems/musicbrainz
|
||||
specs:
|
||||
musicbrainz (0.5.2)
|
||||
musicbrainz (0.5.4)
|
||||
nokogiri
|
||||
|
||||
GEM
|
||||
|
@ -45,7 +45,7 @@ GEM
|
|||
multi_json (~> 1.0)
|
||||
addressable (2.2.6)
|
||||
arel (2.2.1)
|
||||
awesome_print (0.4.0)
|
||||
awesome_print (1.0.1)
|
||||
bcrypt-ruby (3.0.1)
|
||||
bitmask_attributes (0.2.4)
|
||||
activerecord (~> 3.0)
|
||||
|
@ -67,7 +67,7 @@ GEM
|
|||
erubis (2.7.0)
|
||||
execjs (1.2.9)
|
||||
multi_json (~> 1.0)
|
||||
haml (3.1.3)
|
||||
haml (3.1.4)
|
||||
heroku (2.14.0)
|
||||
launchy (>= 0.3.2)
|
||||
rest-client (~> 1.6.1)
|
||||
|
@ -80,7 +80,7 @@ GEM
|
|||
jquery-rails (1.0.19)
|
||||
railties (~> 3.0)
|
||||
thor (~> 0.14)
|
||||
json (1.6.1)
|
||||
json (1.6.2)
|
||||
kgio (2.6.0)
|
||||
launchy (2.0.5)
|
||||
addressable (~> 2.2.6)
|
||||
|
@ -90,7 +90,7 @@ GEM
|
|||
mime-types (~> 1.16)
|
||||
treetop (~> 1.4.8)
|
||||
mime-types (1.17.2)
|
||||
multi_json (1.0.3)
|
||||
multi_json (1.0.4)
|
||||
mysql2 (0.3.7)
|
||||
nokogiri (1.5.0)
|
||||
pg (0.11.0)
|
||||
|
@ -126,7 +126,7 @@ GEM
|
|||
rest-client (1.6.7)
|
||||
mime-types (>= 1.16)
|
||||
rubyzip (0.9.5)
|
||||
sass (3.1.10)
|
||||
sass (3.1.11)
|
||||
sass-rails (3.1.5)
|
||||
actionpack (~> 3.1.0)
|
||||
railties (~> 3.1.0)
|
||||
|
|
|
@ -55,10 +55,11 @@ class window.Player
|
|||
if not autoplay?
|
||||
autoplay = false
|
||||
initial_count = $('.playlist li').length
|
||||
$('.playlist').append this.generateTrackHtml track
|
||||
c = this.generateTrackHtml track
|
||||
$('.playlist').append c.html
|
||||
$('.playlist').sortable "refresh"
|
||||
if initial_count == 0 and not _player.hasTrack()
|
||||
_player.setTrack($('.playlist li').first().attr('id').split('i')[1])
|
||||
unless _player.currentTrack()?
|
||||
_player.setTrack(c.uid)
|
||||
false
|
||||
|
||||
generateTrackHtml: (track) ->
|
||||
|
@ -67,12 +68,16 @@ class window.Player
|
|||
s = len - Math.floor(len / 60) * 60
|
||||
duration = m + ':' + (if s < 10 then '0' else '') + s
|
||||
item_class = (if track.available == false then 'unavailable' else '')
|
||||
"<li id='i#{Math.round(Math.random() * 999999)}' data-id='#{track.id}' class='#{item_class}'>
|
||||
<div class='song-duration'>#{duration}</div>
|
||||
<div class='label important remove'>remove</div>
|
||||
<div class='artist-name'><a class='data artist'>#{track.artist}</a></div>
|
||||
<div class='song-title'>#{track.name}</div>
|
||||
</li>"
|
||||
uid = Math.round(Math.random() * 999999)
|
||||
{
|
||||
html: "<li id='i#{uid}' data-id='#{track.id}' class='#{item_class}'>
|
||||
<div class='song-duration'>#{duration}</div>
|
||||
<div class='label important remove'>remove</div>
|
||||
<div class='artist-name'><a class='data artist'>#{track.artist}</a></div>
|
||||
<div class='song-title'>#{track.name}</div>
|
||||
</li>"
|
||||
uid: uid
|
||||
}
|
||||
|
||||
getDataFromLi: (obj) ->
|
||||
id = $(obj).attr 'data-id'
|
||||
|
@ -91,13 +96,18 @@ class window.Player
|
|||
$obj.addClass 'now'
|
||||
_vk_music.search track.artist, track.name, track.length, (audio) ->
|
||||
if audio is null
|
||||
_session.query '/track/report', { id: track.id }, (r) ->
|
||||
if r.result is 'success'
|
||||
_session.query '/track/report_available', { id: track.id, available: false }, (r) ->
|
||||
if r.result is 'success' or r.status is 'success'
|
||||
$(".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()
|
||||
else
|
||||
_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
|
||||
len = parseInt(audio.duration, 10)
|
||||
m = Math.floor(len / 60)
|
||||
|
@ -128,6 +138,11 @@ class window.Player
|
|||
true
|
||||
false
|
||||
|
||||
currentTrack: ->
|
||||
current_track = $('.playlist li.now')
|
||||
false unless current_track?
|
||||
@library[$(current_track).data('id')]
|
||||
|
||||
playSource: (url) ->
|
||||
@scrobbled = false
|
||||
$('#jplayer').jPlayer 'setMedia', mp3: url
|
||||
|
@ -253,7 +268,8 @@ $ ->
|
|||
cursor: 'move'
|
||||
stop: (e, ui) ->
|
||||
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
|
||||
$('.playlist').droppable
|
||||
accept: '.track'
|
||||
|
|
|
@ -80,7 +80,7 @@
|
|||
|
||||
.playlist {
|
||||
margin: 20px 0 0 0;
|
||||
min-height: 300px;
|
||||
padding-bottom: 200px;
|
||||
li {
|
||||
list-style: none;
|
||||
background-color: #ffffff;
|
||||
|
|
|
@ -15,10 +15,11 @@ class TrackController < ApplicationController
|
|||
render :json => { :result => :failed }
|
||||
end
|
||||
|
||||
def report_unavailable
|
||||
def report_available
|
||||
track = Track.find(params[:id])
|
||||
unless track.nil? or track.available
|
||||
track.available = false
|
||||
available = params[:available] == "false" ? false : true
|
||||
unless track.nil?
|
||||
track.available = available
|
||||
track.save
|
||||
return render :json => { :status => :success }
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ Beathaven::Application.routes.draw do
|
|||
match 'lastfm/scrobble' => 'last_fm#scrobble'
|
||||
|
||||
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/lastfm-top50/(:artist)' => 'playlist#lastfm_top50', constraints: { artist: /.*/ }
|
||||
|
|
|
@ -1 +1 @@
|
|||
0.5.2
|
||||
0.5.4
|
|
@ -59,6 +59,13 @@ module MusicBrainz
|
|||
:type => self.safe_get_attr(a, nil, 'type'),
|
||||
: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 }
|
||||
if aliases.include? name
|
||||
artist[:weight] += 20
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
Gem::Specification.new do |s|
|
||||
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.authors = ["Gregory Eremin"]
|
||||
|
|
Loading…
Reference in New Issue