This commit is contained in:
Seth Call 2014-04-29 14:04:26 +00:00
commit 00a6139cd1
971 changed files with 65166 additions and 12655 deletions

7
.gitignore vendored
View File

@ -1,5 +1,8 @@
.idea
*~
*.swp
web/screenshot*.html
web/screenshot*.png
*/vendor/bundle
*/vendor/cache
HTML
.DS_Store
coverage

46
admin/.simplecov Normal file
View File

@ -0,0 +1,46 @@
if ENV['COVERAGE'] == "1"
require 'simplecov-rcov'
class SimpleCov::Formatter::MergedFormatter
def format(result)
SimpleCov::Formatter::HTMLFormatter.new.format(result)
SimpleCov::Formatter::RcovFormatter.new.format(result)
end
end
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
SimpleCov.start do
add_filter "/test/"
add_filter "/bin/"
add_filter "/scripts/"
add_filter "/tmp/"
add_filter "/vendor/"
add_filter "/spec/"
end
all_files = Dir['**/*.rb']
base_result = {}
all_files.each do |file|
absolute = File::expand_path(file)
lines = File.readlines(absolute, :encoding => 'UTF-8')
base_result[absolute] = lines.map do |l|
l.encode!('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')
l.encode!('UTF-8', 'UTF-16')
l.strip!
l.empty? || l =~ /^end$/ || l[0] == '#' ? nil : 0
end
end
SimpleCov.at_exit do
coverage_result = Coverage.result
covered_files = coverage_result.keys
covered_files.each do |covered_file|
base_result.delete(covered_file)
end
merged = SimpleCov::Result.new(coverage_result).original_result.merge_resultset(base_result)
result = SimpleCov::Result.new(merged)
result.format!
end
end

View File

@ -1,4 +1,4 @@
source 'https://rubygems.org'
source 'http://rubygems.org'
source 'https://jamjam:blueberryjam@int.jamkazam.com/gems/'
devenv = ENV["BUILD_NUMBER"].nil? # Jenkins sets a build number environment variable
@ -11,9 +11,10 @@ else
gem 'jam_db', "0.1.#{ENV["BUILD_NUMBER"]}"
gem 'jampb', "0.1.#{ENV["BUILD_NUMBER"]}"
gem 'jam_ruby', "0.1.#{ENV["BUILD_NUMBER"]}"
ENV['NOKOGIRI_USE_SYSTEM_LIBRARIES'] ||= "true"
end
gem 'rails'
gem 'rails', '~> 3.2.11'
gem 'bootstrap-sass', '2.0.4'
gem 'bcrypt-ruby', '3.0.1'
@ -34,9 +35,10 @@ end
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'carrierwave', '0.9.0'
gem 'carrierwave_direct'
gem 'uuidtools', '2.1.2'
gem 'bcrypt-ruby', '3.0.1'
gem 'jquery-rails', '2.3.0' # pinned because jquery-ui-rails was split from jquery-rails, but activeadmin doesn't support this gem yet
gem 'jquery-rails' # , '2.3.0' # pinned because jquery-ui-rails was split from jquery-rails, but activeadmin doesn't support this gem yet
gem 'jquery-ui-rails'
gem 'rails3-jquery-autocomplete'
gem 'activeadmin', '0.6.2'
gem 'mime-types', '1.25'
@ -46,9 +48,15 @@ gem 'unf', '0.1.3' #optional fog dependency
gem 'country-select'
gem 'aasm', '3.0.16'
gem 'postgres-copy', '0.6.0'
gem 'aws-sdk'
gem 'aws-sdk' #, '1.29.1'
gem 'bugsnag'
gem 'gon'
gem 'cocoon'
gem 'haml-rails'
gem 'resque'
gem 'resque-retry'
gem 'resque-failed-job-mailer'
gem 'resque-lonely_job', '~> 1.0.0'
gem 'eventmachine', '1.0.3'
gem 'amqp', '0.9.8'
@ -57,7 +65,12 @@ gem 'logging-rails', :require => 'logging/rails'
gem 'pg_migrate'
gem 'ruby-protocol-buffers', '1.2.2'
gem 'sendgrid', '1.1.0'
gem 'sendgrid', '1.2.0'
gem 'geokit-rails'
gem 'postgres_ext', '1.0.0'
gem 'resque_mailer'
gem 'rest-client'
gem 'geokit-rails'
gem 'postgres_ext', '1.0.0'
@ -98,4 +111,11 @@ group :development, :test do
gem 'factory_girl_rails', '4.1.0'
gem 'database_cleaner', '0.7.0'
gem 'launchy'
gem 'faker'
end
group :test do
gem 'simplecov', '~> 0.7.1'
gem 'simplecov-rcov'
end

View File

@ -1,3 +1,7 @@
ActiveAdmin.register JamRuby::Band, :as => 'Band' do
collection_action :autocomplete_band_name, :method => :get
controller do
autocomplete :band, :name, :full => true
end
end

View File

@ -3,6 +3,7 @@ ActiveAdmin.register JamRuby::CrashDump, :as => 'Crash Dump' do
filter :timestamp
filter :user_email, :as => :string
filter :client_id
menu :parent => 'Debug'
index do
column "Timestamp" do |post|

View File

@ -8,7 +8,7 @@ ActiveAdmin.register_page "Dashboard" do
span "JamKazam Data Administration Portal"
small ul do
li "Admin users are users with the admin boolean set to true"
li "Create/Edit JamKazam users using the 'Jam User' menu in header"
li "Invite JamKazam users using the 'Users > Invite' menu in header"
li "Admin users are created/deleted when toggling the 'admin' flag for JamKazam users"
end
end

View File

@ -0,0 +1,127 @@
ActiveAdmin.register JamRuby::EmailBatch, :as => 'Batch Emails' do
menu :label => 'Batch Emails', :parent => 'Email'
config.sort_order = 'updated_at DESC'
config.batch_actions = false
config.clear_action_items!
config.filters = false
form :partial => 'form'
action_item :only => [:show] do
link_to('Edit Batch Email', edit_admin_batch_email_path(resource.id)) if resource.can_run_batch?
end
action_item :only => [:show] do
link_to("Test Batch (#{resource.test_count})",
batch_test_admin_batch_email_path(resource.id),
:confirm => "Run test batch with #{resource.test_count} emails?") if resource.can_run_test?
end
action_item :only => [:show] do
link_to("Deliver Batch (#{User.email_opt_in.count})",
batch_send_admin_batch_email_path(resource.id),
:confirm => "Run LIVE batch with #{User.email_opt_in.count} emails?") if resource.can_run_batch?
end
action_item :only => [:show, :edit] do
link_to('Clone Batch Email', batch_clone_admin_batch_email_path(resource.id))
end
action_item do
link_to('New Batch Email', new_admin_batch_email_path)
end
index do
column 'Subject' do |bb| bb.subject end
column 'Created' do |bb| bb.created_at end
column 'From' do |bb| bb.from_email end
column 'Status' do |bb| bb.aasm_state end
column 'Test Emails' do |bb| bb.test_emails end
column 'Email Count' do |bb| bb.opt_in_count end
column 'Sent Count' do |bb| bb.sent_count end
column 'Started' do |bb| bb.started_at end
column 'Completed' do |bb| bb.completed_at end
column 'Send Test' do |bb|
bb.can_run_test? ? link_to("Test Batch (#{bb.test_count})",
batch_test_admin_batch_email_path(bb.id),
:confirm => "Run test batch with #{bb.test_count} emails?") : ''
end
column 'Deliver Live' do |bb|
bb.can_run_batch? ? link_to("Deliver Batch (#{User.email_opt_in.count})",
batch_send_admin_batch_email_path(bb.id),
:confirm => "Run LIVE batch with #{User.email_opt_in.count} emails?") : ''
end
column 'Clone' do |bb|
link_to("Clone", batch_clone_admin_batch_email_path(bb.id))
end
default_actions
end
show :title => 'Batch Email' do |obj|
panel 'Email Contents' do
attributes_table_for obj do
row 'From' do |obj| obj.from_email end
row 'Test Emails' do |obj| obj.test_emails end
row 'Subject' do |obj| obj.subject end
row 'Body' do |obj| obj.body end
end
end
columns do
column do
panel 'Sending Parameters' do
attributes_table_for obj do
row 'State' do |obj| obj.aasm_state end
row 'Opt-in Count' do |obj| obj.opting_in_count end
row 'Sent Count' do |obj| obj.sent_count end
row 'Started' do |obj| obj.started_at end
row 'Completed' do |obj| obj.completed_at end
row 'Updated' do |obj| obj.updated_at end
end
end
end
column do
panel 'Send Chunks' do
table_for(sets = obj.email_batch_sets) do
column :started_at do |sets| sets.started_at.strftime('%b %d %Y, %H:%M') end
column :batch_count do |sets| sets.batch_count end
end
end
end
end
end
controller do
def create
batch = EmailBatch.create_with_params(params[:jam_ruby_email_batch])
set_resource_ivar(batch)
render active_admin_template('show')
end
def update
resource.update_with_conflict_validation(params[:jam_ruby_email_batch])
set_resource_ivar(resource)
render active_admin_template('show')
end
end
member_action :batch_test, :method => :get do
resource.send_test_batch
redirect_to admin_batch_email_path(resource.id)
end
member_action :batch_send, :method => :get do
resource.deliver_batch
redirect_to admin_batch_email_path(resource.id)
end
member_action :batch_clone, :method => :get do
bb = resource.clone
redirect_to edit_admin_batch_email_path(bb.id)
end
end

View File

@ -0,0 +1,29 @@
ActiveAdmin.register JamRuby::EmailError, :as => 'Email Errors' do
menu :label => 'Email Errors', :parent => 'Email'
config.batch_actions = false
config.filters = false
config.clear_action_items!
index do
column 'User' do |eerr|
eerr.user ? link_to(eerr.user.name, admin_user_path(eerr.user_id)) : 'N/A'
end
column 'Error Type' do |eerr| eerr.error_type end
column 'Email Address' do |eerr| eerr.email_address end
column 'Status' do |eerr| eerr.status end
column 'Reason' do |eerr| eerr.reason end
column 'Email Date' do |eerr| eerr.email_date end
end
controller do
def scoped_collection
@eerrors ||= end_of_association_chain
.includes([:user])
.order('email_date DESC')
end
end
end

View File

@ -0,0 +1,52 @@
ActiveAdmin.register JamRuby::Mix, :as => 'Errored Mixes' do
config.filters = true
config.per_page = 50
config.clear_action_items!
config.sort_order = "created_at_desc"
menu :parent => 'Sessions'
controller do
def scoped_collection
Mix.where('error_reason is not NULL and completed = FALSE')
end
def mix_again
@mix = Mix.find(params[:id])
@mix.enqueue
render :json => {}
end
end
index :as => :block do |mix|
div :for => mix do
h3 "Mix (Users: #{mix.recording.users.map { |u| u.name }.join ','}) (When: #{mix.created_at.strftime('%b %d %Y, %H:%M')})"
columns do
column do
panel 'Mix Details' do
attributes_table_for(mix) do
row :recording do |mix| auto_link(mix.recording, mix.recording.id) end
row :created_at do |mix| mix.created_at.strftime('%b %d %Y, %H:%M') end
row :s3_url do |mix| mix.url end
row :manifest do |mix| mix.manifest end
row :completed do |mix| "#{mix.completed ? "finished" : "not finished"}" end
if mix.completed
row :completed_at do |mix| mix.completed_at.strftime('%b %d %Y, %H:%M') end
elsif mix.error_count > 0
row :error_count do |mix| "#{mix.error_count} times failed" end
row :error_reason do |mix| "last reason failed: #{mix.error_reason}" end
row :error_detail do |mix| "last error detail: #{mix.error_detail}" end
row :mix_again do |mix| div :class => 'mix-again' do
span do link_to "Mix Again", '#', :class => 'mix-again', :'data-mix-id' => mix.id end
span do div :class => 'mix-again-dialog' do end end
end
end
end
end
end
end
end
end
end
end

