2014-02-06 16:31:52 +00:00
|
|
|
module RecordingHelper
|
|
|
|
|
|
|
|
|
|
def facebook_image_for_claimed_recording(claimed_recording)
|
|
|
|
|
if claimed_recording.recording.band
|
|
|
|
|
path = !claimed_recording.recording.band.large_photo_url.blank? ? claimed_recording.recording.band.large_photo_url : "/assets/web/logo-256.png"
|
|
|
|
|
else
|
|
|
|
|
path = "/assets/web/logo-256.png"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
request.protocol + request.host_with_port + path
|
|
|
|
|
end
|
|
|
|
|
|
2014-05-06 13:34:38 +00:00
|
|
|
# careful; this mirrors logic of facebook_image_for_music_session
|
2014-02-06 16:31:52 +00:00
|
|
|
def facebook_image_size_for_claimed_recording(claimed_recording)
|
|
|
|
|
if claimed_recording.recording.band
|
|
|
|
|
!claimed_recording.recording.band.large_photo_url.blank? ? 200 : 256
|
|
|
|
|
else
|
|
|
|
|
256
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-02-07 14:07:08 +00:00
|
|
|
def title_for_claimed_recording(claimed_recording, sharer = nil)
|
2014-02-06 16:31:52 +00:00
|
|
|
if claimed_recording.recording.band
|
|
|
|
|
"RECORDING: #{claimed_recording.recording.band.name}"
|
|
|
|
|
else
|
2014-11-09 15:50:28 +00:00
|
|
|
unique_users = claimed_recording.recording.users.uniq
|
2014-11-09 16:52:25 +00:00
|
|
|
if sharer && unique_users.include?(sharer)
|
2014-11-09 15:50:28 +00:00
|
|
|
"RECORDING: #{sharer.name}#{additional_member_count(unique_users, sharer)}"
|
2014-02-06 16:31:52 +00:00
|
|
|
else
|
2014-11-09 15:50:28 +00:00
|
|
|
"RECORDING: #{claimed_recording.user.name}#{additional_member_count(unique_users, claimed_recording.user)}"
|
2014-02-06 16:31:52 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-11-09 15:50:28 +00:00
|
|
|
def additional_member_count(unique_users, target_user)
|
2014-02-06 16:31:52 +00:00
|
|
|
length = unique_users.length
|
|
|
|
|
if length < 2
|
|
|
|
|
""
|
|
|
|
|
else
|
2014-11-09 15:50:28 +00:00
|
|
|
other_length = length - 1
|
|
|
|
|
if other_length == 1
|
|
|
|
|
other_user_in_array = unique_users - [target_user]
|
|
|
|
|
other_user = other_user_in_array[0]
|
|
|
|
|
" & #{other_user.name}"
|
|
|
|
|
else
|
|
|
|
|
" & #{length - 1} OTHERS"
|
|
|
|
|
end
|
2014-02-06 16:31:52 +00:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2015-04-15 20:16:05 +00:00
|
|
|
def description_for_claimed_recording(claimed_recording, length = 250)
|
|
|
|
|
truncate(claimed_recording.name, length:length)
|
2014-02-06 16:31:52 +00:00
|
|
|
end
|
2014-10-23 04:10:49 +00:00
|
|
|
|
|
|
|
|
def listen_mix_url(recording)
|
|
|
|
|
{
|
|
|
|
|
mp3_url: claimed_recording_download_url(recording.candidate_claimed_recording.id, 'mp3'),
|
|
|
|
|
ogg_url: claimed_recording_download_url(recording.candidate_claimed_recording.id, 'ogg')
|
|
|
|
|
}
|
|
|
|
|
end
|
2014-02-06 16:31:52 +00:00
|
|
|
end
|