Permalink
Browse files

adding the source...

  • Loading branch information...
0 parents commit 9f905b169a712d403d53d28e1941fd4d9f6db2ab sshaw committed Sep 4, 2012
Showing with 3,876 additions and 0 deletions.
  1. +32 −0 Gemfile
  2. +130 −0 Gemfile.lock
  3. +17 −0 README.rdoc
  4. +4 −0 Rakefile
  5. +160 −0 app/app.rb
  6. +48 −0 app/forms/forms.rb
  7. +30 −0 app/helpers/application_helper.rb
  8. +66 −0 app/helpers/jobs_helper.rb
  9. +11 −0 app/views/browse.html.haml
  10. +27 −0 app/views/config.html.haml
  11. +13 −0 app/views/jobs/_job.html.haml
  12. +44 −0 app/views/jobs/index.html.haml
  13. +1 −0 app/views/jobs/index.js.erb
  14. +4 −0 app/views/jobs/results/_lookup.html.haml
  15. +24 −0 app/views/jobs/results/_providers.html.haml
  16. +5 −0 app/views/jobs/results/_schema.html.haml
  17. +24 −0 app/views/jobs/results/_status.html.haml
  18. +2 −0 app/views/jobs/results/_upload.html.haml
  19. +2 −0 app/views/jobs/results/_verify.html.haml
  20. +117 −0 app/views/jobs/show.html.haml
  21. +40 −0 app/views/layouts/application.html.haml
  22. +15 −0 app/views/lookup.html.haml
  23. +11 −0 app/views/providers.html.haml
  24. +12 −0 app/views/schema.html.haml
  25. +16 −0 app/views/shared/_auth_fields.html.haml
  26. +13 −0 app/views/shared/_file_browser.html.haml
  27. +10 −0 app/views/status.html.haml
  28. +35 −0 app/views/upload.html.haml
  29. +20 −0 app/views/verify.html.haml
  30. +5 −0 config.ru
  31. +34 −0 config/apps.rb
  32. +33 −0 config/boot.rb
  33. +43 −0 config/database.rb
  34. +16 −0 db/migrate/001_create_delayed_jobs.rb
  35. +18 −0 db/migrate/002_create_config.rb
  36. +17 −0 db/migrate/003_create_jobs.rb
  37. +9 −0 db/migrate/004_add_transporter_job_job_id.rb
  38. +53 −0 db/schema.rb
  39. +31 −0 lib/ls.rb
  40. +34 −0 lib/options.rb
  41. +35 −0 lib/transporter_form_builder.rb
  42. +19 −0 models/app_config.rb
  43. +10 −0 models/lookup_job.rb
  44. +6 −0 models/providers_job.rb
  45. +10 −0 models/schema_job.rb
  46. +10 −0 models/status_job.rb
  47. +148 −0 models/transporter_job.rb
  48. +18 −0 models/upload_job.rb
  49. +18 −0 models/verify_job.rb
  50. +6 −0 models/version_job.rb
  51. BIN public/images/glyphicons-halflings.png
  52. +23 −0 public/javascripts/application.js
  53. +6 −0 public/javascripts/bootstrap.min.js
  54. +92 −0 public/javascripts/jquery-ujs.js
  55. +4 −0 public/javascripts/jquery.js
  56. BIN public/jqueryFileTree/images/application.png
  57. BIN public/jqueryFileTree/images/code.png
  58. BIN public/jqueryFileTree/images/css.png
  59. BIN public/jqueryFileTree/images/db.png
  60. BIN public/jqueryFileTree/images/directory.png
  61. BIN public/jqueryFileTree/images/doc.png
  62. BIN public/jqueryFileTree/images/file.png
  63. BIN public/jqueryFileTree/images/film.png
  64. BIN public/jqueryFileTree/images/flash.png
  65. BIN public/jqueryFileTree/images/folder_open.png
  66. BIN public/jqueryFileTree/images/html.png
  67. BIN public/jqueryFileTree/images/java.png
  68. BIN public/jqueryFileTree/images/linux.png
  69. BIN public/jqueryFileTree/images/music.png
  70. BIN public/jqueryFileTree/images/pdf.png
  71. BIN public/jqueryFileTree/images/php.png
  72. BIN public/jqueryFileTree/images/picture.png
  73. BIN public/jqueryFileTree/images/ppt.png
  74. BIN public/jqueryFileTree/images/psd.png
  75. BIN public/jqueryFileTree/images/ruby.png
  76. BIN public/jqueryFileTree/images/script.png
  77. BIN public/jqueryFileTree/images/spinner.gif
  78. BIN public/jqueryFileTree/images/txt.png
  79. BIN public/jqueryFileTree/images/xls.png
  80. BIN public/jqueryFileTree/images/zip.png
  81. +91 −0 public/jqueryFileTree/jqueryFileTree.css
  82. +114 −0 public/jqueryFileTree/jqueryFileTree.js
  83. +689 −0 public/stylesheets/bootstrap.min.css
  84. +163 −0 public/stylesheets/main.css
  85. +62 −0 test/controllers/config_controller_test.rb
  86. +198 −0 test/controllers/jobs_controller_test.rb
  87. +43 −0 test/controllers/lookup_controller_test.rb
  88. +23 −0 test/controllers/providers_controller_test.rb
  89. +59 −0 test/controllers/schema_controller_test.rb
  90. +34 −0 test/controllers/status_controller_test.rb
  91. +121 −0 test/controllers/upload_controller_test.rb
  92. +59 −0 test/controllers/verify_controller_test.rb
  93. +29 −0 test/lib/form_actions.rb
  94. +22 −0 test/lib/message_matchers.rb
  95. +230 −0 test/lib/transporter_job_test_methods.rb
  96. +30 −0 test/models/app_config_test.rb
  97. +36 −0 test/models/lookup_job_test.rb
  98. +19 −0 test/models/providers_job_test.rb
  99. +27 −0 test/models/schema_job_test.rb
  100. +27 −0 test/models/status_job_test.rb
  101. +57 −0 test/models/upload_job_test.rb
  102. +43 −0 test/models/verify_job_test.rb
  103. +21 −0 test/test.rake
  104. +48 −0 test/test_config.rb