3
admin/app/admin/event.rb Normal file
View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::Event, :as => 'Event' do
menu :parent => 'Events'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::EventSession, :as => 'Event Session' do
menu :parent => 'Events'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastAdminAuthentication, :as => 'Admin Authentication' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,242 @@
ActiveAdmin.register_page "Bootstrap" do
menu :parent => 'Icecast'
page_action :create_server, :method => :post do
template = IcecastTemplate.find_by_id(params[:jam_ruby_icecast_server][:template_id])
mount_template = IcecastMountTemplate.find_by_id(params[:jam_ruby_icecast_server][:mount_template_id])
hostname = params[:jam_ruby_icecast_server][:hostname]
server = IcecastServer.new
server.template = template
server.mount_template = mount_template
server.hostname = hostname
server.server_id = hostname
server.save!
redirect_to admin_bootstrap_path, :notice => "Server created. If you start a job worker (bundle exec rake all_jobs in /web), it should update your icecast config."
end
page_action :brew_template, :method => :post do
# to make this template, I just did 'brew install icecast', and then based the rest of this code on what I saw in /usr/local/etc/icecast.xml
IcecastServer.transaction do
limit = IcecastLimit.new
limit.clients = 100
limit.sources = 2
limit.queue_size = 524288
limit.client_timeout = 30
limit.header_timeout = 15
limit.source_timeout = 10
limit.burst_size = 65535
limit.save!
admin_auth = IcecastAdminAuthentication.new
admin_auth.source_pass = 'blueberryjam'
admin_auth.relay_user = 'jamjam'
admin_auth.relay_pass = 'blueberryjam'
admin_auth.admin_user = 'jamjam'
admin_auth.admin_pass = 'blueberryjam'
admin_auth.save!
path = IcecastPath.new
path.base_dir = '/usr/local/Cellar/icecast/2.3.3/share/icecast'
path.log_dir = '/usr/local/Cellar/icecast/2.3.3/var/log/icecast'
path.web_root = '/usr/local/Cellar/icecast/2.3.3/share/icecast/web'
path.admin_root = '/usr/local/Cellar/icecast/2.3.3/share/icecast/admin'
path.pid_file = nil
path.save!
security = IcecastSecurity.new
security.chroot = false
security.save!
logging = IcecastLogging.new
logging.access_log = 'access.log'
logging.error_log = 'error.log'
logging.log_level = 3 # you might want to change this after creating the template
logging.log_size = 10000
logging.save!
listen_socket1 = IcecastListenSocket.new
listen_socket1.port = 10000
listen_socket1.save!
listen_socket2 = IcecastListenSocket.new
listen_socket2.port = 10001
listen_socket2.save!
template = IcecastTemplate.new
template.name = "Brew-#{IcecastTemplate.count + 1}"
template.location = '@work'
template.admin_email = 'nobody@jamkazam.com'
template.fileserve = true
template.limit = limit
template.admin_auth = admin_auth
template.path = path
template.security = security
template.logging = logging
template.listen_sockets = [listen_socket1, listen_socket2]
template.save!
end
redirect_to admin_bootstrap_path, :notice => "Brew template created. Now, create a mount template."
end
page_action :ubuntu_template, :method => :post do
# to make this template, I installed icecast233 from jenkins (or our chef'ed apt-repo, same difference), and then based the rest of this code on what I saw in /etc/icecast2/icecast.xml
IcecastServer.transaction do
limit = IcecastLimit.new
limit.clients = 100
limit.sources = 2
limit.queue_size = 524288
limit.client_timeout = 30
limit.header_timeout = 15
limit.source_timeout = 10
limit.burst_size = 65535
limit.save!
admin_auth = IcecastAdminAuthentication.new
admin_auth.source_pass = 'blueberryjam'
admin_auth.relay_user = 'jamjam'
admin_auth.relay_pass = 'blueberryjam'
admin_auth.admin_user = 'jamjam'
admin_auth.admin_pass = 'blueberryjam'
admin_auth.save!
path = IcecastPath.new
path.base_dir = '/usr/share/icecast2'
path.log_dir = '/var/log/icecast2'
path.web_root = '/usr/share/icecast2/web'
path.admin_root = '/usr/share/icecast2/admin'
path.pid_file = nil
path.save!
security = IcecastSecurity.new
security.chroot = false
security.save!
logging = IcecastLogging.new
logging.access_log = 'access.log'
logging.error_log = 'error.log'
logging.log_level = 3 # you might want to change this after creating the template
logging.log_size = 10000
logging.save!
listen_socket1 = IcecastListenSocket.new
listen_socket1.port = 10000
listen_socket1.save!
listen_socket2 = IcecastListenSocket.new
listen_socket2.port = 10001
listen_socket2.save!
template = IcecastTemplate.new
template.name = "Ubuntu-#{IcecastTemplate.count + 1}"
template.location = '@work'
template.admin_email = 'nobody@jamkazam.com'
template.fileserve = true
template.limit = limit
template.admin_auth = admin_auth
template.path = path
template.security = security
template.logging = logging
template.listen_sockets = [listen_socket1, listen_socket2]
template.save!
end
redirect_to admin_bootstrap_path, :notice => "Ubuntu 12.04 template created. You should also install the icecast233 package: https://int.jamkazam.com/jenkins/job/icecast-debian/"
end
page_action :create_mount_template, :method => :post do
IcecastServer.transaction do
hostname = params[:jam_ruby_icecast_mount_template][:hostname]
type = params[:jam_ruby_icecast_mount_template][:default_mime_type]
auth = IcecastUserAuthentication.new
auth.authentication_type = 'url'
auth.mount_add = 'http://' + hostname + '/api/icecast/mount_add'
auth.mount_remove = 'http://' + hostname + '/api/icecast/mount_remove'
auth.listener_add = 'http://' + hostname + '/api/icecast/listener_add'
auth.listener_remove = 'http://' + hostname + '/api/icecast/listener_remove'
auth.auth_header = 'HTTP/1.1 200 OK'
auth.timelimit_header = 'icecast-auth-timelimit:'
auth.save!
mount_template = IcecastMountTemplate.new
mount_template.name = "#{type}-#{IcecastMountTemplate.count + 1}"
mount_template.source_username = nil # mount will override
mount_template.source_pass = nil # mount will override
mount_template.max_listeners = 20000 # huge
mount_template.max_listener_duration = 3600 * 24 # one day
mount_template.fallback_override = 1
mount_template.fallback_when_full = 1
mount_template.is_public = 0
mount_template.stream_name = nil # mount will override
mount_template.stream_description = nil # mount will override
mount_template.stream_url = nil # mount will override
mount_template.genre = nil # mount will override
mount_template.bitrate = 128
mount_template.burst_size = 65536
mount_template.hidden = 1
mount_template.on_connect = nil
mount_template.on_disconnect = nil
mount_template.authentication = auth
if type == 'ogg'
mount_template.mp3_metadata_interval = nil
mount_template.mime_type ='audio/ogg'
mount_template.subtype = 'vorbis'
#mount_template.fallback_mount = "/fallback-#{mount_template.bitrate}.ogg"
else
mount_template.mp3_metadata_interval = 4096
mount_template.mime_type ='audio/mpeg'
mount_template.subtype = nil
#mount_template.fallback_mount = "/fallback-#{mount_template.bitrate}.mp3"
end
mount_template.save!
end
redirect_to admin_bootstrap_path, :notice => "Mount template created. Create a server now with your new templates specified."
end
action_item do
link_to "Create MacOSX (Brew) Template", admin_bootstrap_brew_template_path, :method => :post
end
action_item do
link_to "Create Ubuntu 12.04 Template", admin_bootstrap_ubuntu_template_path, :method => :post
end
content do
if IcecastTemplate.count == 0
para "You need to create at least one server template, and one mount template. Click one of the top-left buttons based on your platform"
elsif IcecastMountTemplate.count == 0
semantic_form_for IcecastMountTemplate.new, :url => admin_bootstrap_create_mount_template_path, :builder => ActiveAdmin::FormBuilder do |f|
f.inputs "New Mount Template" do
f.input :hostname, :label => "jam-web public hostname:port (such that icecast can reach it)"
f.input :default_mime_type, :as => :select, :collection => ["ogg", "mp3"]
end
f.actions
end
else
semantic_form_for IcecastServer.new, :url => admin_bootstrap_create_server_path, :builder => ActiveAdmin::FormBuilder do |f|
f.inputs "New Icecast Server" do
f.input :hostname, :hint => "Just the icecast hostname; no port"
f.input :template, :hint => "This is the template associated with the server. Not as useful for the 1st server, but subsequent servers can use this same template, and share config"
f.input :mount_template, :hint => "The mount template. When mounts are made as music sessions are created, this template will satisfy templatable values"
end
f.actions
end
end
end
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastDirectory, :as => 'Directory' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastLimit, :as => 'Limit' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastListenSocket, :as => 'Listener' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastLogging, :as => 'Logging' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastMasterServerRelay, :as => 'Master Server Relay' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastMount, :as => 'Mount' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastMountTemplate, :as => 'IcecastMountTemplate' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastPath, :as => 'Path' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastRelay, :as => 'Relay' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastSecurity, :as => 'Security' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastServer, :as => 'Server' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastServerGroup, :as => 'IcecastServerGroup' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,4 @@
ActiveAdmin.register JamRuby::IcecastServerMount, :as => 'ServerMounts' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastServerRelay, :as => 'ServerRelays' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastServerSocket, :as => 'ServerListenSockets' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastTemplate, :as => 'Template' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastTemplateSocket, :as => 'TemplateListenSockets' do
menu :parent => 'Icecast'
end

View File

@ -0,0 +1,3 @@
ActiveAdmin.register JamRuby::IcecastUserAuthentication, :as => 'User Authentication' do
menu :parent => 'Icecast'
end

View File

@ -2,4 +2,6 @@ ActiveAdmin.register JamRuby::IspScoreBatch, :as => 'Isp Score Data' do
config.sort_order = 'created_at_desc'
menu :parent => 'Debug'
end

View File

@ -1,5 +1,5 @@
ActiveAdmin.register JamRuby::InvitedUser, :as => 'Invited Users' do
menu :label => 'Invite Users'
menu :label => 'Invite', :parent => 'Users'
config.sort_order = 'created_at'

View File

