From b80f0e2ff3a51e6166e4e29b87a7380f42529e7a Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 27 Aug 2005 06:30:33 +0000 Subject: [PATCH] Made Upload Progress work with Prototype 1.4.0 and add some documentation for it #1847, #1876 [Thomas Fuchs/Sean Treadway] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2059 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../lib/action_controller/upload_progress.rb | 52 +++++++++++++++++++ .../helpers/upload_progress_helper.rb | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/upload_progress.rb b/actionpack/lib/action_controller/upload_progress.rb index 6ffe429758..76fdcf4e00 100644 --- a/actionpack/lib/action_controller/upload_progress.rb +++ b/actionpack/lib/action_controller/upload_progress.rb @@ -13,6 +13,9 @@ module ActionController #:nodoc: # fully on all the systems that is a part of your environment. Consider this an extended # preview. # + # To enable this module, add ActionController::Base.enable_upload_progress to your + # config/environment.rb file. + # # == Action Pack Upload Progress for multipart uploads # # The UploadProgress module aids in the process of viewing an Ajax driven @@ -131,6 +134,55 @@ module ActionController #:nodoc: # def custom_status # render :inline => '<%= upload_progress_status %>
Updated at <%= Time.now %>
', :layout => false # end + # + # ==== Environment checklist + # + # This is an experimental feature that requires a specific webserver environment. Use the following checklist + # to confirm that you have an environment that supports upload progress. + # + # ===== Ruby: + # + # * Running the command `ruby -v` should print "ruby 1.8.2 (2004-12-25)" or older + # + # ===== Web server: + # + # * Apache 1.3, Apache 2.0 or Lighttpd *1.4* (need to build lighttpd from CVS) + # + # ===== FastCGI bindings: + # + # * > 0.8.6 and must be the compiled C version of the bindings + # * The command `ruby -e "p require('fcgi.so')"` should print "true" + # + # ===== Apache/Lighttpd FastCGI directives: + # + # * You must allow more than one FCGI server process to allow concurrent requests. + # * If there is only a single FCGI process you will not get the upload status updates. + # * You can check this by taking a look for running FCGI servers in your process list during a progress upload. + # * Apache directive: FastCGIConfig -minProcesses 2 + # * Lighttpd directives taken from config/lighttpd.conf (min-procs): + # + # fastcgi.server = ( + # ".fcgi" => ( + # "APP_NAME" => ( + # "socket" => "/tmp/APP_NAME1.socket", + # "bin-path" => "RAILS_ROOT/public/dispatch.fcgi", + # "min-procs" => 2 + # ) + # ) + # ) + # + # ===== config/environment.rb: + # + # * Add the following line to your config/environment.rb and restart your web server. + # * ActionController::Base.enable_upload_progress + # + # ===== Development log: + # + # * When the upload progress is enabled by you will find something the following lines: + # * "Multipart upload with progress (id: 1, size: 85464)" + # * "Finished processing multipart upload in 0.363729s" + # * If you are properly running multiple FCGI processes, then you will see multiple entries for rendering the "upload_status" action before the "Finish processing..." log entry. This is a *good thing* :) + # module UploadProgress def self.append_features(base) #:nodoc: super diff --git a/actionpack/lib/action_view/helpers/upload_progress_helper.rb b/actionpack/lib/action_view/helpers/upload_progress_helper.rb index 04b14c0c17..8563ca3beb 100644 --- a/actionpack/lib/action_view/helpers/upload_progress_helper.rb +++ b/actionpack/lib/action_view/helpers/upload_progress_helper.rb @@ -196,7 +196,7 @@ module ActionView updater = "if (#{upload_update_object}) { #{upload_update_object}.stop(); }" updater << "#{upload_update_object} = new Ajax.PeriodicalUpdater('#{status_tag_id}'," - updater << "'#{status_url}', #{options_for_ajax(options)}.extend(#{updater_options}))" + updater << "'#{status_url}', Object.extend(#{options_for_ajax(options)},#{updater_options}))" updater = "#{options[:begin]}; #{updater}" if options[:begin] updater = "#{upload_progress_update_bar_js(0)}; #{updater}"