32 Gemfile
@@ -0,0 +1,32 @@
+source :rubygems
+
+# Project requirements
+gem 'rake'
+gem 'sinatra-flash', :require => 'sinatra/flash'
+
+# Component requirements
+gem 'haml'
+gem 'activerecord', :require => "active_record"
+gem 'sqlite3'
+
+gem "daemons"
+gem "delayed_job", "~> 3.0.0"
+gem "delayed_job_active_record"
+gem "coderay"
+gem "will_paginate", "~> 3.0"
+gem "itunes_store_transporter", :git => "git://github.com/sshaw/itunes_store_transporter"
+gem "padrino_bootstrap_forms", :require => "bootstrap_forms", :git => "git://github.com/sshaw/padrino_bootstrap_forms"
+
+# Or Individual Gems
+%w(core gen helpers).each do |g|
+ gem 'padrino-' + g, '0.10.7'
+end
+
+# Test requirements
+group :test do
+ gem 'rr'
+ gem 'shoulda', '~> 2.11.3'
+ gem 'rack-test', :require => 'rack/test'
+ gem 'capybara', '~> 1.1.2'
+ gem 'capybara-webkit', '~> 0.12.1'
+end
@@ -0,0 +1,130 @@
+GIT
+ remote: git://github.com/sshaw/itunes_store_transporter
+ revision: 35295f9a547cb46e3262b473f327d4eba5bd5321
+ specs:
+ itunes_store_transporter (0.0.2)
+ childprocess (~> 0.3.2)
+ optout (~> 0.0.2)
+
+GIT
+ remote: git://github.com/sshaw/padrino_bootstrap_forms
+ revision: 14285ef93add537c766ddcfe9c9c9e8e63e771de
+ specs:
+ padrino_bootstrap_forms (2.0.1)
+ padrino-helpers (~> 0.10.6)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activemodel (3.2.3)
+ activesupport (= 3.2.3)
+ builder (~> 3.0.0)
+ activerecord (3.2.3)
+ activemodel (= 3.2.3)
+ activesupport (= 3.2.3)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activesupport (3.2.3)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ addressable (2.2.8)
+ arel (3.0.2)
+ builder (3.0.0)
+ capybara (1.1.2)
+ mime-types (>= 1.16)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ selenium-webdriver (~> 2.0)
+ xpath (~> 0.1.4)
+ capybara-webkit (0.12.1)
+ capybara (>= 1.0.0, < 1.2)
+ json
+ childprocess (0.3.5)
+ ffi (~> 1.0, >= 1.0.6)
+ coderay (1.0.6)
+ daemons (1.1.8)
+ delayed_job (3.0.2)
+ activesupport (~> 3.0)
+ delayed_job_active_record (0.3.2)
+ activerecord (> 2.1.0)
+ delayed_job (~> 3.0.0)
+ ffi (1.1.5)
+ haml (3.1.4)
+ http_router (0.10.2)
+ rack (>= 1.0.0)
+ url_mount (~> 0.2.1)
+ i18n (0.6.0)
+ json (1.7.3)
+ libwebsocket (0.1.3)
+ addressable
+ mime-types (1.19)
+ multi_json (1.3.6)
+ nokogiri (1.5.5)
+ optout (0.0.2)
+ padrino-core (0.10.7)
+ activesupport (~> 3.2.0)
+ http_router (~> 0.10.2)
+ sinatra (~> 1.3.1)
+ thor (~> 0.15.2)
+ tilt (~> 1.3.0)
+ padrino-gen (0.10.7)
+ bundler (~> 1.0)
+ padrino-core (= 0.10.7)
+ padrino-helpers (0.10.7)
+ i18n (~> 0.6)
+ padrino-core (= 0.10.7)
+ rack (1.4.1)
+ rack-protection (1.2.0)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rake (0.9.2.2)
+ rr (1.0.4)
+ rubyzip (0.9.9)
+ selenium-webdriver (2.24.0)
+ childprocess (>= 0.2.5)
+ libwebsocket (~> 0.1.3)
+ multi_json (~> 1.0)
+ rubyzip
+ shoulda (2.11.3)
+ sinatra (1.3.3)
+ rack (~> 1.3, >= 1.3.6)
+ rack-protection (~> 1.2)
+ tilt (~> 1.3, >= 1.3.3)
+ sinatra-flash (0.3.0)
+ sinatra (>= 1.0.0)
+ sqlite3 (1.3.6)
+ thor (0.15.4)
+ tilt (1.3.3)
+ tzinfo (0.3.33)
+ url_mount (0.2.1)
+ rack
+ will_paginate (3.0.3)
+ xpath (0.1.4)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ activerecord
+ capybara (~> 1.1.2)
+ capybara-webkit (~> 0.12.1)
+ coderay
+ daemons
+ delayed_job (~> 3.0.0)
+ delayed_job_active_record
+ haml
+ itunes_store_transporter!
+ padrino-core (= 0.10.7)
+ padrino-gen (= 0.10.7)
+ padrino-helpers (= 0.10.7)
+ padrino_bootstrap_forms!
+ rack-test
+ rake
+ rr
+ shoulda (~> 2.11.3)
+ sinatra-flash
+ sqlite3
+ will_paginate (~> 3.0)
@@ -0,0 +1,17 @@
+= iTunes::Store::Transporter::Web
+
+GUI for the iTunes Store’s Transporter (iTMSTransporter)
+
+== Overview
+
+=== Job Queue
+
+http://lucas.cis.temple.edu/~sshaw/itmsweb/index.png
+
+=== Job Info
+
+http://lucas.cis.temple.edu/~sshaw/itmsweb/show.png
+
+=== Create a Job
+
+http://lucas.cis.temple.edu/~sshaw/itmsweb/upload.png
@@ -0,0 +1,4 @@
+require File.expand_path('../config/boot.rb', __FILE__)
+require 'padrino-core/cli/rake'
+require 'delayed/tasks'
+PadrinoTasks.init
@@ -0,0 +1,160 @@
+class ItunesStoreTransporterWeb < Padrino::Application
+ use ActiveRecord::ConnectionAdapters::ConnectionManagement
+
+ register Padrino::Rendering
+ register Padrino::Helpers
+ register WillPaginate::Sinatra
+ register BootstrapForms
+
+ enable :sessions
+ set :default_builder, TransporterFormBuilder
+
+ error ActiveRecord::RecordNotFound do
+ "Not Found"
+ end
+
+ # The location where transporter output is saved
+ configure :development do
+ AppConfig.output_log_directory = Padrino.root("tmp")
+ end
+
+ configure :production do
+ AppConfig.output_log_directory = Padrino.root("var/lib/output")
+ end
+
+ before :except => %r|^/job| do
+ @config = AppConfig.instance
+ end
+
+ [:lookup, :providers, :schema, :status, :upload, :verify].each do |route|
+ name = route.capitalize
+
+ get route do
+ form = "#{name}Form".constantize
+ @options = form.new(@config.attributes)
+ render route
+ end
+
+ post route do
+ job = "#{name}Job".constantize
+ form = "#{name}Form".constantize
+
+ @options = form.new(params["#{route}_form"])
+ if @options.valid?
+ @job = job.create!(:options => @options.marshal_dump)
+ flash[:success] = "#{name} job added to the queue."
+ redirect url(:job, :id => @job.id)
+ else
+ render route
+ end
+ end
+ end
+
+ get :config do
+ render :config
+ end
+
+ post :config do
+ # Queued and resubmitted jobs will still have the old transporter path
+ if @config.update_attributes(params[:app_config])
+ flash[:success] = "Configuration saved."
+ redirect to(:config)
+ else
+ render :config
+ end
+ end
+
+ post :browse do
+ @files = params[:dir].present? ?
+ Ls.find(params[:dir], params.slice("type")) :
+ Ls::ROOT
+ render :browse, :layout => false
+ end
+
+ get :jobs, :provides => [:html, :js] do
+ @jobs = TransporterJob.order(order_by).paginate(paging_options)
+ render "jobs/index"
+ end
+
+ get "/jobs/:id/status", :provides => :json do
+ @jobs = TransporterJob.select("state").find(params[:id])
+ @jobs.to_json
+ end
+
+ get "/jobs/:id/results" do
+ @job = TransporterJob.find(params[:id])
+ render_job_result(@job)
+ end
+
+ # %r|/(?:jobs)?| ..!
+ get :job, "/jobs", :with => :id do
+ @job = TransporterJob.find(params[:id])
+ render "jobs/show"
+ end
+
+ delete :job_delete, :map => "/jobs/:id" do
+ @job = TransporterJob.find(params[:id])
+ @job.delete
+ flash[:success] = "Job deleted."
+ redirect :jobs
+ end
+
+ get :job_resubmit, :map => "/jobs/:id/resubmit" do
+ @job = TransporterJob.find(params[:id])
+ @job.resubmit!
+ redirect url(:job, :id => @job.id)
+ end
+
+ get :job_schema, :map => "/jobs/:id/schema", :provides => [:html, :xml] do
+ job = SchemaJob.find(params[:id])
+ if content_type == :html
+ attachment "#{job.target}.rng"
+ end
+
+ content_type(:xml)
+ job.result
+ end
+
+ get :job_metadata, :map => "/jobs/:id/metadata", :provides => [:html, :xml] do
+ job = LookupJob.find(params[:id])
+ if content_type == :html
+ attachment "metadata.xml"
+ end
+
+ content_type(:xml)
+ job.result
+ end
+
+ get :job_output, :map => "/jobs/:id/output", :provides => [:html, :log] do
+ @job = TransporterJob.find(params[:id])
+ data = @job.output(params[:offset].to_i)
+ if content_type == :html
+ filename = "#{@job.type}-Job"
+ filename << "-#{@job.target}" if @job.target.present?
+ attachment filename
+ end
+
+ content_type(:text)
+ data
+ end
+
+ get "/" do
+ redirect :jobs
+ end
+
+ protected
+ def paging_options
+ options = {}
+ options[:page] = params[:page].to_i
+ options[:page] = 1 unless options[:page] > 0
+ options[:per_page] = params[:per_page].to_i
+ options[:per_page] = 20 unless options[:per_page] > 0
+ options
+ end
+
+ def order_by
+ column = TransporterJob.columns_hash.include?(params[:order]) ? params[:order].dup : "created_at"
+ column << " " + (params[:direction] != "asc" ? "desc" : params[:direction])
+ column
+ end
+end
@@ -0,0 +1,48 @@
+require "ostruct"
+require "options"
+
+class JobForm < OpenStruct
+ include ActiveModel::Validations
+ validates_presence_of :username, :password
+ alias :options :marshal_dump
+end
+
+class UploadForm < JobForm
+ include Options::Validations::Upload
+ include Options::Validations::Package
+end
+
+class VerifyForm < JobForm
+ include Options::Validations::Package
+end
+
+class SchemaForm < JobForm
+ validates_presence_of :version_number
+ validates_numericality_of :version_number, :greater_than => 0, :unless => lambda { |form| form.version_number.blank? }
+ validates_inclusion_of :version_name, :in => %w[film tv], :message => "Must be film or TV"
+ validates_inclusion_of :type, :in => %w[transitional strict], :message => "Must be transitional or strict"
+
+ def marshal_dump
+ options = super.except(:version_name, :version_number)
+ options[:version] = [version_name, version_number].compact.join
+ options
+ end
+end
+
+class LookupForm < JobForm
+ validates_presence_of :package_id_value, :message => "You must provide an Apple ID or Vendor ID"
+ validates_inclusion_of :package_id, :in => %w[vendor_id apple_id], :message => "Must be vendor_id or apple_id"
+
+ def marshal_dump
+ options = super.except(:package_id, :package_id_value)
+ options[package_id.to_sym] = package_id_value
+ options
+ end
+end
+
+class StatusForm < JobForm
+ # Without a custom message, the ID is dropped from vendor id
+ validates_presence_of :vendor_id, :message => "ID can't be blank"
+end
+
+class ProvidersForm < JobForm; end
Oops, something went wrong.

0 comments on commit 9f905b1

Please sign in to comment.