@ -1,6 +1,9 @@
ActiveAdmin.register JamRuby::User, :as => 'Users' do
menu :label => 'Jam User'
collection_action :autocomplete_user_email, :method => :get
menu :label => 'Users', :parent => 'Users'
config.sort_order = 'created_at DESC'
@ -11,7 +14,8 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
filter :created_at
filter :updated_at
form do |ff|
form do |ff|
ff.inputs "Details" do
ff.input :email
ff.input :admin
@ -69,7 +73,7 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
column :admin
column :updated_at
column :created_at
column :musician
column :musician do |user| user.musician? ? true : false end
column :city
column :state
column :country
@ -95,6 +99,13 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
controller do
# this actually searches on first name, last name, and email, because of get_autocomplete_items defined below
autocomplete :user, :email, :full => true, :display_value => :autocomplete_display_name
def get_autocomplete_items(parameters)
items = User.select("DISTINCT email, first_name, last_name, id").where(["email ILIKE ? OR first_name ILIKE ? OR last_name ILIKE ?", "%#{parameters[:term]}%", "%#{parameters[:term]}%", "%#{parameters[:term]}%"])
end
def create
@jam_ruby_user = JamRuby::User.new(params[:jam_ruby_user])
@jam_ruby_user.administratively_created = true

48
admin/app/admin/mix.rb Normal file
View File

@ -0,0 +1,48 @@
ActiveAdmin.register JamRuby::Mix, :as => 'Mixes' do
config.filters = true
config.per_page = 50
config.clear_action_items!
config.sort_order = "created_at_desc"
menu :parent => 'Sessions'
controller do
def mix_again
@mix = Mix.find(params[:id])
@mix.enqueue
render :json => {}
end
end
index :as => :block do |mix|
div :for => mix do
h3 "Mix (Users: #{mix.recording.users.map { |u| u.name }.join ','}) (When: #{mix.created_at.strftime('%b %d %Y, %H:%M')})"
columns do
column do
panel 'Mix Details' do
attributes_table_for(mix) do
row :recording do |mix| auto_link(mix.recording, mix.recording.id) end
row :created_at do |mix| mix.created_at.strftime('%b %d %Y, %H:%M') end
row :s3_url do |mix| mix.url end
row :manifest do |mix| mix.manifest end
row :completed do |mix| "#{mix.completed ? "finished" : "not finished"}" end
if mix.completed
row :completed_at do |mix| mix.completed_at.strftime('%b %d %Y, %H:%M') end
elsif mix.error_count > 0
row :error_count do |mix| "#{mix.error_count} times failed" end
row :error_reason do |mix| "last reason failed: #{mix.error_reason}" end
row :error_detail do |mix| "last error detail: #{mix.error_detail}" end
row :mix_again do |mix| div :class => 'mix-again' do
span do link_to "Mix Again", '#', :class => 'mix-again', :'data-mix-id' => mix.id end
span do div :class => 'mix-again-dialog' do end end
end
end
end
end
end
end
end
end
end
end

View File

@ -1,8 +1,10 @@
ActiveAdmin.register JamRuby::MusicSessionHistory, :as => 'Music Session History', :sort_order => 'created_at DESC' do
ActiveAdmin.register JamRuby::MusicSessionHistory, :as => 'Music Session History' do
config.filters = false
config.per_page = 50
config.clear_action_items!
config.sort_order = 'created_at_desc'
menu :parent => 'Sessions', :label => 'Sessions'
controller do
def scoped_collection
@ -23,7 +25,7 @@ ActiveAdmin.register JamRuby::MusicSessionHistory, :as => 'Music Session History
index :as => :block do |msh|
div :for => msh do
h3 "Session ##{msh.music_session_id}: #{msh.created_at.strftime('%b %d %Y, %H:%M')}"
h4 "(append URL with ?admin=0 to hide admin sessions)"
h4 "(append URL with ?admin=1 to show admin sessions)"
columns do
column do
panel 'Session Details' do

View File

@ -0,0 +1,68 @@
ActiveAdmin.register JamRuby::PromoBuzz, :as => 'Buzz' do
menu :label => 'Buzz', :parent => 'Home Page'
config.sort_order = 'position ASC aasm_state DESC updated_at DESC'
config.batch_actions = false
# config.clear_action_items!
config.filters = false
form :partial => 'form'
index do
column 'Who?' do |pp| pp.text_short end
column 'Image' do |pp|
image_tag(pp.image_url, :size => '50x50')
end
column 'Quote' do |pp| pp.text_long[0..256] end
column 'State' do |pp| pp.aasm_state end
column 'Position' do |pp| pp.position end
column 'Updated' do |pp| pp.updated_at end
default_actions
end
show do
attributes_table do
row 'Who?' do |obj| obj.text_short end
row 'Quote' do |obj| obj.text_long end
row :image do |obj|
image_tag(obj.image_url, :size => '50x50')
end
row 'State' do |obj| obj.aasm_state end
row 'Position' do |obj| obj.position end
row 'Updated' do |obj| obj.updated_at end
end
end
controller do
def new
@promo = JamRuby::PromoBuzz.new
@promo.key = params[:key] if params[:key].present?
@promo.aasm_state = 'active'
@uploader = @promo.image
@uploader.success_action_redirect = new_admin_buzz_url
super
end
def create
promo = PromoBuzz.create_with_params(params[:jam_ruby_promo_buzz])
redirect_to admin_buzzs_path
end
def edit
@promo = resource
@promo.key = params[:key] if params[:key].present? && params[:key] != @promo.key
@uploader = @promo.image
@uploader.success_action_redirect = edit_admin_buzz_url(@promo)
super
end
def update
resource.update_with_params(params[:jam_ruby_promo_buzz]).save!
redirect_to admin_buzzs_path
end
end
end

View File

@ -0,0 +1,56 @@
ActiveAdmin.register JamRuby::PromoLatest, :as => 'Latest' do
menu :label => 'Latest', :parent => 'Home Page'
config.batch_actions = false
config.sort_order = ''
# config.clear_action_items!
config.filters = false
form :partial => 'form'
index do
column 'Latest' do |pp| pp.latest_display_name end
column 'Latest ID' do |pp| pp.latest_id end
column 'State' do |pp| pp.aasm_state end
column 'Position' do |pp| pp.position end
column 'Updated' do |pp| pp.updated_at end
default_actions
end
show do
attributes_table do
row 'Latest' do |pp| pp.latest_display_name end
row 'State' do |obj| obj.aasm_state end
row 'Position' do |obj| obj.position end
row 'Updated' do |obj| obj.updated_at end
end
end
controller do
def new
@promo = JamRuby::PromoLatest.new
@promo.aasm_state = 'active'
super
end
def create
promo = PromoLatest.create_with_params(params[:jam_ruby_promo_latest])
redirect_to admin_latests_path
end
def edit
@promo = resource
super
end
def update
resource.update_with_params(params[:jam_ruby_promo_latest]).save!
redirect_to admin_latests_path
end
end
end

View File

@ -0,0 +1,61 @@
ActiveAdmin.register JamRuby::Recording, :as => 'Recording' do
menu :label => 'Recording', :parent => 'Recordings'
config.sort_order = 'DESC updated_at'
config.batch_actions = false
# config.clear_action_items!
config.filters = false
form :partial => 'form'
controller do
def initialize_client_tokens(params)
recording = params[:jam_ruby_recording]
return params unless recording
recorded_tracks = recording[:recorded_tracks_attributes]
return params unless recorded_tracks
recorded_tracks.each do |key, recorded_track|
recorded_track[:client_id] = nil if recorded_track[:client_id] == ""
recorded_track[:client_track_id] = nil if recorded_track[:client_track_id] == ""
recorded_track[:track_id] = nil if recorded_track[:track_id] == ""
recorded_track[:client_id] ||= recorded_track[:user_id] if recorded_track[:user_id]
recorded_track[:client_track_id] ||= SecureRandom.uuid
recorded_track[:track_id] ||= SecureRandom.uuid
end
params
end
def new
@recording = JamRuby::Recording.new
super
end
def create
params.merge! initialize_client_tokens(params)
create!
end
def edit
@recording = resource
super
end
def update
params.merge! initialize_client_tokens(params)
update! do |format|
format.html { redirect_to edit_admin_recording_url(params[:jam_ruby_recording]) }
end
end
end
end

View File

@ -1,8 +0,0 @@
ActiveAdmin.register JamRuby::User do
# define routes for "autocomplete :admin_user, :email"
collection_action :autocomplete_user_email, :method => :get
controller do
autocomplete :invited_user, :email
end
end

View File

@ -0,0 +1,89 @@
ActiveAdmin.register JamRuby::User, :as => 'User Progression' do
PROGRESSION_DATE = '%Y-%m-%d %H:%M' unless defined?(PROGRESSION_DATE)
menu :label => 'Progression', :parent => 'Users'
config.sort_order = 'updated_at DESC'
config.batch_actions = false
config.clear_action_items!
config.filters = false
index do
column :email do |user| link_to(truncate(user.email, {:length => 12}), resource_path(user), {:title => "#{user.first_name} #{user.last_name} (#{user.email})"}) end
column :updated_at do |uu| uu.updated_at.strftime(PROGRESSION_DATE) end
column :created_at do |uu| uu.created_at.strftime(PROGRESSION_DATE) end
column :city
column :musician
column 'Client DL' do |uu|
if dd = uu.first_downloaded_client_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Client Run' do |uu|
if dd = uu.first_ran_client_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Certified Gear' do |uu|
if dd = uu.first_certified_gear_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Any Session' do |uu|
if dd = uu.first_music_session_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Real Session' do |uu|
if dd = uu.first_real_music_session_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Good Session' do |uu|
if dd = uu.first_good_music_session_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Invited' do |uu|
if dd = uu.first_invited_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Friended' do |uu|
if dd = uu.first_friended_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Recorded' do |uu|
if dd = uu.first_recording_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
column 'Promoted' do |uu|
if dd = uu.first_social_promoted_at
dd.strftime(PROGRESSION_DATE)
else
''
end
end
end
end

View File

@ -1,2 +1,14 @@
//= require active_admin/base
// //= require active_admin/base
//= require jquery
//= require jquery_ujs
//= require jquery-ui
// require jquery.ui.core
// require jquery.ui.widget
// require jquery.ui.datepicker
// require jquery.ui.dialog
// require jquery.ui.autocomplete
//= require cocoon
//= require active_admin/application
//= require autocomplete-rails
//= require base
//= require_tree .

View File

@ -0,0 +1,38 @@
(function(context,$) {
/**
* Javascript wrappers for the REST API
*/
"use strict";
context.JK = context.JK || {};
context.JK.RestAdmin = function() {
var self = this;
var logger = context.JK.logger;
function tryMixAgain(options) {
var mixId = options['mix_id']
return $.ajax({
type: "POST",
dataType: "json",
url: gon.global.prefix + 'api/mix/' + mixId + '/enqueue',
contentType: 'application/json',
processData: false
});
}
function initialize() {
return self;
}
// Expose publics
this.initialize = initialize;
this.tryMixAgain = tryMixAgain;
return this;
};
})(window,jQuery);

View File

@ -12,4 +12,3 @@
//
//= require jquery
//= require jquery_ujs
//= require_tree .

View File

@ -0,0 +1,23 @@
(function(context,$) {
context.JK = {}
var console_methods = [
'log', 'debug', 'info', 'warn', 'error', 'assert',
'clear', 'dir', 'dirxml', 'trace', 'group',
'groupCollapsed', 'groupEnd', 'time', 'timeEnd',
'timeStamp', 'profile', 'profileEnd', 'count',
'exception', 'table'
];
if ('undefined' === typeof(context.console)) {
context.console = {};
$.each(console_methods, function(index, value) {
context.console[value] = $.noop;
});
}
context.JK.logger = context.console;
})(window, jQuery);

