condo 1.0.1 → 1.0.2
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.
- data/README.textile +5 -3
- data/app/assets/javascripts/condo.js +1 -0
- data/app/assets/javascripts/condo/abstract-md5.js.erb +8 -2
- data/app/assets/javascripts/condo/broadcaster.js +7 -1
- data/app/assets/javascripts/condo/config.js +80 -0
- data/app/assets/javascripts/condo/controller.js +28 -15
- data/app/assets/javascripts/condo/uploader.js +7 -3
- data/lib/condo/engine.rb +7 -2
- data/lib/condo/strata/google_cloud_storage.rb +14 -6
- data/lib/condo/version.rb +1 -1
- metadata +4 -2
data/README.textile
CHANGED
@@ -50,9 +50,11 @@ See the "example application":https://github.com/cotag/condo_example which imple
|
|
50
50
|
|
51
51
|
# Add the following to your rails application gemfile:
|
52
52
|
#* @gem 'condo'@
|
53
|
-
#*
|
54
|
-
|
55
|
-
|
53
|
+
#* Add a datastore
|
54
|
+
#** @gem 'condo_active_record'@ (for traditional databases)
|
55
|
+
#** "condo_mongoid":https://github.com/axomi/condo_mongoid by "axomi":https://github.com/axomi for "MongoDB":http://mongodb.org/
|
56
|
+
#* @gem 'condo_interface'@ (optional - an example interface)
|
57
|
+
# Run migrations if using active record
|
56
58
|
#* @rake railties:install:migrations FROM=condo_active_record@
|
57
59
|
#* @rake db:migrate@
|
58
60
|
# Create an initialiser for any default residencies. (details further down)
|
@@ -51,7 +51,10 @@
|
|
51
51
|
hasher.onmessage = recievedMessage;
|
52
52
|
hasher.onerror = function(e) {
|
53
53
|
ready = false;
|
54
|
-
broadcaster.broadcast('
|
54
|
+
broadcaster.broadcast('coNotice', {
|
55
|
+
type: 'error',
|
56
|
+
number: 1
|
57
|
+
});
|
55
58
|
};
|
56
59
|
ready = true;
|
57
60
|
} else {
|
@@ -60,7 +63,10 @@
|
|
60
63
|
ready = true;
|
61
64
|
processNext(); // It is possible
|
62
65
|
}).fail(function(jqxhr, settings, exception) {
|
63
|
-
broadcaster.broadcast('
|
66
|
+
broadcaster.broadcast('coNotice', {
|
67
|
+
type: 'error',
|
68
|
+
number: 1
|
69
|
+
});
|
64
70
|
});
|
65
71
|
}
|
66
72
|
|
@@ -26,12 +26,18 @@
|
|
26
26
|
}(function (undefined) {
|
27
27
|
'use strict';
|
28
28
|
|
29
|
+
|
30
|
+
//
|
31
|
+
//
|
32
|
+
//
|
33
|
+
|
34
|
+
|
29
35
|
angular.module('CondoBroadcaster', []).factory('Condo.Broadcast', ['$rootScope', function($rootScope) {
|
30
36
|
// eventBroadcaster is the object created by the factory method.
|
31
37
|
var eventBroadcaster = {};
|
32
38
|
|
33
39
|
// The message is a string or object to carry data with the event.
|
34
|
-
eventBroadcaster.message =
|
40
|
+
eventBroadcaster.message = {};
|
35
41
|
|
36
42
|
// The event name is a string used to define event types.
|
37
43
|
eventBroadcaster.eventName = '';
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/**
|
2
|
+
* CoTag Condo
|
3
|
+
* Direct to cloud resumable uploads
|
4
|
+
*
|
5
|
+
* Copyright (c) 2012 CoTag Media.
|
6
|
+
*
|
7
|
+
* @author Stephen von Takach <steve@cotag.me>
|
8
|
+
* @copyright 2012 cotag.me
|
9
|
+
*
|
10
|
+
*
|
11
|
+
* References:
|
12
|
+
* * https://github.com/umdjs/umd
|
13
|
+
* * https://github.com/addyosmani/jquery-plugin-patterns
|
14
|
+
* * http://docs.angularjs.org/api/AUTO.$provide
|
15
|
+
* * http://jsfiddle.net/pkozlowski_opensource/PxdSP/14/
|
16
|
+
*
|
17
|
+
**/
|
18
|
+
|
19
|
+
(function (factory) {
|
20
|
+
if (typeof define === 'function' && define.amd) {
|
21
|
+
// AMD
|
22
|
+
define('condo-config', ['jquery', 'condo-uploader'], factory);
|
23
|
+
} else {
|
24
|
+
// Browser globals
|
25
|
+
factory(jQuery, window.CondoUploader);
|
26
|
+
}
|
27
|
+
}(function ($, uploads, undefined) {
|
28
|
+
'use strict';
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
//
|
33
|
+
// Create a provider for defining the configuration
|
34
|
+
//
|
35
|
+
uploads.provider('Condo.Config', function() {
|
36
|
+
|
37
|
+
//
|
38
|
+
// Controller options
|
39
|
+
//
|
40
|
+
this.endpoint = '/uploads'; // Default endpoint path
|
41
|
+
this.autostart = true; // Start uploading as soon as the file is added?
|
42
|
+
this.ignore_errors = true; // Continue to autostart after an error?
|
43
|
+
this.parallelism = 1; // number of autostarted uploads at once
|
44
|
+
this.size_limit = undefined; // defaults to unlimited
|
45
|
+
this.file_checker = function(file) { // client side filtering of files
|
46
|
+
return true;
|
47
|
+
};
|
48
|
+
|
49
|
+
//
|
50
|
+
// Directive options (specifically for the condo default interface)
|
51
|
+
//
|
52
|
+
this.delegate = undefined; // defaults to the condo interface container
|
53
|
+
this.drop_targets = undefined; // defaults to the condo interface container
|
54
|
+
this.hover_class = 'drag-hover'; // for styling the interface
|
55
|
+
this.supress_notifications = false; // this prevents js alerts about warnings and errors if you are observing these yourself (Condo.Broadcast)
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
this.$get = function() {
|
60
|
+
var self = this;
|
61
|
+
|
62
|
+
return {
|
63
|
+
endpoint: self.endpoint,
|
64
|
+
autostart: self.autostart,
|
65
|
+
ignore_errors: self.ignore_errors,
|
66
|
+
parallelism: self.parallelism,
|
67
|
+
file_checker: self.file_checker,
|
68
|
+
size_limit: self.size_limit,
|
69
|
+
|
70
|
+
delegate: self.delegate,
|
71
|
+
drop_targets: self.drop_targets,
|
72
|
+
hover_class: self.hover_class,
|
73
|
+
supress_notifications: self.supress_notifications
|
74
|
+
};
|
75
|
+
};
|
76
|
+
});
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
}));
|
@@ -22,7 +22,7 @@
|
|
22
22
|
define('condo-controller', ['jquery', 'condo-uploader'], factory);
|
23
23
|
} else {
|
24
24
|
// Browser globals
|
25
|
-
|
25
|
+
factory(jQuery, window.CondoUploader);
|
26
26
|
}
|
27
27
|
}(function ($, uploads, undefined) {
|
28
28
|
'use strict';
|
@@ -32,25 +32,44 @@
|
|
32
32
|
//
|
33
33
|
// Create a controller for managing the upload states
|
34
34
|
//
|
35
|
-
uploads.controller('Condo.Controller', ['$scope', 'Condo.Api', 'Condo.Broadcast', function($scope, api, broadcaster) {
|
35
|
+
uploads.controller('Condo.Controller', ['$scope', 'Condo.Api', 'Condo.Broadcast', 'Condo.Config', function($scope, api, broadcaster, config) {
|
36
36
|
|
37
37
|
$scope.uploads = [];
|
38
38
|
$scope.upload_count = 0;
|
39
|
-
$scope.endpoint = '/uploads'; // Default, the directive can overwrite this
|
40
39
|
|
41
|
-
|
42
|
-
|
43
|
-
|
40
|
+
|
41
|
+
//
|
42
|
+
// See Condo.Config for configuration options
|
43
|
+
//
|
44
|
+
$scope.endpoint = config.endpoint;
|
45
|
+
$scope.autostart = config.autostart;
|
46
|
+
$scope.ignore_errors = config.ignore_errors; // Continue to autostart after an error?
|
47
|
+
$scope.parallelism = config.parallelism; // number of uploads at once
|
44
48
|
|
45
49
|
|
46
50
|
$scope.add = function(files) {
|
47
51
|
var length = files.length,
|
48
52
|
i = 0,
|
49
|
-
ret = 0
|
53
|
+
ret = 0, // We only want to check for auto-start after the files have been added
|
54
|
+
file;
|
50
55
|
|
51
56
|
for (; i < length; i += 1) {
|
52
|
-
|
57
|
+
file = files[i];
|
58
|
+
|
59
|
+
if(file.size <= 0 || file.type == '')
|
60
|
+
continue;
|
61
|
+
|
62
|
+
//
|
63
|
+
// check file size is acceptable
|
64
|
+
//
|
65
|
+
if(!config.file_checker(file) || (config.size_limit != undefined && file.size > config.size_limit)) {
|
66
|
+
broadcaster.broadcast('coNotice', {
|
67
|
+
type: 'warn',
|
68
|
+
number: 0,
|
69
|
+
file: file
|
70
|
+
});
|
53
71
|
continue;
|
72
|
+
}
|
54
73
|
|
55
74
|
$scope.upload_count += 1;
|
56
75
|
|
@@ -70,7 +89,7 @@
|
|
70
89
|
//
|
71
90
|
// broadcast this so it can be handled by a directive
|
72
91
|
//
|
73
|
-
broadcaster.broadcast('
|
92
|
+
broadcaster.broadcast('coNotice', failure);
|
74
93
|
});
|
75
94
|
}
|
76
95
|
};
|
@@ -172,10 +191,4 @@
|
|
172
191
|
|
173
192
|
}]);
|
174
193
|
|
175
|
-
|
176
|
-
//
|
177
|
-
// Anonymous function return
|
178
|
-
//
|
179
|
-
return uploads;
|
180
|
-
|
181
194
|
}));
|
@@ -266,19 +266,23 @@
|
|
266
266
|
|
267
267
|
} else {
|
268
268
|
return $q.reject({
|
269
|
-
|
269
|
+
type: 'error',
|
270
|
+
number: 0,
|
271
|
+
file: the_file
|
270
272
|
});
|
271
273
|
}
|
272
274
|
}, function(reason) {
|
273
275
|
if(reason.status == 406) {
|
274
276
|
return $q.reject({
|
275
|
-
|
277
|
+
type: 'warn',
|
278
|
+
number: 0,
|
276
279
|
details: reason.data,
|
277
280
|
file: the_file
|
278
281
|
});
|
279
282
|
} else {
|
280
283
|
return $q.reject({
|
281
|
-
|
284
|
+
type: 'warn',
|
285
|
+
number: 1,
|
282
286
|
file: the_file
|
283
287
|
});
|
284
288
|
}
|
data/lib/condo/engine.rb
CHANGED
@@ -13,11 +13,15 @@ module Condo
|
|
13
13
|
|
14
14
|
config.autoload_paths << File.expand_path("../../../lib", __FILE__)
|
15
15
|
|
16
|
+
|
16
17
|
#
|
17
|
-
# Set the proper error types for Rails
|
18
|
+
# Set the proper error types for Rails and add assets for compilation
|
18
19
|
#
|
19
|
-
initializer "
|
20
|
+
initializer "condo initializer" do |app|
|
21
|
+
|
20
22
|
config.after_initialize do
|
23
|
+
Rails.application.config.assets.precompile += ['condo/md5/hash.worker.js', 'condo/md5/hash.worker.emulator.js']
|
24
|
+
|
21
25
|
responses = {
|
22
26
|
"Condo::Errors::MissingFurniture" => :not_found,
|
23
27
|
"Condo::Errors::LostTheKeys" => :forbidden,
|
@@ -29,6 +33,7 @@ module Condo
|
|
29
33
|
ActionDispatch::ShowExceptions.rescue_responses.update(responses) # Rails 3.0/3.1
|
30
34
|
end
|
31
35
|
end
|
36
|
+
|
32
37
|
end
|
33
38
|
|
34
39
|
|
@@ -17,15 +17,19 @@ class Condo::Strata::GoogleCloudStorage
|
|
17
17
|
:location => :na, # US or Europe, set at bucket creation time
|
18
18
|
:fog => {
|
19
19
|
:provider => 'Google',
|
20
|
-
:google_storage_access_key_id => options[:access_id],
|
21
|
-
:google_storage_secret_access_key => options[:secret_key]
|
22
|
-
}
|
20
|
+
:google_storage_access_key_id => options[:fog_access_id] || options[:access_id],
|
21
|
+
:google_storage_secret_access_key => options[:fog_secret_key] || options[:secret_key]
|
22
|
+
},
|
23
|
+
:api => 1
|
23
24
|
}.merge!(options)
|
24
25
|
|
25
26
|
|
26
27
|
raise ArgumentError, 'Google Access ID missing' if @options[:access_id].nil?
|
27
28
|
raise ArgumentError, 'Google Secret Key missing' if @options[:secret_key].nil?
|
28
29
|
|
30
|
+
if @options[:api] == 2
|
31
|
+
@options[:secret_key] = OpenSSL::PKey::RSA.new(@options[:secret_key])
|
32
|
+
end
|
29
33
|
|
30
34
|
@options[:location] = @options[:location].to_sym
|
31
35
|
end
|
@@ -128,7 +132,7 @@ DATA
|
|
128
132
|
#
|
129
133
|
# Set the access control headers
|
130
134
|
#
|
131
|
-
options[:object_options][:headers]['x-goog-api-version'] =
|
135
|
+
options[:object_options][:headers]['x-goog-api-version'] = @options[:api]
|
132
136
|
|
133
137
|
if options[:object_options][:headers]['x-goog-acl'].nil?
|
134
138
|
options[:object_options][:headers]['x-goog-acl'] = case options[:object_options][:permissions]
|
@@ -283,12 +287,16 @@ DATA
|
|
283
287
|
#
|
284
288
|
# Encode the request signature
|
285
289
|
#
|
286
|
-
|
290
|
+
if @options[:api] == 1
|
291
|
+
signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), @options[:secret_key], signature)).gsub("\n","")
|
292
|
+
options[:object_options][:headers]['Authorization'] = "GOOG1 #{@options[:access_id]}:#{signature}"
|
293
|
+
else
|
294
|
+
signature = Base64.encode64(@options[:secret_key].sign(OpenSSL::Digest::SHA256.new, signature)).gsub("\n","")
|
295
|
+
end
|
287
296
|
|
288
297
|
|
289
298
|
url += signed_params.present? ? '&' : '?'
|
290
299
|
url = "#{options[:object_options][:protocol]}://#{options[:bucket_name]}.storage.googleapis.com#{url}#{other_params}GoogleAccessId=#{@options[:access_id]}&Expires=#{options[:object_options][:expires]}&Signature=#{CGI::escape(signature)}"
|
291
|
-
options[:object_options][:headers]['Authorization'] = "GOOG1 #{@options[:access_id]}:#{signature}"
|
292
300
|
|
293
301
|
|
294
302
|
#
|
data/lib/condo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: condo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- app/assets/javascripts/condo/amazon.js
|
72
72
|
- app/assets/javascripts/condo/base64.js
|
73
73
|
- app/assets/javascripts/condo/broadcaster.js
|
74
|
+
- app/assets/javascripts/condo/config.js
|
74
75
|
- app/assets/javascripts/condo/controller.js
|
75
76
|
- app/assets/javascripts/condo/google.js
|
76
77
|
- app/assets/javascripts/condo/md5/hash.worker.emulator.js
|
@@ -183,3 +184,4 @@ test_files:
|
|
183
184
|
- test/dummy/script/rails
|
184
185
|
- test/integration/navigation_test.rb
|
185
186
|
- test/test_helper.rb
|
187
|
+
has_rdoc:
|