phocoder-rails 0.0.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. data/.autotest +46 -0
  2. data/.document +5 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +44 -0
  5. data/LICENSE.txt +20 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.rdoc +3 -0
  8. data/Rakefile +56 -0
  9. data/VERSION +5 -0
  10. data/app/controllers/phocoder_controller.rb +118 -0
  11. data/app/helpers/phocoder_helper.rb +320 -0
  12. data/app/models/encodable_job.rb +91 -0
  13. data/app/views/phocoder/_offline_video_embed.html.erb +19 -0
  14. data/app/views/phocoder/_thumbnail_update.html.erb +3 -0
  15. data/app/views/phocoder/_video_embed.html.erb +23 -0
  16. data/app/views/phocoder/multi_thumbnail_update.json.erb +7 -0
  17. data/app/views/phocoder/thumbnail_update.js.erb +9 -0
  18. data/config/routes.rb +8 -0
  19. data/lib/generators/phocoder_rails/model_update_generator.rb +52 -0
  20. data/lib/generators/phocoder_rails/scaffold_generator.rb +94 -0
  21. data/lib/generators/phocoder_rails/setup_generator.rb +33 -0
  22. data/lib/generators/phocoder_rails/templates/controller.rb +71 -0
  23. data/lib/generators/phocoder_rails/templates/helper.rb +5 -0
  24. data/lib/generators/phocoder_rails/templates/migration.rb +24 -0
  25. data/lib/generators/phocoder_rails/templates/model.rb +20 -0
  26. data/lib/generators/phocoder_rails/templates/model_migration.rb +56 -0
  27. data/lib/generators/phocoder_rails/templates/model_thumbnail.rb +5 -0
  28. data/lib/generators/phocoder_rails/templates/model_update_migration.rb +64 -0
  29. data/lib/generators/phocoder_rails/templates/phocodable.yml +28 -0
  30. data/lib/generators/phocoder_rails/templates/views/_form.html.erb.tt +23 -0
  31. data/lib/generators/phocoder_rails/templates/views/index.html.erb.tt +26 -0
  32. data/lib/generators/phocoder_rails/templates/views/new.html.erb.tt +5 -0
  33. data/lib/generators/phocoder_rails/templates/views/show.html.erb.tt +12 -0
  34. data/lib/phocoder_rails.rb +12 -0
  35. data/lib/phocoder_rails/acts_as_phocodable.rb +1153 -0
  36. data/lib/phocoder_rails/engine.rb +24 -0
  37. data/lib/phocoder_rails/errors.rb +46 -0
  38. data/phocoder-rails.gemspec +219 -0
  39. data/public/images/building.gif +0 -0
  40. data/public/images/error.png +0 -0
  41. data/public/images/play_small.png +0 -0
  42. data/public/images/storing.gif +0 -0
  43. data/public/images/waiting.gif +0 -0
  44. data/public/javascripts/phocodable.js +110 -0
  45. data/public/javascripts/video-js-2.0.2/.DS_Store +0 -0
  46. data/public/javascripts/video-js-2.0.2/LICENSE.txt +165 -0
  47. data/public/javascripts/video-js-2.0.2/README.markdown +202 -0
  48. data/public/javascripts/video-js-2.0.2/demo-subtitles.srt +13 -0
  49. data/public/javascripts/video-js-2.0.2/demo.html +101 -0
  50. data/public/javascripts/video-js-2.0.2/skins/hu.css +116 -0
  51. data/public/javascripts/video-js-2.0.2/skins/tube.css +111 -0
  52. data/public/javascripts/video-js-2.0.2/skins/vim.css +89 -0
  53. data/public/javascripts/video-js-2.0.2/video-js.css +242 -0
  54. data/public/javascripts/video-js-2.0.2/video.js +1758 -0
  55. data/public/stylesheets/phocodable.css +19 -0
  56. data/spec/controllers/phocoder_controller_spec.rb +123 -0
  57. data/spec/dummy/Rakefile +7 -0
  58. data/spec/dummy/app/controllers/application_controller.rb +7 -0
  59. data/spec/dummy/app/controllers/images_controller.rb +72 -0
  60. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  61. data/spec/dummy/app/helpers/images_helper.rb +5 -0
  62. data/spec/dummy/app/models/image.rb +20 -0
  63. data/spec/dummy/app/models/image_thumbnail.rb +5 -0
  64. data/spec/dummy/app/models/image_upload.rb +11 -0
  65. data/spec/dummy/app/views/images/_form.html.erb +23 -0
  66. data/spec/dummy/app/views/images/index.html.erb +26 -0
  67. data/spec/dummy/app/views/images/new.html.erb +5 -0
  68. data/spec/dummy/app/views/images/show.html.erb +12 -0
  69. data/spec/dummy/app/views/layouts/application.html.erb +18 -0
  70. data/spec/dummy/config.ru +4 -0
  71. data/spec/dummy/config/application.rb +45 -0
  72. data/spec/dummy/config/boot.rb +10 -0
  73. data/spec/dummy/config/database.yml +25 -0
  74. data/spec/dummy/config/environment.rb +8 -0
  75. data/spec/dummy/config/environments/development.rb +26 -0
  76. data/spec/dummy/config/environments/production.rb +49 -0
  77. data/spec/dummy/config/environments/test.rb +40 -0
  78. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  79. data/spec/dummy/config/initializers/inflections.rb +10 -0
  80. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  81. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  82. data/spec/dummy/config/initializers/session_store.rb +8 -0
  83. data/spec/dummy/config/locales/en.yml +5 -0
  84. data/spec/dummy/config/routes.rb +60 -0
  85. data/spec/dummy/db/migrate/001_create_image_uploads.rb +37 -0
  86. data/spec/dummy/db/migrate/20110523165213_add_parent_type_to_image_uploads.rb +11 -0
  87. data/spec/dummy/db/migrate/20110523165522_create_encodable_jobs.rb +24 -0
  88. data/spec/dummy/db/migrate/20111101024507_create_images.rb +56 -0
  89. data/spec/dummy/db/schema.rb +99 -0
  90. data/spec/dummy/public/404.html +26 -0
  91. data/spec/dummy/public/422.html +26 -0
  92. data/spec/dummy/public/500.html +26 -0
  93. data/spec/dummy/public/favicon.ico +0 -0
  94. data/spec/dummy/public/index.html +239 -0
  95. data/spec/dummy/public/javascripts/application.js +2 -0
  96. data/spec/dummy/public/javascripts/controls.js +965 -0
  97. data/spec/dummy/public/javascripts/dragdrop.js +974 -0
  98. data/spec/dummy/public/javascripts/effects.js +1123 -0
  99. data/spec/dummy/public/javascripts/jquery-1.6.4.js +9046 -0
  100. data/spec/dummy/public/javascripts/prototype.js +6001 -0
  101. data/spec/dummy/public/javascripts/rails.js +175 -0
  102. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  103. data/spec/dummy/script/rails +6 -0
  104. data/spec/engine_spec.rb +12 -0
  105. data/spec/fixtures/big_eye_tiny.jpg +0 -0
  106. data/spec/fixtures/octologo.png +0 -0
  107. data/spec/fixtures/test.txt +2 -0
  108. data/spec/fixtures/video-test.mov +0 -0
  109. data/spec/helpers/phocoder_helper_spec.rb +421 -0
  110. data/spec/integration/navigation_spec.rb +10 -0
  111. data/spec/models/acts_as_phocodable_spec.rb +664 -0
  112. data/spec/models/encodable_job_spec.rb +50 -0
  113. data/spec/phocoder_rails_spec.rb +8 -0
  114. data/spec/routing/phocoder_routing_spec.rb +19 -0
  115. data/spec/spec_helper.rb +75 -0
  116. metadata +375 -0