View File

View File

@ -0,0 +1,22 @@
(function(context,$) {
var restAdmin = context.JK.RestAdmin();
$(function() {
// convert mix again links to ajax
$('a.mix-again').click(function() {
var $link = $(this);
restAdmin.tryMixAgain({mix_id: $link.attr('data-mix-id')})
.done(function(response) {
$link.closest('div.mix-again').find('div.mix-again-dialog').html('<div>Mix enqueued</div><a href="' + gon.global.prefix + 'resque">Resque Web</a>').dialog();
})
.error(function(jqXHR) {
$link.closest('div.mix-again').find('div.mix-again-dialog').html('Mix failed: ' + jqXHR.responseText).dialog();
})
return false;
})
});
})(window, jQuery);

View File

@ -7,6 +7,9 @@
// For example, to change the sidebar width:
// $sidebar-width: 242px;
/*
*= require jquery.ui.all
*/
// Active Admin's got SASS!
@import "active_admin/mixins";
@import "active_admin/base";

View File

@ -9,5 +9,6 @@
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require jquery.ui.all
*= require_tree .
*/

View File

@ -1,3 +1,4 @@
.version-info {
font-size:small;
color:lightgray;

View File

@ -1,3 +1,9 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :prepare_gon
def prepare_gon
gon.prefix = ENV['RAILS_RELATIVE_URL_ROOT'] || '/'
end
end

View File

@ -11,12 +11,16 @@ class ArtifactsController < ApplicationController
file = params[:file]
environment = params[:environment]
@artifact = ArtifactUpdate.find_or_create_by_product_and_environment(product, environment)
ArtifactUpdate.transaction do
# VRFS-1071: Postpone client update notification until installer is available for download
ArtifactUpdate.connection.execute('SET TRANSACTION ISOLATION LEVEL READ COMMITTED')
@artifact = ArtifactUpdate.find_or_create_by_product_and_environment(product, environment)
@artifact.version = version
@artifact.uri = file
@artifact.version = version
@artifact.uri = file
@artifact.save
@artifact.save
end
unless @artifact.errors.any?
render :json => {}, :status => :ok

View File

@ -1,3 +1,4 @@
module ApplicationHelper
end

View File

@ -0,0 +1,7 @@
class AdminAuthorization < ActiveAdmin::AuthorizationAdapter
def authorized?(action, subject = nil)
subject.is_a?(EmailBatch) && :update == action ? subject.can_run_batch? : true
end
end

View File

@ -0,0 +1,20 @@
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWaveDirect::Uploader
include CarrierWave::MimeTypes
process :set_content_type
def initialize(*)
super
JamRuby::UploaderConfiguration.set_aws_public_configuration(self)
end
# Add a white list of extensions which are allowed to be uploaded.
def extension_white_list
%w(jpg jpeg gif png)
end
end

View File

@ -0,0 +1,9 @@
<%= semantic_form_for([:admin, resource], :url => resource.new_record? ? admin_batch_emails_path : "/admin/batch_emails/#{resource.id}") do |f| %>
<%= f.inputs do %>
<%= f.input(:from_email, :label => "From Email", :input_html => {:maxlength => 64}) %>
<%= f.input(:subject, :label => "Subject", :input_html => {:maxlength => 128}) %>
<%= f.input(:test_emails, :label => "Test Emails", :input_html => {:maxlength => 1024, :size => '3x3'}) %>
<%= f.input(:body, :label => "Body", :input_html => {:maxlength => 3096, :size => '10x20'}) %>
<% end %>
<%= f.actions %>
<% end %>

View File

@ -0,0 +1,21 @@
<% unless @promo.image_name.present? %>
<h3>Upload Image First</h3>
<%= direct_upload_form_for @uploader do |f| %>
<p><%= f.file_field :image %></p>
<p><%= f.submit "Upload Image", :id => :submit_buzz_img %></p>
<% end %>
<% end %>
<%= semantic_form_for([:admin, @promo], :html => {:multipart => true}, :url => @promo.new_record? ? admin_buzzs_path : "/admin/buzzs/#{@promo.id}") do |f| %>
<%= f.inputs do %>
<%= f.input(:text_short, :label => "Who?", :input_html => {:maxlength => 512}) %>
<%= f.input(:text_long, :label => "Quote", :input_html => {:rows => 3, :maxlength => 4096}) %>
<%= f.input(:position, :label => "Position", :input_html => {:maxlength => 4}) %>
<%= f.input(:aasm_state, :as => :select, :collection => Promotional::STATES, :label => 'Status') %>
Image File: <%= @promo.image_name %>
<%= f.hidden_field :key %>
<% # = f.input(:photo, :as => :file, :hint => f.template.image_tag(@promo.image_url(:thumb), :size => '50x50')) if @promo.new_record? %>
<% end %>
<% if @promo.image_name.present? %>
<%= f.actions %>
<% end %>
<% end %>

View File

@ -0,0 +1,11 @@
<%= semantic_form_for([:admin, @promo], :html => {:multipart => true}, :url => @promo.new_record? ? admin_latests_path : "/admin/latests/#{@promo.id}") do |f| %>
<%= f.inputs :name => "Recording or Session", :for => :latest do |latest_form| %>
<%= f.input(:latest_id, :label => "Unique ID (Recording or Session)", :input_html => {:maxlength => 128}) %>
<% #= latest_form.input :id, :as => :select, :collection => @latests.collect { |ll| [ll[:name], ll[:id]] }, :label => "Latest", :required => true, :selected => @promo.latest.try(:id) %>
<% end %>
<%= f.inputs do %>
<%= f.input(:position, :label => "Position", :input_html => {:maxlength => 4}) %>
<%= f.input(:aasm_state, :as => :select, :collection => Promotional::STATES, :label => 'Status') %>
<% end %>
<%= f.actions %>
<% end %>

View File

@ -0,0 +1,15 @@
= f.inputs name: 'Claimed Recording' do
%ol.nested-fields
= f.input :name, :hint => 'This is entered in the post-recording dialog. It will be displayed in jam-web.'
= f.input :description, :hint => 'This is entered in the post-recording dialog. It will be displayed in jam-web.'
= f.input :user, :as => :autocomplete, :url => autocomplete_user_email_admin_users_path, :input_html => { id: "jam_ruby_claimed_recording_user_id", name: "", id_element: "#WILL_BE_OVERRIDDEN_BY_JS_IN_RECORDED_FORM" }
= f.input :user_id, :as => :hidden, :input_html => { class: "jam_ruby_claimed_recording[user_id]" }
= f.input :genre, collection: Genre.all, :member_label => :description
= f.input :is_public
= link_to_remove_association "Delete Claimed Recording", f, class: 'button', style: 'margin-left:10px'
%div{style: 'display:none'}

View File

@ -0,0 +1,65 @@
%h2 Instructions
%h3 Overview
%p Make each recorded track first, then the mix, and then finally the claimed recordings.
%h3 Entering users and bands
%p Autocomplete is used to supply users and bands. Just starting typing and pick from the resulting options.
%h3 Adding Tracks and Mixes
%p To add a track or mix, you first click 'Add track' or 'Add mix', and fill out any values present. However, to upload an ogg file for a mix or track, you must first click 'Update Recording' after you initially click 'Add Track/Mix'. When the form re-displays after the update, you will then seen an upload file input. Finally, after you have uploaded an ogg file, you can then click the Download link to verify your ogg file, or mp3, in the case of mixes.
%h4 Specific to Mixes
%ul
%li When you first click 'Add Mix', there is nothing to fill out. So click 'Add Mix', then click 'Update Recording'. The page will prompt you, as well.
%li When you upload a mix ogg file, it will be converted to mp3 too. This makes the request take a little bit of time. Just wait it out.
%h3 Add Claimed Recordings
%p Once your recorded tracks are added, you then want to add one Claimed Recording for each user you want to have access to the recording. Making a claimed recording is basically making a recording 'visible' for a given user. The user must have a recorded track to have a claimed recording.
%h3 Validations
%p It should not be possible to create an invalid recording/track/mix/claim; there are a great deal of validations that will prevent you from doing something invalid. If you find otherwise, please fill out a JIRA .
= semantic_form_for([:admin, @recording], :html => {:multipart => true}, :url => @recording.new_record? ? admin_recordings_path : "#{ENV['RAILS_RELATIVE_URL_ROOT']}/admin/recordings/#{@recording.id}") do |f|
= f.semantic_errors *f.object.errors.keys
= f.inputs name: 'Recording Fields' do
= f.input :name, :hint => 'something to remember this recording by. This is used solely for display in jam-admin; nowhere else.'
= f.input :owner, :as => :autocomplete, :url => autocomplete_user_email_admin_users_path, :input_html => { :id => "jam_ruby_recording_owner", :name => "", :id_element => "#jam_ruby_recording_owner_id" }
= f.input :owner_id, :as => :hidden, :input_html => { :name => "jam_ruby_recording[owner_id]" }
= f.input :band, :as => :autocomplete, :url => autocomplete_band_name_admin_bands_path, :input_html => { :id => "jam_ruby_recording_band", :name => "", :id_element => "#jam_ruby_recording_band_id" }
= f.input :band_id, :as => :hidden, :input_html => { :name => "jam_ruby_recording[band_id]" }
= f.input :duration, :hint => 'how long the recording is (in seconds)'
= f.semantic_fields_for :recorded_tracks do |recorded_track, index|
= render 'recorded_track_fields', f: recorded_track
.links
= link_to_add_association 'Add Track', f, :recorded_tracks, class: 'button', style: 'margin:20px;padding:10px 20px'
= f.semantic_fields_for :mixes do |mix, index|
= render 'mix_fields', f: mix
.links
= link_to_add_association 'Add Mix', f, :mixes, class: 'button', style: 'margin:20px; padding:10px 20px'
= f.semantic_fields_for :claimed_recordings do |claimed_recording, index|
= render 'claimed_recording_fields', f: claimed_recording
.links
= link_to_add_association 'Add Claimed Recording', f, :claimed_recordings, class: 'button', style: 'margin:20px; padding:10px 20px'
= f.actions
:javascript
$(document).ready( function() {
$('body').on('cocoon:before-insert', function(e, insertedItem) {
// handle recorded tracks
var idForHiddenUserId = $('input[class="jam_ruby_recorded_track[user_id]"]', insertedItem).attr('id');
if(idForHiddenUserId) {
$('input[id="jam_ruby_recorded_track_user_id"]', insertedItem).attr('data-id-element', '#' + idForHiddenUserId)
}
// handle claimed recordings
idForHiddenUserId = $('input[class="jam_ruby_claimed_recording[user_id]"]', insertedItem).attr('id');
if(idForHiddenUserId) {
$('input[id="jam_ruby_claimed_recording_user_id"]', insertedItem).attr('data-id-element', '#' + idForHiddenUserId)
}
});
});

View File

@ -0,0 +1,22 @@
= f.inputs name: 'Mix' do
%ol.nested-fields
- if f.object.new_record?
%p{style: 'margin-left:10px'}
%i before you can upload, you must select 'Update Recording'
- else
= f.input :ogg_url, :as => :file
.current_file_holder{style: 'margin-bottom:10px'}
- unless f.object.nil? || f.object[:ogg_url].nil?
%a{href: f.object.sign_url(3600, 'ogg'), style: 'padding:0 0 0 20px'} Download OGG
- unless f.object.nil? || f.object[:mp3_url].nil?
%a{href: f.object.sign_url(3600, 'mp3'), style: 'padding:0 0 0 20px'} Download MP3
%div{style: 'display:none'}
= f.input :should_retry, :as => :hidden, :input_html => {:value => '0' }
= link_to_remove_association "Delete Mix", f, class: 'button', style: 'margin-left:10px'

View File

@ -0,0 +1,25 @@
= f.inputs name: 'Track' do
%ol.nested-fields
= f.input :user, :as => :autocomplete, :url => autocomplete_user_email_admin_users_path, :input_html => { id: "jam_ruby_recorded_track_user_id", name: "", id_element: "#WILL_BE_OVERRIDDEN_BY_JS_IN_RECORDED_FORM" }
= f.input :user_id, :as => :hidden, :input_html => { class: "jam_ruby_recorded_track[user_id]" }
= f.input :instrument, collection: Instrument.all
= f.input :sound, :as => :select, collection: options_for_select(RecordedTrack::SOUND, 'stereo')
- if f.object.new_record?
%i before you can upload, you must select 'Update Recording'
- else
= f.input :url, :as => :file
- unless f.object.nil? || f.object[:url].nil?
.current_file_holder{style: 'margin-bottom:10px'}
%a{href: f.object.sign_url(3600), style: 'padding:0 0 0 20px'} Download
%div{style: 'display:none'}
= f.input :client_id, as: :hidden
= f.input :track_id, as: :hidden
= f.input :client_track_id, as: :hidden
= link_to_remove_association "Delete Track", f, class: 'button', style: 'margin-left:10px'

View File

@ -22,10 +22,10 @@ cp ../pb/target/ruby/jampb/jampb-${GEM_VERSION}.gem vendor/cache/ || { echo "una
cp ../ruby/jam_ruby-${GEM_VERSION}.gem vendor/cache/ || { echo "unable to copy jam-ruby gem"; exit 1; }
# put all dependencies into vendor/bundle
rm -rf vendor/bundle
#rm -rf vendor/bundle -- let jenkins config 'wipe workspace' decide this
rm Gemfile.lock # if we don't want versions to float, pin it in the Gemfile, not count on Gemfile.lock
bundle install --path vendor/bundle
bundle update
#bundle update
if [ "$?" = "0" ]; then
echo "success: updated dependencies"
@ -74,7 +74,7 @@ EOF
set -e
# cache all gems local, and tell bundle to use local gems only
bundle install --path vendor/bundle --local
#bundle install --path vendor/bundle --local
# prepare production acssets
rm -rf $DIR/public/assets
bundle exec rake assets:precompile RAILS_ENV=production

View File

@ -16,6 +16,9 @@ end
include JamRuby
User = JamRuby::User
Band = JamRuby::Band
module JamAdmin
class Application < Rails::Application
@ -33,7 +36,7 @@ module JamAdmin
# Activate observers that should always be running.
config.active_record.observers = "JamRuby::InvitedUserObserver"
config.assets.prefix = ENV['RAILS_RELATIVE_URL_ROOT'] || '/'
config.assets.prefix = "#{ENV['RAILS_RELATIVE_URL_ROOT']}/assets"
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
@ -52,6 +55,9 @@ module JamAdmin
# Enable escaping HTML in JSON.
config.active_support.escape_html_entities_in_json = true
# suppress locale complaint: http://stackoverflow.com/questions/20361428/rails-i18n-validation-deprecation-warning
config.i18n.enforce_available_locales = false
# Use SQL instead of Active Record's schema dumper when creating the database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
@ -72,15 +78,48 @@ module JamAdmin
# to make active_admin assets precompile
config.assets.precompile += ['active_admin.css', 'active_admin.js', 'active_admin/print.css']
###### THESE ARE JAM-WEB VALUES
config.external_hostname = ENV['EXTERNAL_HOSTNAME'] || 'localhost'
config.external_port = ENV['EXTERNAL_PORT'] || 3000
config.external_protocol = ENV['EXTERNAL_PROTOCOL'] || 'http://'
config.external_root_url = "#{config.external_protocol}#{config.external_hostname}#{(config.external_port == 80 || config.external_port == 443) ? '' : ':' + config.external_port.to_s}"
# set to false to instead use amazon. You will also need to supply amazon secrets
config.store_artifacts_to_disk = true
config.store_artifacts_to_disk = false
#config.storage_type = :fog
# these only need to be set if store_artifact_to_files = false
config.aws_artifact_access_key_id = ENV['AWS_KEY']
config.aws_artifact_secret_access_key = ENV['AWS_SECRET']
config.aws_artifact_region = 'us-east-1'
config.aws_artifact_bucket_public = 'jamkazam-dev-public'
config.aws_artifact_bucket = 'jamkazam-dev'
config.aws_artifact_cache = '315576000'
config.aws_access_key_id = ENV['AWS_KEY']
config.aws_secret_access_key = ENV['AWS_SECRET']
config.aws_region = 'us-east-1'
config.aws_bucket_public = 'jamkazam-dev-public'
config.aws_bucket = 'jamkazam-dev'
config.aws_cache = '315576000'
# for carrierwave_direct
config.action_controller.allow_forgery_protection = false
config.redis_host = "localhost:6379"
config.email_alerts_alias = 'alerts@jamkazam.com' # should be used for 'oh no' server down/service down sorts of emails
config.email_generic_from = 'nobody@jamkazam.com'
config.email_smtp_address = 'smtp.sendgrid.net'
config.email_smtp_port = 587
config.email_smtp_domain = 'www.jamkazam.com'
config.email_smtp_authentication = :plain
config.email_smtp_user_name = 'jamkazam'
config.email_smtp_password = 'jamjamblueberryjam'
config.email_smtp_starttls_auto = true
config.facebook_app_id = ENV['FACEBOOK_APP_ID'] || '468555793186398'
config.facebook_app_secret = ENV['FACEBOOK_APP_SECRET'] || '546a5b253972f3e2e8b36d9a3dd5a06e'
config.twitter_app_id = ENV['TWITTER_APP_ID'] || 'nQj2oEeoJZxECC33tiTuIg'
config.twitter_app_secret = ENV['TWITTER_APP_SECRET'] || 'Azcy3QqfzYzn2fsojFPYXcn72yfwa0vG6wWDrZ3KT8'
config.ffmpeg_path = ENV['FFMPEG_PATH'] || (File.exist?('/usr/local/bin/ffmpeg') ? '/usr/local/bin/ffmpeg' : '/usr/bin/ffmpeg')
config.max_audio_downloads = 100
end
end

View File

@ -12,7 +12,9 @@ module Rails
class Server
alias :default_options_alias :default_options
def default_options
default_options_alias.merge!(:Port => 3333)
default_options_alias.merge!(
:Port => 3333 + ENV['JAM_INSTANCE'].to_i,
:pid => File.expand_path("tmp/pids/server-#{ENV['JAM_INSTANCE'].to_i}.pid"))
end
end
end

View File

@ -1,5 +1,7 @@
# Load the rails application
require File.expand_path('../application', __FILE__)
APP_CONFIG = Rails.application.config
# Initialize the rails application
JamAdmin::Application.initialize!

View File

@ -71,6 +71,6 @@ JamAdmin::Application.configure do
# Show the logging configuration on STDOUT
config.show_log_configuration = false
config.aws_artifact_bucket_public = 'jamkazam-public'
config.aws_artifact_bucket = 'jamkazam'
config.aws_bucket_public = 'jamkazam-public'
config.aws_bucket = 'jamkazam'
end

View File

@ -34,4 +34,10 @@ JamAdmin::Application.configure do
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
config.facebook_app_id = '1441492266082868'
config.facebook_app_secret = '233bd040a07e47dcec1cff3e490bfce7'
config.twitter_app_id = 'e7hGc71gmcBgo6Wvdta6Sg'
config.twitter_app_secret = 'PfG1jAUMnyrimPcDooUVQaJrG1IuDjUyGg5KciOo'
end

View File

@ -2,9 +2,15 @@ class Footer < ActiveAdmin::Component
def build
super(id: "footer")
para "version info: web=#{::JamAdmin::VERSION} lib=#{JamRuby::VERSION} db=#{JamDb::VERSION}"
render :inline => include_gon
end
end
module ActiveAdmin
class BaseController
with_role :admin
end
end
ActiveAdmin.setup do |config|
@ -159,4 +165,11 @@ ActiveAdmin.setup do |config|
# config.csv_options = {}
config.view_factory.footer = Footer
config.register_javascript 'autocomplete-rails.js'
config.register_stylesheet 'jquery.ui.theme.css'
config.authorization_adapter = "AdminAuthorization"
end

View File

@ -4,20 +4,9 @@ CarrierWave.root = Rails.root.join(Rails.public_path).to_s
CarrierWave.base_path = ENV['RAILS_RELATIVE_URL_ROOT']
CarrierWave.configure do |config|
if JamAdmin::Application.config.store_artifacts_to_disk
config.storage = :file
else
config.storage = :fog
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => JamAdmin::Application.config.aws_artifact_access_key_id,
:aws_secret_access_key => JamAdmin::Application.config.aws_artifact_secret_access_key,
:region => JamAdmin::Application.config.aws_artifact_region,
}
config.fog_directory = JamAdmin::Application.config.aws_artifact_bucket_public # required
config.fog_public = true # optional, defaults to true
config.fog_attributes = {'Cache-Control'=>"max-age=#{JamAdmin::Application.config.aws_artifact_cache}"} # optional, defaults to {}
end
config.storage = Rails.application.config.store_artifacts_to_disk ? :file : :fog
JamRuby::UploaderConfiguration.set_aws_private_configuration(config)
end
require 'carrierwave/orm/activerecord'

View File

@ -1,11 +1,11 @@
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.delivery_method = Rails.env == "test" ? :test : :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => 587,
:domain => "www.jamkazam.com",
:authentication => :plain,
:user_name => "jamkazam",
:password => "jamjamblueberryjam",
:enable_starttls_auto => true
:address => Rails.application.config.email_smtp_address,
:port => Rails.application.config.email_smtp_port,
:domain => Rails.application.config.email_smtp_domain,
:authentication => Rails.application.config.email_smtp_authentication,
:user_name => Rails.application.config.email_smtp_user_name,
:password => Rails.application.config.email_smtp_password ,
:enable_starttls_auto => Rails.application.config.email_smtp_starttls_auto
}

