diff options
Diffstat (limited to 'projects/mongrel_upload_progress')
-rw-r--r-- | projects/mongrel_upload_progress/CHANGELOG | 2 | ||||
-rw-r--r-- | projects/mongrel_upload_progress/COPYING | 1 | ||||
-rw-r--r-- | projects/mongrel_upload_progress/LICENSE | 55 | ||||
-rw-r--r-- | projects/mongrel_upload_progress/Manifest | 7 | ||||
-rw-r--r-- | projects/mongrel_upload_progress/README | 5 | ||||
-rw-r--r-- | projects/mongrel_upload_progress/Rakefile | 15 | ||||
-rw-r--r-- | projects/mongrel_upload_progress/lib/mongrel_upload_progress/init.rb | 90 | ||||
-rw-r--r-- | projects/mongrel_upload_progress/resources/defaults.yaml | 3 |
8 files changed, 0 insertions, 178 deletions
diff --git a/projects/mongrel_upload_progress/CHANGELOG b/projects/mongrel_upload_progress/CHANGELOG deleted file mode 100644 index e3b4b88..0000000 --- a/projects/mongrel_upload_progress/CHANGELOG +++ /dev/null @@ -1,2 +0,0 @@ - -v0.2.2. Signed gem. diff --git a/projects/mongrel_upload_progress/COPYING b/projects/mongrel_upload_progress/COPYING deleted file mode 100644 index bff74f4..0000000 --- a/projects/mongrel_upload_progress/COPYING +++ /dev/null @@ -1 +0,0 @@ -No copying restrictions/license given.
\ No newline at end of file diff --git a/projects/mongrel_upload_progress/LICENSE b/projects/mongrel_upload_progress/LICENSE deleted file mode 100644 index e5a926e..0000000 --- a/projects/mongrel_upload_progress/LICENSE +++ /dev/null @@ -1,55 +0,0 @@ -Mongrel Web Server (Mongrel) is copyrighted free software by Zed A. Shaw -<zedshaw at zedshaw dot com> and contributors. You can redistribute it -and/or modify it under either the terms of the GPL2 or the conditions below: - -1. You may make and give away verbatim copies of the source form of the - software without restriction, provided that you duplicate all of the - original copyright notices and associated disclaimers. - -2. You may modify your copy of the software in any way, provided that - you do at least ONE of the following: - - a) place your modifications in the Public Domain or otherwise make them - Freely Available, such as by posting said modifications to Usenet or an - equivalent medium, or by allowing the author to include your - modifications in the software. - - b) use the modified software only within your corporation or - organization. - - c) rename any non-standard executables so the names do not conflict with - standard executables, which must also be provided. - - d) make other distribution arrangements with the author. - -3. You may distribute the software in object code or executable - form, provided that you do at least ONE of the following: - - a) distribute the executables and library files of the software, - together with instructions (in the manual page or equivalent) on where - to get the original distribution. - - b) accompany the distribution with the machine-readable source of the - software. - - c) give non-standard executables non-standard names, with - instructions on where to get the original software distribution. - - d) make other distribution arrangements with the author. - -4. You may modify and include the part of the software into any other - software (possibly commercial). But some files in the distribution - are not written by the author, so that they are not under this terms. - -5. The scripts and library files supplied as input to or produced as - output from the software do not automatically fall under the - copyright of the software, but belong to whomever generated them, - and may be sold commercially, and may be aggregated with this - software. - -6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - PURPOSE. - - diff --git a/projects/mongrel_upload_progress/Manifest b/projects/mongrel_upload_progress/Manifest deleted file mode 100644 index e2a2e8b..0000000 --- a/projects/mongrel_upload_progress/Manifest +++ /dev/null @@ -1,7 +0,0 @@ -resources/defaults.yaml -README -Manifest -LICENSE -lib/mongrel_upload_progress/init.rb -COPYING -CHANGELOG diff --git a/projects/mongrel_upload_progress/README b/projects/mongrel_upload_progress/README deleted file mode 100644 index 7014ec3..0000000 --- a/projects/mongrel_upload_progress/README +++ /dev/null @@ -1,5 +0,0 @@ -== Mongrel_upload_progress GemPlugin - -You should document your project here. - - diff --git a/projects/mongrel_upload_progress/Rakefile b/projects/mongrel_upload_progress/Rakefile deleted file mode 100644 index 23b337e..0000000 --- a/projects/mongrel_upload_progress/Rakefile +++ /dev/null @@ -1,15 +0,0 @@ - -require 'echoe' - -Echoe.new("mongrel_upload_progress") do |p| - p.summary = "The mongrel_upload_progress gemplugin" - p.project = "mongrel" - p.author="The Mongrel team" - p.dependencies = ['mongrel >=0.3.13.3', 'gem_plugin >=0.2.1'] - - p.need_tar_gz = false - p.need_tgz = true - p.certificate_chain = ['~/p/configuration/gem_certificates/mongrel/mongrel-public_cert.pem', - '~/p/configuration/gem_certificates/evan_weaver-mongrel-public_cert.pem'] - p.require_signed = true -end diff --git a/projects/mongrel_upload_progress/lib/mongrel_upload_progress/init.rb b/projects/mongrel_upload_progress/lib/mongrel_upload_progress/init.rb deleted file mode 100644 index 5ef1f7e..0000000 --- a/projects/mongrel_upload_progress/lib/mongrel_upload_progress/init.rb +++ /dev/null @@ -1,90 +0,0 @@ -require 'mongrel' -require 'gem_plugin' - -class Upload < GemPlugin::Plugin "/handlers" - include Mongrel::HttpHandlerPlugin - - def initialize(options = {}) - @path_info = Array(options[:path_info]) - @frequency = options[:frequency] || 3 - @request_notify = true - if options[:drb] - require 'drb' - DRb.start_service - Mongrel.const_set :Uploads, DRbObject.new(nil, options[:drb]) - else - Mongrel.const_set :Uploads, Mongrel::UploadProgress.new - end - Mongrel::Uploads.debug = true if options[:debug] - end - - def request_begins(params) - upload_notify(:add, params, params[Mongrel::Const::CONTENT_LENGTH].to_i) - end - - def request_progress(params, clen, total) - upload_notify(:mark, params, clen) - end - - def process(request, response) - upload_notify(:finish, request.params) - end - - private - def upload_notify(action, params, *args) - return unless @path_info.include?(params['PATH_INFO']) && - params[Mongrel::Const::REQUEST_METHOD] == 'POST' && - upload_id = Mongrel::HttpRequest.query_parse(params['QUERY_STRING'])['upload_id'] - if action == :mark - last_checked_time = Mongrel::Uploads.last_checked(upload_id) - return unless last_checked_time && Time.now - last_checked_time > @frequency - end - Mongrel::Uploads.send(action, upload_id, *args) - Mongrel::Uploads.update_checked_time(upload_id) unless action == :finish - end -end - -# Keeps track of the status of all currently processing uploads -class Mongrel::UploadProgress - attr_accessor :debug - def initialize - @guard = Mutex.new - @counters = {} - end - - def check(upid) - @counters[upid].last rescue nil - end - - def last_checked(upid) - @counters[upid].first rescue nil - end - - def update_checked_time(upid) - @guard.synchronize { @counters[upid][0] = Time.now } - end - - def add(upid, size) - @guard.synchronize do - @counters[upid] = [Time.now, {:size => size, :received => 0}] - puts "#{upid}: Added" if @debug - end - end - - def mark(upid, len) - return unless status = check(upid) - puts "#{upid}: Marking" if @debug - @guard.synchronize { status[:received] = status[:size] - len } - end - - def finish(upid) - @guard.synchronize do - puts "#{upid}: Finished" if @debug - @counters.delete(upid) - end - end - - def list - @counters.keys.sort - end -end
\ No newline at end of file diff --git a/projects/mongrel_upload_progress/resources/defaults.yaml b/projects/mongrel_upload_progress/resources/defaults.yaml deleted file mode 100644 index beb3c6d..0000000 --- a/projects/mongrel_upload_progress/resources/defaults.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -:debug: false -:upload_path: 'tmp/uploads'
\ No newline at end of file |