Permalink
Browse files

initial import

  • Loading branch information...
0 parents commit ebd539af8d209b2e781693e8236ff15435fc761c @ksylvest committed Dec 10, 2010
@@ -0,0 +1,3 @@
+.bundle
+log/*
+tmp/*
@@ -0,0 +1,3 @@
+*.ai
+*.psd
+doc
@@ -0,0 +1,3 @@
+source 'http://rubygems.org'
+
+gem 'sinatra'
@@ -0,0 +1,14 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ rack (1.2.1)
+ sinatra (1.1.0)
+ rack (~> 1.1)
+ tilt (~> 1.1)
+ tilt (1.1)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ sinatra
20 LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2010 Kevin Sylvestre
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
+= Transfer HQ
+
+Transfer HQ is a Sinatra application for providing file transfers directly to the cloud. The applications supports uploading a file using a HTML or Flash uploader (even across domains) and will take care of copying into the cloud.
50 app.rb
@@ -0,0 +1,50 @@
+require 'rubygems'
+require 'sinatra'
+
+configure do
+ class << Sinatra::Base
+ def options(path, opts={}, &block)
+ route 'OPTIONS', path, opts, &block
+ end
+ end
+ Sinatra::Delegator.delegate :options
+end
+
+options '/' do
+ response.headers["Access-Control-Allow-Origin"] = "*"
+ response.headers["Access-Control-Allow-Methods"] = "POST"
+end
+
+get '/' do
+ erb :index
+end
+
+get '/about' do
+ erb :about
+end
+
+get '/terms' do
+ erb :terms
+end
+
+get '/new' do
+ erb :new
+end
+
+post '/' do
+ path = params[:path]
+ file = params[:file][:tempfile] if params[:file]
+ name = params[:file][:filename] if params[:file]
+
+ if path and file and name
+
+ identifier = `uuidgen`
+ extension = File.extname(name)
+
+ path = path.gsub(/:identifier/, identifier)
+ path = path.gsub(/:extension/, extension)
+
+ end
+
+ erb :new
+end
@@ -0,0 +1,5 @@
+require 'rubygems'
+require 'sinatra'
+require './app.rb'
+
+run Sinatra::Application
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
No changes.
@@ -0,0 +1,59 @@
+/*!
+ * jQuery Uploader
+ *
+ * Copyright 2010 Kevin Sylvestre
+ */
+
+(function ($) {
+
+ $.fn.uploader = function(options) {
+
+ var settings = {
+ url: '/',
+ path: ':identifier:extension',
+ files: null,
+ method: 'POST',
+ events: {
+ error: null,
+ progress: null,
+ },
+ };
+
+ if (options) ($.extend(settings, options));
+
+ const XMLHttpFactories = [
+ function () { return new XDomainRequest(); },
+ function () { return new XMLHttpRequest(); },
+ function () { return new ActiveXObject("Msxml2.XMLHTTP"); },
+ function () { return new ActiveXObject("Msxml3.XMLHTTP"); },
+ function () { return new ActiveXObject("Microsoft.XMLHTTP"); },
+ ];
+
+ var xhr = null;
+
+ for (var i = 0; i < XMLHttpFactories.length; i++) {
+ try { xhr = XMLHttpFactories[i](); break; } catch (exception) { continue; }
+ }
+
+ if (!(xhr && ('upload' in xhr) && ('onprogress' in xhr.upload))) return;
+
+ xhr.upload.addEventListener('progress', settings.events.progress, false);
+
+ var path = settings.path;
+
+ for (var i = 0; i < settings.files.length; i++) {
+
+ var file = settings.files[i];
+
+ var formdata = new FormData();
+ formdata.append('file', file);
+ formdata.append('path', path);
+
+ xhr.open(settings.method, settings.url, true);
+ xhr.send(formdata);
+
+ }
+
+ };
+
+}) (jQuery);
Oops, something went wrong.

0 comments on commit ebd539a

Please sign in to comment.