View File

@ -0,0 +1 @@
Gon.global.prefix = ENV['RAILS_RELATIVE_URL_ROOT'] || '/'

View File

@ -0,0 +1,3 @@
class JamRuby::PromoBuzz < JamRuby::Promotional
mount_uploader :image, ImageUploader
end

View File

@ -25,14 +25,6 @@
end
end
def country
@country = "United States"
end
def musician
@musician = true
end
def confirm_url
@signup_confirm_url ||= CONFIRM_URL
end

View File

@ -0,0 +1 @@
Resque.redis = Rails.application.config.redis_host

View File

@ -1,3 +1,7 @@
require 'resque/server'
require 'resque-retry'
require 'resque-retry/server'
JamAdmin::Application.routes.draw do
# ActiveAdmin::Devise.config,
@ -5,12 +9,32 @@ JamAdmin::Application.routes.draw do
devise_for :users, :class_name => "JamRuby::User", :path_prefix => '/admin', :path => '', :path_names => {:sign_in => 'login', :sign_out => 'logout'}
scope ENV['RAILS_RELATIVE_URL_ROOT'] || '/' do
root :to => "admin/dashboard#index"
namespace :admin do
resources :users do
get :autocomplete_user_email, :on => :collection
end
end
namespace :admin do
resources :bands do
get :autocomplete_band_name, :on => :collection
end
end
ActiveAdmin.routes(self)
match '/api/artifacts' => 'artifacts#update_artifacts', :via => :post
match '/api/mix/:id/enqueue' => 'admin/mixes#mix_again', :via => :post
mount Resque::Server.new, :at => "/resque"
# The priority is based upon order of creation:
# first created -> highest priority.

