Permalink
Browse files

no auth token checking on swfupload, fixed upload progress bug

  • Loading branch information...
1 parent a8d409c commit 20d1401ee97fa4b318f8dcd5ba5b6b0f7347c1f3 Bruno Bornsztein committed Jul 29, 2008
Showing with 15 additions and 25 deletions.
  1. +2 −19 app/controllers/photos_controller.rb
  2. +13 −6 assets/javascripts/uploader.js
@@ -5,7 +5,7 @@ class PhotosController < BaseController
before_filter :find_user, :only => [:new, :edit, :index, :show, :slideshow, :swfupload]
before_filter :require_current_user, :only => [:new, :edit, :update, :destroy, :swfupload]
- skip_before_filter :verify_authenticity_token, :only => :create #because the TinyMCE image uploader can't provide the auth token
+ skip_before_filter :verify_authenticity_token, :only => [:create, :swfupload] #because the TinyMCE image uploader can't provide the auth token
session :cookie_only => false, :only => :swfupload
@@ -185,23 +185,6 @@ def destroy
def slideshow
@xml_file = formatted_user_photos_url( {:user_id => @user, :format => :xml}.merge(:tag_name => params[:tag_name]) )
render :action => 'slideshow'
- end
-
- # protected
- # def require_fake_session
- # raise session[:user].inspect
- # fake_session = ActionController::Base.session
- # @user = Marshal.load(Base64.decode64(fake_session.data))[:user]
- # raise @user.inspect
- #
- # begin
- # fake_session = ActionController::Base.session_store.find_session(params[:_session_id])
- # @user = Marshal.load(Base64.decode64(fake_session.data))[:user]
- # return @user
- # rescue
- # render :nothing => true, :status => 500 and return false
- # end
- # end
-
+ end
end
@@ -10,7 +10,8 @@ CommunityEngine.SwfUpload = Class.create({
file_queue_error_handler : this.fileQueueError.bind(this),
file_dialog_complete_handler : this.fileDialogComplete.bind(this),
file_dialog_start_handler: this.fileDialogStart.bind(this),
- upload_progress_handler : this.uploadProgress,
+ upload_start_handler: this.uploadStart.bind(this),
+ upload_progress_handler : this.uploadProgress.bind(this),
upload_error_handler : this.uploadError.bind(this),
upload_success_handler : this.uploadSuccess.bind(this),
upload_complete_handler : this.uploadComplete.bind(this),
@@ -61,18 +62,24 @@ CommunityEngine.SwfUpload = Class.create({
} catch (ex) { this.swfu.debug(ex); }
},
+ uploadStart: function(fileObj){
+ var progress = new FileProgress(fileObj, this.swfu.customSettings.upload_target);
+ progress.SetStatus("Uploading...");
+ progress.ToggleCancel(true, this.swfu, fileObj.id);
+ },
+
uploadProgress: function(fileObj, bytesLoaded) {
try {
var percent = Math.ceil((bytesLoaded / fileObj.size) * 100)
- var progress = new FileProgress(fileObj, this.customSettings.upload_target);
+ var progress = new FileProgress(fileObj, this.swfu.customSettings.upload_target);
progress.SetProgress(percent);
if (percent === 100) {
progress.SetStatus("Creating thumbnail...");
progress.ToggleCancel(false);
- progress.ToggleCancel(true, this, fileObj.id);
+ progress.ToggleCancel(true, this.swfu, fileObj.id);
} else {
progress.SetStatus("Uploading...");
- progress.ToggleCancel(true, this, fileObj.id);
+ progress.ToggleCancel(true, this.swfu, fileObj.id);
}
} catch (ex) { this.debug(ex); }
},
@@ -98,7 +105,7 @@ CommunityEngine.SwfUpload = Class.create({
} else if(this.swfu.getStats().files_queued > 0) {
this.swfu.startUpload();
} else {
- var progress = new FileProgress(fileObj, this.customSettings.upload_target);
+ var progress = new FileProgress(fileObj, this.swfu.customSettings.upload_target);
progress.SetComplete();
progress.SetStatus("All images received.");
}
@@ -168,7 +175,7 @@ function FileProgress(fileObj, target_id) {
FadeIn(this.fileProgressWrapper, 0);
} else {
- this.fileProgressElement = this.fileProgressWrapper.firstChild;
+ this.fileProgressElement = this.fileProgressWrapper.down('div');
this.fileProgressElement.childNodes[1].firstChild.nodeValue = fileObj.name;
}

0 comments on commit 20d1401

Please sign in to comment.