@@ -0,0 +1,91 @@
1
+ class EncodableJob < ActiveRecord::Base
2
+
3
+ belongs_to :encodable, :polymorphic=>true
4
+
5
+ def self.update_from_phocoder(params)
6
+ Rails.logger.debug "tying to call update from phocoder for params = #{params.to_json}"
7
+ puts "tying to call update from phocoder for params = #{params.to_json}"
8
+ if !params[:output].blank?
9
+ Rails.logger.debug "find_by_phocoder_job_id_and_phocoder_output_id_and_encodable_type #{params[:job][:id]} - #{params[:output][:id]} ,#{params[:class]}"
10
+ puts "find_by_phocoder_job_id_and_phocoder_output_id_and_encodable_type #{params[:job][:id]} - #{params[:output][:id]} ,#{params[:class]}"
11
+ job = self.find_by_phocoder_job_id_and_phocoder_output_id_and_encodable_type params[:job][:id],params[:output][:id],params[:class]
12
+
13
+
14
+ Rails.logger.debug "the job = #{job}"
15
+ img_params = params[:output]
16
+ begin
17
+ encodable = job.encodable
18
+ rescue NoMethodError => ex
19
+ # here we try to fall back if we can't find an Encodable
20
+ encodable = params[:class].constantize.find params[:id]
21
+ end
22
+ encodable.filename = File.basename(params[:output][:url]) if encodable.filename.blank?
23
+ if ActsAsPhocodable.storeage_mode == "local"
24
+ encodable.save_url(params[:output][:url])
25
+ end
26
+ else
27
+ puts "find_by_phocoder_job_id_and_phocoder_input_id_and_encodable_type #{params[:job][:id]}, #{params[:input][:id]}, #{params[:class]}"
28
+ job = find_by_phocoder_job_id_and_phocoder_input_id_and_encodable_type params[:job][:id],params[:input][:id],params[:class]
29
+ puts "found job = #{job.to_json}"
30
+ puts "job.encodable = #{job.encodable}"
31
+ img_params = params[:input]
32
+ encodable = job.encodable
33
+ end
34
+ [:file_size,:width,:height,:taken_at,:lat,:lng,:saturated_pixels,:gauss].each do |att|
35
+ setter = att.to_s + "="
36
+ if encodable.respond_to? setter and !img_params[att].blank?
37
+ encodable.send setter, img_params[att]
38
+ end
39
+ end
40
+
41
+ #job.file_size = img_params[:file_size]
42
+ #job.width = img_params[:width]
43
+ #job.height = img_params[:height]
44
+ encodable.encodable_status = "ready"
45
+ encodable.save
46
+ encodable.fire_ready_callback
47
+ # may not have a job if the EncodableJob didn't get created for some reason
48
+ if job
49
+ job.phocoder_status = "ready"
50
+ job.save
51
+ job
52
+ end
53
+ end
54
+
55
+
56
+
57
+ # Updating from zencoder is a two pass operation.
58
+ # This method gets called for each output when it's ready.
59
+ # Once all outputs are ready, we call parent.check_zencoder_details
60
+ def self.update_from_zencoder(params)
61
+ Rails.logger.debug "tying to call update from zencoder for params = #{params}"
62
+ job = find_by_zencoder_output_id params[:output][:id]
63
+ encodable = job.encodable
64
+ if params[:output][:url].match /%2F(.*)\?/
65
+ encodable.filename = $1
66
+ else
67
+ encodable.filename = File.basename(params[:output][:url].match(/(.*)\??/)[1])
68
+ end
69
+ #job.filename = File.basename(params[:output][:url].match(/(.*)\??/)[1]) if job.filename.blank?
70
+ if ActsAsPhocodable.storeage_mode == "local"
71
+ encodable.save_url(params[:output][:url])
72
+ end
73
+ job.zencoder_status = encodable.encodable_status = "ready"
74
+ encodable.save
75
+ encodable.fire_ready_callback
76
+ job.save
77
+ puts "~~~~~~~~~~~~~~~~~~~~` #{encodable.to_json}"
78
+
79
+ if encodable.parent
80
+ puts " WE NEED TO CHECK ON PARENT on #{encodable.to_json}"
81
+ encodable.parent.check_zencoder_details
82
+ #else
83
+ # puts " WE NEED TO CHECK OUR SELF!"
84
+ # encodable.check_zencoder_details
85
+ end
86
+ end
87
+
88
+
89
+
90
+
91
+ end
@@ -0,0 +1,19 @@
1
+ <!-- Begin VideoJS -->
2
+ <div class="video-js-box vim-css">
3
+ <!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
4
+ <video class="video-js" width="<%=width%>" height="<%=height%>" controls preload poster="<%= video.get_thumbnail('poster').public_url %>">
5
+ <source src="<%= video.public_url %>">
6
+ <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
7
+ <object class="vjs-flash-fallback" width="<%=width%>" height="<%=height%>" type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
8
+ <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" /><param name="allowfullscreen" value="true" /><param name="flashvars" value='config={"playlist":["<%= video.get_thumbnail('poster').public_url %>", {"url": "<%= video.public_url %>","autoPlay":false,"autoBuffering":true}]}' /><!-- Image Fallback. Typically the same as the poster image. --><img src="<%= video.get_thumbnail('poster').public_url %>" width="<%=width%>" height="<%=height%>" alt="Poster Image" title="No video playback capabilities." />
9
+ </object>
10
+ </video><!-- Download links provided for devices that can't play video in the browser. -->
11
+ <p class="vjs-no-video">
12
+ <strong>Download Video:</strong>
13
+ <a href="<%= video.public_url %>">Original</a>
14
+ <br>
15
+ <!-- Support VideoJS by keeping this link. --><a href="http://videojs.com">HTML5 Video Player</a>
16
+ by VideoJS
17
+ </p>
18
+ </div>
19
+ <!-- End VideoJS -->
@@ -0,0 +1,3 @@
1
+ <%=
2
+ phocoder_thumbnail(@img,params[:thumbnail],params[:live_video],{})
3
+ %>
@@ -0,0 +1,23 @@
1
+ <!-- Begin VideoJS -->
2
+ <div class="video-js-box vim-css">
3
+ <!-- Using the Video for Everybody Embed Code http://camendesign.com/code/video_for_everybody -->
4
+ <video class="video-js" width="<%=width%>" height="<%=height%>" controls preload poster="<%= video.get_thumbnail('poster').public_url %>">
5
+ <source src="<%= video.get_thumbnail('mp4').public_url %>" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'>
6
+ <source src="<%= video.get_thumbnail('webm').public_url %>" type='video/webm; codecs="vp8, vorbis"'>
7
+ <source src="<%= video.get_thumbnail('ogv').public_url %>" type='video/ogg; codecs="theora, vorbis"'>
8
+ <!-- Flash Fallback. Use any flash video player here. Make sure to keep the vjs-flash-fallback class. -->
9
+ <object class="vjs-flash-fallback" width="<%=width%>" height="<%=height%>" type="application/x-shockwave-flash" data="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf">
10
+ <param name="movie" value="http://releases.flowplayer.org/swf/flowplayer-3.2.1.swf" /><param name="allowfullscreen" value="true" /><param name="flashvars" value='config={"playlist":["<%= video.get_thumbnail('poster').public_url %>", {"url": "<%= video.get_thumbnail('mp4').public_url %>","autoPlay":false,"autoBuffering":true}]}' /><!-- Image Fallback. Typically the same as the poster image. --><img src="<%= video.get_thumbnail('poster').public_url %>" width="<%=width%>" height="<%=height%>" alt="Poster Image" title="No video playback capabilities." />
11
+ </object>
12
+ </video><!-- Download links provided for devices that can't play video in the browser. -->
13
+ <p class="vjs-no-video">
14
+ <strong>Download Video:</strong>
15
+ <a href="<%= video.get_thumbnail('mp4').public_url %>">MP4</a>,
16
+ <a href="<%= video.get_thumbnail('webm').public_url %>">WebM</a>,
17
+ <a href="<%= video.get_thumbnail('ogv').public_url %>">Ogg</a>
18
+ <br>
19
+ <!-- Support VideoJS by keeping this link. --><a href="http://videojs.com">HTML5 Video Player</a>
20
+ by VideoJS
21
+ </p>
22
+ </div>
23
+ <!-- End VideoJS -->
@@ -0,0 +1,7 @@
1
+ {
2
+ <% @outputs.each_with_index do |output,i| %>
3
+ <% @img = output[:encodable] %>
4
+ <% @random = output[:random] %>
5
+ "<%= output[:elem_id] %>" : "<%= escape_javascript(render(:partial=>"thumbnail_update.html.erb", :locals => {:params => output} )) %>" <%= "," if i != @outputs.size %>
6
+ <% end %>
7
+ }
@@ -0,0 +1,9 @@
1
+ <% if ActsAsPhocodable.javascript_library == 'prototype' %>
2
+
3
+ $("<%= @img.class.to_s %>_<%= @img.id.to_s %>_<%= @random %>").replace("<%= escape_javascript(render(:partial=>"thumbnail_update")) %>")
4
+
5
+ <% else %>
6
+
7
+ $('#<%= @img.class.to_s %>_<%= @img.id.to_s %>_<%= @random %>').replaceWith("<%= escape_javascript(render(:partial=>"thumbnail_update")) %>")
8
+
9
+ <% end %>
data/config/routes.rb ADDED
@@ -0,0 +1,8 @@
1
+ Rails.application.routes.draw do
2
+
3
+ match "phocoder/phocoder_notifications/:class/:id", :to=>"phocoder#phocoder_notification_update", :via=>:post
4
+ match "phocoder/zencoder_notifications/:class/:id", :to=>"phocoder#zencoder_notification_update", :via=>:post
5
+ match "phocoder/thumbnail_update", :to=>"phocoder#thumbnail_update", :via=>:post
6
+ match "phocoder/multi_thumbnail_update", :to=>"phocoder#multi_thumbnail_update", :via=>:post
7
+
8
+ end
@@ -0,0 +1,52 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ module PhocoderRails
4
+ module Generators
5
+
6
+ class ModelUpdateGenerator < Rails::Generators::NamedBase
7
+
8
+ include Rails::Generators::Migration
9
+
10
+ #argument :model_names, :type => :array, :default => [], :banner => "action action"
11
+ #check_class_collision :suffix => "PhocoderRails"
12
+
13
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
14
+
15
+ def self.next_migration_number(dirname)
16
+ if ActiveRecord::Base.timestamped_migrations
17
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
18
+ else
19
+ "%.3d" % (current_migration_number(dirname) + 1)
20
+ end
21
+ end
22
+
23
+ def create_migration_file
24
+ migration_template 'model_update_migration.rb', "db/migrate/make_#{file_name.pluralize}_encodable.rb"
25
+ #migration_template 'model_thumbnail_migration.rb', "db/migrate/create_#{file_name.singularize}_thumbnails.rb"
26
+ end
27
+
28
+ def create_model_file
29
+ #template 'model.rb', File.join('app/models', class_path, "#{file_name.singularize}.rb")
30
+ template 'model_thumbnail.rb', File.join('app/models', class_path, "#{file_name.singularize}_thumbnail.rb")
31
+ end
32
+
33
+
34
+ protected
35
+
36
+ #def create_views_for(engine)
37
+ # for state in model_names do
38
+ # @state = state
39
+ # @path = File.join('app/cells', file_name, "#{state}.html.#{engine}")
40
+ #
41
+ # template "view.#{engine}", @path
42
+ # end
43
+ #end
44
+
45
+
46
+
47
+
48
+ end
49
+
50
+ end
51
+ end
52
+
@@ -0,0 +1,94 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ module PhocoderRails
4
+ module Generators
5
+
6
+ class ScaffoldGenerator < Rails::Generators::NamedBase
7
+
8
+ include Rails::Generators::Migration
9
+
10
+ #argument :model_names, :type => :array, :default => [], :banner => "action action"
11
+ #check_class_collision :suffix => "PhocoderRails"
12
+
13
+ source_root File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
14
+
15
+ def self.next_migration_number(dirname)
16
+ if ActiveRecord::Base.timestamped_migrations
17
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
18
+ else
19
+ "%.3d" % (current_migration_number(dirname) + 1)
20
+ end
21
+ end
22
+
23
+ def create_migration_file
24
+ migration_template 'model_migration.rb', "db/migrate/create_#{file_name.pluralize}.rb"
25
+ #migration_template 'model_thumbnail_migration.rb', "db/migrate/create_#{file_name.singularize}_thumbnails.rb"
26
+ end
27
+
28
+ def create_model_file
29
+ template 'model.rb', File.join('app/models', class_path, "#{file_name.singularize}.rb")
30
+ template 'model_thumbnail.rb', File.join('app/models', class_path, "#{file_name.singularize}_thumbnail.rb")
31
+ end
32
+
33
+ def create_helper_file
34
+ template 'helper.rb', File.join('app/helpers', class_path, "#{file_name.pluralize}_helper.rb")
35
+ end
36
+
37
+ def create_controller_file
38
+ template 'controller.rb', File.join('app/controllers', class_path, "#{file_name.pluralize}_controller.rb")
39
+ end
40
+
41
+ def create_views
42
+ directory 'views', File.join('app/views', class_path, "#{file_name.pluralize}" )
43
+ #["_form.html.erb","index.html.erb","new.html.erb","show.html.erb"].each do |view|
44
+ # template "views/#{view}", File.join('app/views', class_path, "#{file_name.pluralize}", view )
45
+ #end
46
+ end
47
+
48
+ def create_route
49
+ route("resources :#{file_name.pluralize}, :except=>[:edit,:update]")
50
+ end
51
+
52
+ #class_option :view_engine, :type => :string, :aliases => "-t", :desc => "Template engine for the views. Available options are 'erb' and 'haml'.", :default => "erb"
53
+ #class_option :haml, :type => :boolean, :default => false
54
+
55
+ def do_a_thing
56
+ puts "We are doing a thing!!!!!!!!!!!!!!!! #{file_name}"
57
+ end
58
+
59
+ #def create_cell_file
60
+ # template 'cell.rb', File.join('app/cells', class_path, "#{file_name}_cell.rb")
61
+ #end
62
+
63
+ #def create_views
64
+ # if options[:view_engine].to_s == "haml" or options[:haml]
65
+ # create_views_for(:haml)
66
+ # else
67
+ # create_views_for(:erb)
68
+ # end
69
+ #end
70
+
71
+ #def create_test
72
+ # @states = model_names
73
+ # template 'cell_test.rb', File.join('test/cells/', "#{file_name}_cell_test.rb")
74
+ #end
75
+
76
+ protected
77
+
78
+ #def create_views_for(engine)
79
+ # for state in model_names do
80
+ # @state = state
81
+ # @path = File.join('app/cells', file_name, "#{state}.html.#{engine}")
82
+ #
83
+ # template "view.#{engine}", @path
84
+ # end
85
+ #end
86
+
87
+
88
+
89
+
90
+ end
91
+
92
+ end
93
+ end
94
+
@@ -0,0 +1,33 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ module PhocoderRails
4
+ module Generators
5
+
6
+ class SetupGenerator < Rails::Generators::Base
7
+
8
+ include Rails::Generators::Migration
9
+ def self.source_root
10
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
11
+ end
12
+
13
+ def self.next_migration_number(dirname)
14
+ if ActiveRecord::Base.timestamped_migrations
15
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
16
+ else
17
+ "%.3d" % (current_migration_number(dirname) + 1)
18
+ end
19
+ end
20
+
21
+ def create_migration_file
22
+ migration_template 'migration.rb', 'db/migrate/create_encodable_jobs.rb'
23
+ end
24
+
25
+ def create_config_file
26
+ template 'phocodable.yml', File.join('config','phocodable.yml')
27
+ end
28
+
29
+ end
30
+
31
+ end
32
+ end
33
+
@@ -0,0 +1,71 @@
1
+ class <%= name.classify.pluralize %>Controller < ApplicationController
2
+
3
+ # This example does not handle all of the ins and outs of
4
+ # allowing someone to 'replace' a file by edit/update.
5
+ # That's a sticky problem that would only cloud
6
+ # the concepts we're demonstrating here.
7
+
8
+
9
+ # GET /<%= name.pluralize %>
10
+ # GET /<%= name.pluralize %>.xml
11
+ def index
12
+ @<%= name.pluralize %> = <%= name.classify %>.top_level.all
13
+
14
+ respond_to do |format|
15
+ format.html # index.html.erb
16
+ format.xml { render :xml => @<%= name.pluralize %> }
17
+ end
18
+ end
19
+
20
+ # GET /<%= name.pluralize %>/1
21
+ # GET /<%= name.pluralize %>/1.xml
22
+ def show
23
+ @<%= name.singularize %> = <%= name.classify %>.find(params[:id])
24
+
25
+ respond_to do |format|
26
+ format.html # show.html.erb
27
+ format.xml { render :xml => @<%= name.singularize %> }
28
+ end
29
+ end
30
+
31
+ # GET /<%= name.pluralize %>/new
32
+ # GET /<%= name.pluralize %>/new.xml
33
+ def new
34
+ @<%= name.singularize %> = <%= name.classify %>.new
35
+
36
+ respond_to do |format|
37
+ format.html # new.html.erb
38
+ format.xml { render :xml => @<%= name.singularize %> }
39
+ end
40
+ end
41
+
42
+
43
+ # POST /<%= name.pluralize %>
44
+ # POST /<%= name.pluralize %>.xml
45
+ def create
46
+ @<%= name.singularize %> = <%= name.classify %>.new(params[:<%= name.singularize %>])
47
+
48
+ respond_to do |format|
49
+ if @<%= name.singularize %>.save
50
+ format.html { redirect_to(@<%= name.singularize %>, :notice => "<%= name.classify %> was successfully created.") }
51
+ format.xml { render :xml => @<%= name.singularize %>, :status => :created, :location => @<%= name.singularize %> }
52
+ else
53
+ format.html { render :action => "new" }
54
+ format.xml { render :xml => @<%= name.singularize %>.errors, :status => :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+
60
+ # DELETE /<%= name.pluralize %>/1
61
+ # DELETE /<%= name.pluralize %>/1.xml
62
+ def destroy
63
+ @<%= name.singularize %> = <%= name.classify %>.find(params[:id])
64
+ @<%= name.singularize %>.destroy
65
+
66
+ respond_to do |format|
67
+ format.html { redirect_to(<%= name.pluralize %>_url) }
68
+ format.xml { head :ok }
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,5 @@
1
+ module <%= name.classify.pluralize %>Helper
2
+
3
+
4
+
5
+ end
@@ -0,0 +1,24 @@
1
+ class CreateEncodableJobs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :encodable_jobs do |t|
4
+ t.string "encodable_type"
5
+ t.integer "encodable_id"
6
+ t.integer "phocoder_job_id"
7
+ t.integer "phocoder_input_id"
8
+ t.integer "phocoder_output_id"
9
+ t.string "phocoder_status"
10
+ t.integer "zencoder_job_id"
11
+ t.integer "zencoder_input_id"
12
+ t.integer "zencoder_output_id"
13
+ t.string "zencoder_status"
14
+ t.string "zencoder_url"
15
+ t.timestamps
16
+ end
17
+ add_index :encodable_jobs, [:encodable_type, :encodable_id]
18
+ add_index :encodable_jobs, :id
19
+ end
20
+
21
+ def self.down
22
+ drop_table :encodable_jobs
23
+ end
24
+ end