View File

@ -32,7 +32,7 @@ listen 3100, :tcp_nopush => true
timeout 30
# feel free to point this anywhere accessible on the filesystem
pid "/var/run/jam-admin.pid"
pid "/var/run/jam-admin/jam-admin.pid"
# By default, the Unicorn logger will write to stderr.
# Additionally, ome applications/frameworks log to stderr or stdout,

View File

@ -7,20 +7,6 @@ echo "starting build..."
if [ "$?" = "0" ]; then
echo "build succeeded"
if [ ! -z "$PACKAGE" ]; then
echo "publishing ubuntu package (.deb)"
DEBPATH=`find target/deb -name *.deb`
DEBNAME=`basename $DEBPATH`
curl -f -T $DEBPATH $DEB_SERVER/$DEBNAME
if [ "$?" != "0" ]; then
echo "deb publish failed"
exit 1
fi
echo "done publishing deb"
fi
else
echo "build failed"
exit 1

View File

@ -0,0 +1,12 @@
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
task custom_routes: :environment do
require 'rails/application/route_inspector'
inspector = Rails::Application::RouteInspector.new
puts inspector.format(Rails.application.routes.routes)
#all_routes = Rails.application.routes.routes
#inspector = ActionDispatch::Routing::RoutesInspector.new(all_routes)
#puts inspector.format(ActionDispatch::Routing::ConsoleFormatter.new, ENV['CONTROLLER'])
end

View File

@ -3,4 +3,5 @@ module Utils
chars = ((('a'..'z').to_a + ('0'..'9').to_a) - %w(i o 0 1 l 0))
(1..size).collect{|a| cc = chars[rand(chars.size)]; 0==rand(2) ? cc.upcase : cc }.join
end
end

View File

@ -4,4 +4,10 @@ start on startup
start on runlevel [2345]
stop on runlevel [016]
exec start-stop-daemon --start --chdir /var/lib/jam-admin --exec /var/lib/jam-admin/script/package/upstart-run.sh
pre-start script
set -e
mkdir -p /var/run/jam-admin
chown jam-admin:jam-admin /var/run/jam-admin
end script
exec start-stop-daemon --start --chuid jam-admin:jam-admin --chdir /var/lib/jam-admin --exec /var/lib/jam-admin/script/package/upstart-run.sh

View File

@ -9,7 +9,7 @@ FactoryGirl.define do
musician true
city "Apex"
state "NC"
country "USA"
country "US"
terms_of_service true

View File

@ -1,6 +1,5 @@
ENV["RAILS_ENV"] ||= 'test'
require 'simplecov'
# provision database
require 'active_record'

135
build Executable file
View File

@ -0,0 +1,135 @@
#!/bin/bash
# RUN_SLOW_TESTS, RUN_AWS_TESTS, SKIP_KARMA=1 SHOW_JS_ERRORS=1 PACKAGE=1
# WORKSPACE=/var/lib/jenkins/jobs/jam-web/workspace
set -e
export BUNDLE_JOBS=1 # 6, which i want to use, makes the whole server crawl
echo ""
echo "BUILDING JAM-DB"
pushd db > /dev/null
./jenkins
popd > /dev/null
echo ""
echo "BUILDING JAM-PB"
pushd pb > /dev/null
bash -l ./jenkins
popd > /dev/null
echo ""
echo "BUILDING JAM-RUBY"
pushd ruby > /dev/null
rm -f *.gem
bash -l ./jenkins
popd > /dev/null
echo ""
echo "BUILDING WEBSOCKET GATEWAY"
pushd websocket-gateway > /dev/null
bash -l ./jenkins
popd > /dev/null
echo ""
echo "BUILDING JAM-WEB"
pushd web > /dev/null
echo "kill any stuck rspec tests from previous run. need to debug how/why this happens on build server"
set +e
ps aux | grep -ie "jam-cloud.*rspec" | awk '{print $2}' | xargs kill -9
set -e
PACKAGE=1 bash ./jenkins
# we do this so that the build won't fail in jenkins if no capybara error screenshot isn't there
mkdir -p tmp/capybara
touch tmp/capybara/success.png
popd > /dev/null
echo ""
echo "BUILDING JAM-ADMIN"
pushd admin /dev/null
bash -l ./jenkins
popd > /dev/null
if [ ! -z "$PACKAGE" ]; then
DEB_SERVER=http://localhost:9010/apt-`uname -p`
GEM_SERVER=http://localhost:9000/gems
# if still going, then push all debs up
if [[ "$GIT_BRANCH" == *develop* || "$GIT_BRANCH" == *master* || "$GIT_BRANCH" == *release* ]]; then
echo ""
echo "PUSHING DB ARTIFACTS"
pushd db > /dev/null
echo "publishing ubuntu packages (.deb)"
for f in `find target -name '*.deb'`; do
DEBNAME=`basename $f`
DEBPATH="$f"
echo "publishing $DEBPATH to deb server"
curl -f -T $DEBPATH $DEB_SERVER/$DEBNAME
if [ "$?" != "0" ]; then
echo "deb publish failed of $DEBPATH"
exit 1
fi
done
echo "done publishing debs"
popd > /dev/null
echo ""
echo "PUSHING WEB"
pushd web > /dev/null
echo "publishing ubuntu package (.deb)"
DEBPATH=`find target/deb -name *.deb`
DEBNAME=`basename $DEBPATH`
curl -f -T $DEBPATH $DEB_SERVER/$DEBNAME
if [ "$?" != "0" ]; then
echo "deb publish failed"
exit 1
fi
echo "done publishing deb"
popd > /dev/null
echo ""
echo "PUSHING WEBSOCKET-GATEWAY"
pushd websocket-gateway > /dev/null
echo "publishing ubuntu package (.deb)"
DEBPATH=`find target/deb -name *.deb`
DEBNAME=`basename $DEBPATH`
curl -f -T $DEBPATH $DEB_SERVER/$DEBNAME
if [ "$?" != "0" ]; then
echo "deb publish failed"
exit 1
fi
echo "done publishing deb"
popd > /dev/null
echo ""
echo "PUSHING ADMIN"
pushd admin > /dev/null
echo "publishing ubuntu package (.deb)"
DEBPATH=`find target/deb -name *.deb`
DEBNAME=`basename $DEBPATH`
curl -f -T $DEBPATH $DEB_SERVER/$DEBNAME
if [ "$?" != "0" ]; then
echo "deb publish failed"
exit 1
fi
echo "done publishing deb"
popd > /dev/null
else
echo "Skipping publish since branch is neither master or develop..."
fi
fi

View File

@ -1 +1 @@
ruby-2.0.0-p247
2.0.0-p247

View File

@ -1,6 +1,6 @@
source 'https://rubygems.org'
source 'http://rubygems.org'
# Assumes you have already cloned pg_migrate_ruby in your workspace
# $ cd [workspace]
# $ git clone https://github.com/sethcall/pg_migrate_ruby
gem 'pg_migrate', '0.1.11'
gem 'pg_migrate', '0.1.13'

View File

@ -1,20 +1,18 @@
GEM
remote: https://rubygems.org/
remote: http://rubygems.org/
specs:
little-plugger (1.1.3)
logging (1.7.2)
little-plugger (>= 1.1.3)
pg (0.15.1)
pg (0.15.1-x86-mingw32)
pg_migrate (0.1.11)
pg (0.17.1)
pg_migrate (0.1.13)
logging (= 1.7.2)
pg (= 0.15.1)
thor (= 0.15.4)
thor (0.15.4)
pg (= 0.17.1)
thor
thor (0.18.1)
PLATFORMS
ruby
x86-mingw32
DEPENDENCIES
pg_migrate (= 0.1.11)
pg_migrate (= 0.1.13)

View File

@ -19,7 +19,7 @@ rm -rf $TARGET
mkdir -p $PG_BUILD_OUT
mkdir -p $PG_RUBY_PACKAGE_OUT
bundle update
bundle install --path vendor/bundle
echo "building migrations"
bundle exec pg_migrate build --source . --out $PG_BUILD_OUT --test --verbose

1
db/geodata/README.txt Normal file
View File

@ -0,0 +1 @@
this is just for getting this maxmind data over there so i can use it.

13
db/geodata/ca_region.csv Normal file
View File

@ -0,0 +1,13 @@
AB,Alberta
BC,British Columbia
MB,Manitoba
NB,New Brunswick
NL,Newfoundland and Labrador
NS,Nova Scotia
NT,Northwest Territories
NU,Nunavut
ON,Ontario
PE,Prince Edward Island
QC,Quebec
SK,Saskatchewan
YT,Yukon
1 AB Alberta
2 BC British Columbia
3 MB Manitoba
4 NB New Brunswick
5 NL Newfoundland and Labrador
6 NS Nova Scotia
7 NT Northwest Territories
8 NU Nunavut
9 ON Ontario
10 PE Prince Edward Island
11 QC Quebec
12 SK Saskatchewan
13 YT Yukon

254
db/geodata/iso3166.csv Normal file
View File

@ -0,0 +1,254 @@
A1,"Anonymous Proxy"
A2,"Satellite Provider"
O1,"Other Country"
AD,"Andorra"
AE,"United Arab Emirates"
AF,"Afghanistan"
AG,"Antigua and Barbuda"
AI,"Anguilla"
AL,"Albania"
AM,"Armenia"
AO,"Angola"
AP,"Asia/Pacific Region"
AQ,"Antarctica"
AR,"Argentina"
AS,"American Samoa"
AT,"Austria"
AU,"Australia"
AW,"Aruba"
AX,"Aland Islands"
AZ,"Azerbaijan"
BA,"Bosnia and Herzegovina"
BB,"Barbados"
BD,"Bangladesh"
BE,"Belgium"
BF,"Burkina Faso"
BG,"Bulgaria"
BH,"Bahrain"
BI,"Burundi"
BJ,"Benin"
BL,"Saint Bartelemey"
BM,"Bermuda"
BN,"Brunei Darussalam"
BO,"Bolivia"
BQ,"Bonaire, Saint Eustatius and Saba"
BR,"Brazil"
BS,"Bahamas"
BT,"Bhutan"
BV,"Bouvet Island"
BW,"Botswana"
BY,"Belarus"
BZ,"Belize"
CA,"Canada"
CC,"Cocos (Keeling) Islands"
CD,"Congo, The Democratic Republic of the"
CF,"Central African Republic"
CG,"Congo"
CH,"Switzerland"
CI,"Cote d'Ivoire"
CK,"Cook Islands"
CL,"Chile"
CM,"Cameroon"
CN,"China"
CO,"Colombia"
CR,"Costa Rica"
CU,"Cuba"
CV,"Cape Verde"
CW,"Curacao"
CX,"Christmas Island"
CY,"Cyprus"
CZ,"Czech Republic"
DE,"Germany"
DJ,"Djibouti"
DK,"Denmark"
DM,"Dominica"
DO,"Dominican Republic"
DZ,"Algeria"
EC,"Ecuador"
EE,"Estonia"
EG,"Egypt"
EH,"Western Sahara"
ER,"Eritrea"
ES,"Spain"
ET,"Ethiopia"
EU,"Europe"
FI,"Finland"
FJ,"Fiji"
FK,"Falkland Islands (Malvinas)"
FM,"Micronesia, Federated States of"
FO,"Faroe Islands"
FR,"France"
GA,"Gabon"
GB,"United Kingdom"
GD,"Grenada"
GE,"Georgia"
GF,"French Guiana"
GG,"Guernsey"
GH,"Ghana"
GI,"Gibraltar"
GL,"Greenland"
GM,"Gambia"
GN,"Guinea"
GP,"Guadeloupe"
GQ,"Equatorial Guinea"
GR,"Greece"
GS,"South Georgia and the South Sandwich Islands"
GT,"Guatemala"
GU,"Guam"
GW,"Guinea-Bissau"
GY,"Guyana"
HK,"Hong Kong"
HM,"Heard Island and McDonald Islands"
HN,"Honduras"
HR,"Croatia"
HT,"Haiti"
HU,"Hungary"
ID,"Indonesia"
IE,"Ireland"
IL,"Israel"
IM,"Isle of Man"
IN,"India"
IO,"British Indian Ocean Territory"
IQ,"Iraq"
IR,"Iran, Islamic Republic of"
IS,"Iceland"
IT,"Italy"
JE,"Jersey"
JM,"Jamaica"
JO,"Jordan"
JP,"Japan"
KE,"Kenya"
KG,"Kyrgyzstan"
KH,"Cambodia"
KI,"Kiribati"
KM,"Comoros"
KN,"Saint Kitts and Nevis"
KP,"Korea, Democratic People's Republic of"
KR,"Korea, Republic of"
KW,"Kuwait"
KY,"Cayman Islands"
KZ,"Kazakhstan"
LA,"Lao People's Democratic Republic"
LB,"Lebanon"
LC,"Saint Lucia"
LI,"Liechtenstein"
LK,"Sri Lanka"
LR,"Liberia"
LS,"Lesotho"
LT,"Lithuania"
LU,"Luxembourg"
LV,"Latvia"
LY,"Libyan Arab Jamahiriya"
MA,"Morocco"
MC,"Monaco"
MD,"Moldova, Republic of"
ME,"Montenegro"
MF,"Saint Martin"
MG,"Madagascar"
MH,"Marshall Islands"
MK,"Macedonia"
ML,"Mali"
MM,"Myanmar"
MN,"Mongolia"
MO,"Macao"
MP,"Northern Mariana Islands"
MQ,"Martinique"
MR,"Mauritania"
MS,"Montserrat"
MT,"Malta"
MU,"Mauritius"
MV,"Maldives"
MW,"Malawi"
MX,"Mexico"
MY,"Malaysia"
MZ,"Mozambique"
NA,"Namibia"
NC,"New Caledonia"
NE,"Niger"
NF,"Norfolk Island"
NG,"Nigeria"
NI,"Nicaragua"
NL,"Netherlands"
NO,"Norway"
NP,"Nepal"
NR,"Nauru"
NU,"Niue"
NZ,"New Zealand"
OM,"Oman"
PA,"Panama"
PE,"Peru"
PF,"French Polynesia"
PG,"Papua New Guinea"
PH,"Philippines"
PK,"Pakistan"
PL,"Poland"
PM,"Saint Pierre and Miquelon"
PN,"Pitcairn"
PR,"Puerto Rico"
PS,"Palestinian Territory"
PT,"Portugal"
PW,"Palau"
PY,"Paraguay"
QA,"Qatar"
RE,"Reunion"
RO,"Romania"
RS,"Serbia"
RU,"Russian Federation"
RW,"Rwanda"
SA,"Saudi Arabia"
SB,"Solomon Islands"
SC,"Seychelles"
SD,"Sudan"
SE,"Sweden"
SG,"Singapore"
SH,"Saint Helena"
SI,"Slovenia"
SJ,"Svalbard and Jan Mayen"
SK,"Slovakia"
SL,"Sierra Leone"
SM,"San Marino"
SN,"Senegal"
SO,"Somalia"
SR,"Suriname"
SS,"South Sudan"
ST,"Sao Tome and Principe"
SV,"El Salvador"
SX,"Sint Maarten"
SY,"Syrian Arab Republic"
SZ,"Swaziland"
TC,"Turks and Caicos Islands"
TD,"Chad"
TF,"French Southern Territories"
TG,"Togo"
TH,"Thailand"
TJ,"Tajikistan"
TK,"Tokelau"
TL,"Timor-Leste"
TM,"Turkmenistan"
TN,"Tunisia"
TO,"Tonga"
TR,"Turkey"
TT,"Trinidad and Tobago"
TV,"Tuvalu"
TW,"Taiwan"
TZ,"Tanzania, United Republic of"
UA,"Ukraine"
UG,"Uganda"
UM,"United States Minor Outlying Islands"
US,"United States"
UY,"Uruguay"
UZ,"Uzbekistan"
VA,"Holy See (Vatican City State)"
VC,"Saint Vincent and the Grenadines"
VE,"Venezuela"
VG,"Virgin Islands, British"
VI,"Virgin Islands, U.S."
VN,"Vietnam"
VU,"Vanuatu"
WF,"Wallis and Futuna"
WS,"Samoa"
YE,"Yemen"
YT,"Mayotte"
ZA,"South Africa"
ZM,"Zambia"
ZW,"Zimbabwe"
1 A1 Anonymous Proxy
2 A2 Satellite Provider
3 O1 Other Country
4 AD Andorra
5 AE United Arab Emirates
6 AF Afghanistan
7 AG Antigua and Barbuda
8 AI Anguilla
9 AL Albania
10 AM Armenia
11 AO Angola
12 AP Asia/Pacific Region
13 AQ Antarctica
14 AR Argentina
15 AS American Samoa
16 AT Austria
17 AU Australia
18 AW Aruba
19 AX Aland Islands
20 AZ Azerbaijan
21 BA Bosnia and Herzegovina
22 BB Barbados
23 BD Bangladesh
24 BE Belgium
25 BF Burkina Faso
26 BG Bulgaria
27 BH Bahrain
28 BI Burundi
29 BJ Benin
30 BL Saint Bartelemey
31 BM Bermuda
32 BN Brunei Darussalam
33 BO Bolivia
34 BQ Bonaire, Saint Eustatius and Saba
35 BR Brazil
36 BS Bahamas
37 BT Bhutan
38 BV Bouvet Island
39 BW Botswana
40 BY Belarus
41 BZ Belize
42 CA Canada
43 CC Cocos (Keeling) Islands
44 CD Congo, The Democratic Republic of the
45 CF Central African Republic
46 CG Congo
47 CH Switzerland
48 CI Cote d'Ivoire
49 CK Cook Islands
50 CL Chile
51 CM Cameroon
52 CN China
53 CO Colombia
54 CR Costa Rica
55 CU Cuba
56 CV Cape Verde
57 CW Curacao
58 CX Christmas Island
59 CY Cyprus
60 CZ Czech Republic
61 DE Germany
62 DJ Djibouti
63 DK Denmark
64 DM Dominica
65 DO Dominican Republic
66 DZ Algeria
67 EC Ecuador
68 EE Estonia
69 EG Egypt
70 EH Western Sahara
71 ER Eritrea
72 ES Spain
73 ET Ethiopia
74 EU Europe
75 FI Finland
76 FJ Fiji
77 FK Falkland Islands (Malvinas)
78 FM Micronesia, Federated States of
79 FO Faroe Islands
80 FR France
81 GA Gabon
82 GB United Kingdom
83 GD Grenada
84 GE Georgia
85 GF French Guiana
86 GG Guernsey
87 GH Ghana
88 GI Gibraltar
89 GL Greenland
90 GM Gambia
91 GN Guinea
92 GP Guadeloupe
93 GQ Equatorial Guinea
94 GR Greece
95 GS South Georgia and the South Sandwich Islands
96 GT Guatemala
97 GU Guam
98 GW Guinea-Bissau
99 GY Guyana
100 HK Hong Kong
101 HM Heard Island and McDonald Islands
102 HN Honduras
103 HR Croatia
104 HT Haiti
105 HU Hungary
106 ID Indonesia
107 IE Ireland
108 IL Israel
109 IM Isle of Man
110 IN India
111 IO British Indian Ocean Territory
112 IQ Iraq
113 IR Iran, Islamic Republic of
114 IS Iceland
115 IT Italy
116 JE Jersey
117 JM Jamaica
118 JO Jordan
119 JP Japan
120 KE Kenya
121 KG Kyrgyzstan
122 KH Cambodia
123 KI Kiribati
124 KM Comoros
125 KN Saint Kitts and Nevis
126 KP Korea, Democratic People's Republic of
127 KR Korea, Republic of
128 KW Kuwait
129 KY Cayman Islands
130 KZ Kazakhstan
131 LA Lao People's Democratic Republic
132 LB Lebanon
133 LC Saint Lucia
134 LI Liechtenstein
135 LK Sri Lanka
136 LR Liberia
137 LS Lesotho
138 LT Lithuania
139 LU Luxembourg
140 LV Latvia
141 LY Libyan Arab Jamahiriya
142 MA Morocco
143 MC Monaco
144 MD Moldova, Republic of
145 ME Montenegro
146 MF Saint Martin
147 MG Madagascar
148 MH Marshall Islands
149 MK Macedonia
150 ML Mali
151 MM Myanmar
152 MN Mongolia
153 MO Macao
154 MP Northern Mariana Islands
155 MQ Martinique
156 MR Mauritania
157 MS Montserrat
158 MT Malta
159 MU Mauritius
160 MV Maldives
161 MW Malawi
162 MX Mexico
163 MY Malaysia
164 MZ Mozambique
165 NA Namibia
166 NC New Caledonia
167 NE Niger
168 NF Norfolk Island
169 NG Nigeria
170 NI Nicaragua
171 NL Netherlands
172 NO Norway
173 NP Nepal
174 NR Nauru
175 NU Niue
176 NZ New Zealand
177 OM Oman
178 PA Panama
179 PE Peru
180 PF French Polynesia
181 PG Papua New Guinea
182 PH Philippines
183 PK Pakistan
184 PL Poland
185 PM Saint Pierre and Miquelon
186 PN Pitcairn
187 PR Puerto Rico
188 PS Palestinian Territory
189 PT Portugal
190 PW Palau
191 PY Paraguay
192 QA Qatar
193 RE Reunion
194 RO Romania
195 RS Serbia
196 RU Russian Federation
197 RW Rwanda
198 SA Saudi Arabia
199 SB Solomon Islands
200 SC Seychelles
201 SD Sudan
202 SE Sweden
203 SG Singapore
204 SH Saint Helena
205 SI Slovenia
206 SJ Svalbard and Jan Mayen
207 SK Slovakia
208 SL Sierra Leone
209 SM San Marino
210 SN Senegal
211 SO Somalia
212 SR Suriname
213 SS South Sudan
214 ST Sao Tome and Principe
215 SV El Salvador
216 SX Sint Maarten
217 SY Syrian Arab Republic
218 SZ Swaziland
219 TC Turks and Caicos Islands
220 TD Chad
221 TF French Southern Territories
222 TG Togo
223 TH Thailand
224 TJ Tajikistan
225 TK Tokelau
226 TL Timor-Leste
227 TM Turkmenistan
228 TN Tunisia
229 TO Tonga
230 TR Turkey
231 TT Trinidad and Tobago
232 TV Tuvalu
233 TW Taiwan
234 TZ Tanzania, United Republic of
235 UA Ukraine
236 UG Uganda
237 UM United States Minor Outlying Islands
238 US United States
239 UY Uruguay
240 UZ Uzbekistan
241 VA Holy See (Vatican City State)
242 VC Saint Vincent and the Grenadines
243 VE Venezuela
244 VG Virgin Islands, British
245 VI Virgin Islands, U.S.
246 VN Vietnam
247 VU Vanuatu
248 WF Wallis and Futuna
249 WS Samoa
250 YE Yemen
251 YT Mayotte
252 ZA South Africa
253 ZM Zambia
254 ZW Zimbabwe

36
db/geodata/supplement.sql Normal file
View File

@ -0,0 +1,36 @@
-- to load the geoip data:
-- psql -U postgres -d jam -f GeoIP-20140304.sql
-- psql -U postgres -d jam -f supplement.sql
DELETE FROM jamcompany;
ALTER SEQUENCE jamcompany_coid_seq RESTART WITH 1;
INSERT INTO jamcompany (company) SELECT DISTINCT company FROM geoipisp ORDER BY company;
DELETE FROM jamisp;
INSERT INTO jamisp (beginip, endip, coid) SELECT x.beginip, x.endip, y.coid FROM geoipisp x, jamcompany y WHERE x.company = y.company;
ALTER TABLE geoiplocations DROP COLUMN geog;
ALTER TABLE geoiplocations ADD COLUMN geog geography(point, 4326);
UPDATE geoiplocations SET geog = ST_SetSRID(ST_MakePoint(longitude, latitude), 4326)::geography;
CREATE INDEX geoiplocations_geog_gix ON geoiplocations USING GIST (geog);
ALTER TABLE geoipblocks DROP COLUMN geom;
ALTER TABLE geoipblocks ADD COLUMN geom geometry(polygon);
-- DROP INDEX geoipblocks_geom_gix;
UPDATE geoipblocks SET geom = ST_MakeEnvelope(beginip, -1, endip, 1);
CREATE INDEX geoipblocks_geom_gix ON geoipblocks USING GIST (geom);
ALTER TABLE jamisp DROP COLUMN geom;
ALTER TABLE jamisp ADD COLUMN geom geometry(polygon);
UPDATE jamisp SET geom = ST_MakeEnvelope(beginip, -1, endip, 1);
CREATE INDEX jamisp_geom_gix ON jamisp USING GIST (geom);
DELETE FROM cities;
INSERT INTO cities (city, region, countrycode) SELECT DISTINCT city, region, countrycode FROM geoiplocations WHERE length(city) > 0 AND length(countrycode) > 0;
DELETE FROM regions;
INSERT INTO regions (region, countrycode) SELECT DISTINCT region, countrycode FROM cities;
DELETE FROM countries;
INSERT INTO countries (countrycode) SELECT DISTINCT countrycode FROM regions;
VACUUM ANALYSE;

57
db/geodata/us_region.csv Normal file
View File

@ -0,0 +1,57 @@
AA,Armed Forces America
AE,Armed Forces
AP,Armed Forces Pacific
AK,Alaska
AL,Alabama
AR,Arkansas
AZ,Arizona
CA,California
CO,Colorado
CT,Connecticut
DC,District of Columbia
DE,Delaware
FL,Florida
GA,Georgia
GU,Guam
HI,Hawaii
IA,Iowa
ID,Idaho
IL,Illinois
IN,Indiana
KS,Kansas
KY,Kentucky
LA,Louisiana
MA,Massachusetts
MD,Maryland
ME,Maine
MI,Michigan
MN,Minnesota
MO,Missouri
MS,Mississippi
MT,Montana
NC,North Carolina
ND,North Dakota
NE,Nebraska
NH,New Hampshire
NJ,New Jersey
NM,New Mexico
NV,Nevada
NY,New York
OH,Ohio
OK,Oklahoma
OR,Oregon
PA,Pennsylvania
PR,Puerto Rico
RI,Rhode Island
SC,South Carolina
SD,South Dakota
TN,Tennessee
TX,Texas
UT,Utah
VA,Virginia
VI,Virgin Islands
VT,Vermont
WA,Washington
WI,Wisconsin
WV,West Virginia
WY,Wyoming
1 AA Armed Forces America
2 AE Armed Forces
3 AP Armed Forces Pacific
4 AK Alaska
5 AL Alabama
6 AR Arkansas
7 AZ Arizona
8 CA California
9 CO Colorado
10 CT Connecticut
11 DC District of Columbia
12 DE Delaware
13 FL Florida
14 GA Georgia
15 GU Guam
16 HI Hawaii
17 IA Iowa
18 ID Idaho
19 IL Illinois
20 IN Indiana
21 KS Kansas
22 KY Kentucky
23 LA Louisiana
24 MA Massachusetts
25 MD Maryland
26 ME Maine
27 MI Michigan
28 MN Minnesota
29 MO Missouri
30 MS Mississippi
31 MT Montana
32 NC North Carolina
33 ND North Dakota
34 NE Nebraska
35 NH New Hampshire
36 NJ New Jersey
37 NM New Mexico
38 NV Nevada
39 NY New York
40 OH Ohio
41 OK Oklahoma
42 OR Oregon
43 PA Pennsylvania
44 PR Puerto Rico
45 RI Rhode Island
46 SC South Carolina
47 SD South Dakota
48 TN Tennessee
49 TX Texas
50 UT Utah
51 VA Virginia
52 VI Virgin Islands
53 VT Vermont
54 WA Washington
55 WI Wisconsin
56 WV West Virginia
57 WY Wyoming

View File

@ -7,38 +7,19 @@ echo "starting build..."
./build
if [ "$?" = "0" ]; then
echo "build succeeded"
echo "publishing gem"
pushd "target/ruby_package"
find . -name *.gem -exec curl -f -T {} $GEM_SERVER/{} \;
echo "build succeeded"
echo "publishing gem"
pushd "target/ruby_package"
find . -name *.gem -exec curl -f -T {} $GEM_SERVER/{} \;
if [ "$?" != "0" ]; then
echo "publish failed"
exit 1
fi
popd
echo "done publishing gems"
if [ ! -z "$PACKAGE" ]; then
echo "publishing ubuntu packages (.deb)"
for f in `find target -name '*.deb'`; do
DEBNAME=`basename $f`
DEBPATH="$f"
echo "publishing $DEBPATH to deb server"
curl -f -T $DEBPATH $DEB_SERVER/$DEBNAME
if [ "$?" != "0" ]; then
echo "deb publish failed of $DEBPATH"
exit 1
fi
done
echo "done publishing debs"
fi
if [ "$?" != "0" ]; then
echo "publish failed"
exit 1
fi
popd
echo "done publishing gems"
else
echo "build failed"
exit 1
fi

View File

@ -74,3 +74,72 @@ crash_dumps_idx.sql
music_sessions_user_history_add_session_removed_at.sql
user_progress_tracking.sql
whats_next.sql
add_user_bio.sql
users_geocoding.sql
recordings_public_launch.sql
notification_band_invite.sql
band_photo_filepicker.sql
bands_geocoding.sql
store_s3_filenames.sql
discardable_recorded_tracks.sql
music_sessions_have_claimed_recording.sql
discardable_recorded_tracks2.sql
icecast.sql
home_page_promos.sql
mix_job_watch.sql
music_session_constraints.sql
mixes_drop_manifest_add_retry.sql
music_sessions_unlogged.sql
integrate_icecast_into_sessions.sql
ms_recording_anonymous_likes.sql
ms_user_history_add_instruments.sql
icecast_config_changed.sql
invited_users_facebook_support.sql
first_recording_at.sql
share_token.sql
facebook_signup.sql
audiomixer_mp3.sql
share_token_2.sql
large_photo_url.sql
add_secret_to_user_authorization.sql
track_connection_id_not_null.sql
recordings_all_discarded.sql
recordings_via_admin_web.sql
relax_band_model_varchar.sql
add_piano.sql
feed.sql
like_follower_poly_assoc.sql
feed_use_recording.sql
feed_autoincrement_primary_key.sql
music_sessions_plays.sql
plays_likes_counters.sql
add_upright_bass.sql
music_session_history_public.sql
track_claimed_recording.sql
scores_mod_users.sql
scores_mod_connections.sql
scores_create_schemas_and_extensions.sql
scores_create_tables.sql
remove_is_downloadable.sql
scores_mod_connections2.sql
track_download_counts.sql
scores_mod_users2.sql
user_bio.sql
track_changes_counter.sql
scores_better_test_data.sql
connection_client_type.sql
add_countries_regions_and_cities.sql
plays_refactor.sql
fix_max_mind_isp_and_geo.sql
update_get_work_for_client_type.sql
events.sql
cascading_delete_constraints_for_release.sql
events_social_description.sql
fix_broken_cities.sql
notifications_with_text.sql
notification_seen_at.sql
order_event_session.sql
emails.sql
email_batch.sql
user_progress_tracking2.sql
bands_did_session.sql

View File

@ -0,0 +1,8 @@
create table cities (city varchar(255) not null, region varchar(2) not null, regionname varchar(64), countrycode varchar(2) not null, countryname varchar(64));
insert into cities (city, region, countrycode) select distinct city, region, countrycode from geoiplocations where length(city) > 0 and length(countrycode) > 0;
create table regions (region varchar(2) not null, regionname varchar(64), countrycode varchar(2) not null);
insert into regions (region, countrycode) select distinct region, countrycode from cities;
create table countries (countrycode varchar(2) not null, countryname varchar(64));
insert into countries (countrycode) select distinct countrycode from regions;

1
db/up/add_piano.sql Normal file
View File

@ -0,0 +1 @@
INSERT INTO instruments (id, description, popularity) VALUES ('piano', 'Piano', 2);

View File

@ -0,0 +1 @@
ALTER TABLE user_authorizations ADD COLUMN secret VARCHAR(255);

View File

@ -0,0 +1 @@
INSERT INTO instruments (id, description, popularity) VALUES ('upright bass', 'Upright Bass', 2);

1
db/up/add_user_bio.sql Normal file
View File

@ -0,0 +1 @@
alter table users add column biography VARCHAR(4000);

Some files were not shown because too many files have changed in this diff Show More