s3_cors_fileupload 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. data/.document +5 -0
  2. data/.gitignore +51 -0
  3. data/.rspec +1 -0
  4. data/Gemfile +14 -0
  5. data/Gemfile.lock +39 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +104 -0
  8. data/Rakefile +58 -0
  9. data/lib/generators/s3_cors_fileupload/install/USAGE +17 -0
  10. data/lib/generators/s3_cors_fileupload/install/install_generator.rb +51 -0
  11. data/lib/generators/s3_cors_fileupload/install/templates/amazon_s3.yml +17 -0
  12. data/lib/generators/s3_cors_fileupload/install/templates/create_source_files.rb +14 -0
  13. data/lib/generators/s3_cors_fileupload/install/templates/s3_uploads.js +94 -0
  14. data/lib/generators/s3_cors_fileupload/install/templates/s3_uploads_controller.rb +90 -0
  15. data/lib/generators/s3_cors_fileupload/install/templates/source_file.rb +53 -0
  16. data/lib/generators/s3_cors_fileupload/install/templates/views/_template_download.html.erb +29 -0
  17. data/lib/generators/s3_cors_fileupload/install/templates/views/_template_upload.html.erb +31 -0
  18. data/lib/generators/s3_cors_fileupload/install/templates/views/_template_uploaded.html.erb +25 -0
  19. data/lib/generators/s3_cors_fileupload/install/templates/views/index.html.erb +43 -0
  20. data/lib/s3_cors_fileupload.rb +2 -0
  21. data/lib/s3_cors_fileupload/rails.rb +8 -0
  22. data/lib/s3_cors_fileupload/rails/config.rb +27 -0
  23. data/lib/s3_cors_fileupload/rails/engine.rb +6 -0
  24. data/lib/s3_cors_fileupload/rails/form_helper.rb +91 -0
  25. data/lib/s3_cors_fileupload/rails/policy_helper.rb +48 -0
  26. data/lib/s3_cors_fileupload/version.rb +5 -0
  27. data/s3_cors_fileupload.gemspec +35 -0
  28. data/spec/s3_cors_fileupload/version_spec.rb +17 -0
  29. data/spec/s3_cors_fileupload_spec.rb +9 -0
  30. data/spec/spec_helper.rb +16 -0
  31. data/vendor/assets/images/loading.gif +0 -0
  32. data/vendor/assets/images/progressbar.gif +0 -0
  33. data/vendor/assets/javascripts/s3_cors_fileupload/index.js +6 -0
  34. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-ui.js +732 -0
  35. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload.js +1106 -0
  36. data/vendor/assets/javascripts/s3_cors_fileupload/jquery.iframe-transport.js +172 -0
  37. data/vendor/assets/javascripts/s3_cors_fileupload/vendor/jquery.ui.widget.js +511 -0
  38. data/vendor/assets/javascripts/s3_cors_fileupload/vendor/load-image.js +122 -0
  39. data/vendor/assets/javascripts/s3_cors_fileupload/vendor/tmpl.js +87 -0
  40. data/vendor/assets/stylesheets/jquery.fileupload-ui.css.erb +85 -0
  41. metadata +205 -0
@@ -0,0 +1,122 @@
1
+ /*
2
+ * JavaScript Load Image 1.2.1
3
+ * https://github.com/blueimp/JavaScript-Load-Image
4
+ *
5
+ * Copyright 2011, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ */
11
+
12
+ /*jslint nomen: true */
13
+ /*global window, document, URL, webkitURL, Blob, File, FileReader, define */
14
+
15
+
16
+ (function ($) {
17
+ 'use strict';
18
+
19
+ // Loads an image for a given File object.
20
+ // Invokes the callback with an img or optional canvas
21
+ // element (if supported by the browser) as parameter:
22
+ var loadImage = function (file, callback, options) {
23
+ var img = document.createElement('img'),
24
+ url,
25
+ oUrl;
26
+ img.onerror = callback;
27
+ img.onload = function () {
28
+ if (oUrl && !(options && options.noRevoke)) {
29
+ loadImage.revokeObjectURL(oUrl);
30
+ }
31
+ callback(loadImage.scale(img, options));
32
+ };
33
+ if ((window.Blob && file instanceof Blob) ||
34
+ // Files are also Blob instances, but some browsers
35
+ // (Firefox 3.6) support the File API but not Blobs:
36
+ (window.File && file instanceof File)) {
37
+ url = oUrl = loadImage.createObjectURL(file);
38
+ } else {
39
+ url = file;
40
+ }
41
+ if (url) {
42
+ img.src = url;
43
+ return img;
44
+ }
45
+ return loadImage.readFile(file, function (url) {
46
+ img.src = url;
47
+ });
48
+ },
49
+ // The check for URL.revokeObjectURL fixes an issue with Opera 12,
50
+ // which provides URL.createObjectURL but doesn't properly implement it:
51
+ urlAPI = (window.createObjectURL && window) ||
52
+ (window.URL && URL.revokeObjectURL && URL) ||
53
+ (window.webkitURL && webkitURL);
54
+
55
+ // Scales the given image (img or canvas HTML element)
56
+ // using the given options.
57
+ // Returns a canvas object if the browser supports canvas
58
+ // and the canvas option is true or a canvas object is passed
59
+ // as image, else the scaled image:
60
+ loadImage.scale = function (img, options) {
61
+ options = options || {};
62
+ var canvas = document.createElement('canvas'),
63
+ width = img.width,
64
+ height = img.height,
65
+ scale = Math.max(
66
+ (options.minWidth || width) / width,
67
+ (options.minHeight || height) / height
68
+ );
69
+ if (scale > 1) {
70
+ width = parseInt(width * scale, 10);
71
+ height = parseInt(height * scale, 10);
72
+ }
73
+ scale = Math.min(
74
+ (options.maxWidth || width) / width,
75
+ (options.maxHeight || height) / height
76
+ );
77
+ if (scale < 1) {
78
+ width = parseInt(width * scale, 10);
79
+ height = parseInt(height * scale, 10);
80
+ }
81
+ if (img.getContext || (options.canvas && canvas.getContext)) {
82
+ canvas.width = width;
83
+ canvas.height = height;
84
+ canvas.getContext('2d')
85
+ .drawImage(img, 0, 0, width, height);
86
+ return canvas;
87
+ }
88
+ img.width = width;
89
+ img.height = height;
90
+ return img;
91
+ };
92
+
93
+ loadImage.createObjectURL = function (file) {
94
+ return urlAPI ? urlAPI.createObjectURL(file) : false;
95
+ };
96
+
97
+ loadImage.revokeObjectURL = function (url) {
98
+ return urlAPI ? urlAPI.revokeObjectURL(url) : false;
99
+ };
100
+
101
+ // Loads a given File object via FileReader interface,
102
+ // invokes the callback with a data url:
103
+ loadImage.readFile = function (file, callback) {
104
+ if (window.FileReader && FileReader.prototype.readAsDataURL) {
105
+ var fileReader = new FileReader();
106
+ fileReader.onload = function (e) {
107
+ callback(e.target.result);
108
+ };
109
+ fileReader.readAsDataURL(file);
110
+ return fileReader;
111
+ }
112
+ return false;
113
+ };
114
+
115
+ if (typeof define === 'function' && define.amd) {
116
+ define(function () {
117
+ return loadImage;
118
+ });
119
+ } else {
120
+ $.loadImage = loadImage;
121
+ }
122
+ }(this));
@@ -0,0 +1,87 @@
1
+ /*
2
+ * JavaScript Templates 2.1.0
3
+ * https://github.com/blueimp/JavaScript-Templates
4
+ *
5
+ * Copyright 2011, Sebastian Tschan
6
+ * https://blueimp.net
7
+ *
8
+ * Licensed under the MIT license:
9
+ * http://www.opensource.org/licenses/MIT
10
+ *
11
+ * Inspired by John Resig's JavaScript Micro-Templating:
12
+ * http://ejohn.org/blog/javascript-micro-templating/
13
+ */
14
+
15
+ /*jslint evil: true, regexp: true */
16
+ /*global document, define */
17
+
18
+
19
+ (function ($) {
20
+ "use strict";
21
+ var tmpl = function (str, data) {
22
+ var f = !/[^\w\-\.:]/.test(str) ? tmpl.cache[str] = tmpl.cache[str] ||
23
+ tmpl(tmpl.load(str)) :
24
+ new Function(
25
+ tmpl.arg + ',tmpl',
26
+ "var _e=tmpl.encode" + tmpl.helper + ",_s='" +
27
+ str.replace(tmpl.regexp, tmpl.func) +
28
+ "';return _s;"
29
+ );
30
+ return data ? f(data, tmpl) : function (data) {
31
+ return f(data, tmpl);
32
+ };
33
+ };
34
+ tmpl.cache = {};
35
+ tmpl.load = function (id) {
36
+ return document.getElementById(id).innerHTML;
37
+ };
38
+ tmpl.regexp = /([\s'\\])(?![^%]*%\})|(?:\{%(=|#)([\s\S]+?)%\})|(\{%)|(%\})/g;
39
+ tmpl.func = function (s, p1, p2, p3, p4, p5) {
40
+ if (p1) { // whitespace, quote and backspace in interpolation context
41
+ return {
42
+ "\n": "\\n",
43
+ "\r": "\\r",
44
+ "\t": "\\t",
45
+ " " : " "
46
+ }[s] || "\\" + s;
47
+ }
48
+ if (p2) { // interpolation: {%=prop%}, or unescaped: {%#prop%}
49
+ if (p2 === "=") {
50
+ return "'+_e(" + p3 + ")+'";
51
+ }
52
+ return "'+(" + p3 + "||'')+'";
53
+ }
54
+ if (p4) { // evaluation start tag: {%
55
+ return "';";
56
+ }
57
+ if (p5) { // evaluation end tag: %}
58
+ return "_s+='";
59
+ }
60
+ };
61
+ tmpl.encReg = /[<>&"'\x00]/g;
62
+ tmpl.encMap = {
63
+ "<" : "&lt;",
64
+ ">" : "&gt;",
65
+ "&" : "&amp;",
66
+ "\"" : "&quot;",
67
+ "'" : "&#39;"
68
+ };
69
+ tmpl.encode = function (s) {
70
+ return String(s || "").replace(
71
+ tmpl.encReg,
72
+ function (c) {
73
+ return tmpl.encMap[c] || "";
74
+ }
75
+ );
76
+ };
77
+ tmpl.arg = "o";
78
+ tmpl.helper = ",print=function(s,e){_s+=e&&(s||'')||_e(s);}" +
79
+ ",include=function(s,d){_s+=tmpl(s,d);}";
80
+ if (typeof define === "function" && define.amd) {
81
+ define(function () {
82
+ return tmpl;
83
+ });
84
+ } else {
85
+ $.tmpl = tmpl;
86
+ }
87
+ }(this));
@@ -0,0 +1,85 @@
1
+ @charset "UTF-8";
2
+ /*
3
+ * jQuery File Upload UI Plugin CSS 6.3.1
4
+ * https://github.com/blueimp/jQuery-File-Upload
5
+ *
6
+ * Copyright 2010, Sebastian Tschan
7
+ * https://blueimp.net
8
+ *
9
+ * Licensed under the MIT license:
10
+ * http://www.opensource.org/licenses/MIT
11
+ */
12
+
13
+ .fileinput-button {
14
+ position: relative;
15
+ overflow: hidden;
16
+ float: left;
17
+ margin-right: 4px;
18
+ }
19
+ .fileinput-button input {
20
+ position: absolute;
21
+ top: 0;
22
+ right: 0;
23
+ margin: 0;
24
+ border: solid transparent;
25
+ border-width: 0 0 100px 200px;
26
+ opacity: 0;
27
+ filter: alpha(opacity=0);
28
+ -moz-transform: translate(-300px, 0) scale(4);
29
+ direction: ltr;
30
+ cursor: pointer;
31
+ }
32
+ .fileupload-buttonbar .btn,
33
+ .fileupload-buttonbar .toggle {
34
+ margin-bottom: 5px;
35
+ }
36
+ .files .progress {
37
+ width: 200px;
38
+ }
39
+ .progress-animated .bar {
40
+ background: url(<%= asset_path 'progressbar.gif' %>) !important;
41
+ filter: none;
42
+ }
43
+ .fileupload-loading {
44
+ position: absolute;
45
+ left: 50%;
46
+ width: 128px;
47
+ height: 128px;
48
+ background: url(<%= asset_path 'loading.gif' %>) center no-repeat;
49
+ display: none;
50
+ }
51
+ .fileupload-processing .fileupload-loading {
52
+ display: block;
53
+ }
54
+
55
+ /* Fix for IE 6: */
56
+ * html .fileinput-button {
57
+ line-height: 24px;
58
+ margin: 1px -3px 0 0;
59
+ }
60
+
61
+ /* Fix for IE 7: */
62
+ * + html .fileinput-button {
63
+ line-height: 22px;
64
+ margin: 1px 0 0 0;
65
+ }
66
+
67
+ @media (max-width: 767px) {
68
+ .files .btn span {
69
+ display: none;
70
+ }
71
+ .files .preview * {
72
+ width: 40px;
73
+ }
74
+ .files .name * {
75
+ width: 80px;
76
+ display: inline-block;
77
+ word-wrap: break-word;
78
+ }
79
+ .files .progress {
80
+ width: 20px;
81
+ }
82
+ .files .delete {
83
+ width: 60px;
84
+ }
85
+ }
metadata ADDED
@@ -0,0 +1,205 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: s3_cors_fileupload
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ben Atkins
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-10-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.1'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - !ruby/object:Gem::Dependency
31
+ name: jquery-rails
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '2.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '2.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: aws-s3
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.6'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.6'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.8.7
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 0.8.7
78
+ - !ruby/object:Gem::Dependency
79
+ name: bundler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rdoc
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '3.12'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '3.12'
110
+ - !ruby/object:Gem::Dependency
111
+ name: jeweler
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: 1.8.4
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.8.4
126
+ description: A Ruby gem for providing File uploads for Rails ~> 3.1 to AWS-S3 via
127
+ CORS using the jQuery-File-Upload script
128
+ email:
129
+ - benatkins@fullbridge.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files:
133
+ - LICENSE.txt
134
+ - README.md
135
+ files:
136
+ - .document
137
+ - .gitignore
138
+ - .rspec
139
+ - Gemfile
140
+ - Gemfile.lock
141
+ - LICENSE.txt
142
+ - README.md
143
+ - Rakefile
144
+ - lib/generators/s3_cors_fileupload/install/USAGE
145
+ - lib/generators/s3_cors_fileupload/install/install_generator.rb
146
+ - lib/generators/s3_cors_fileupload/install/templates/amazon_s3.yml
147
+ - lib/generators/s3_cors_fileupload/install/templates/create_source_files.rb
148
+ - lib/generators/s3_cors_fileupload/install/templates/s3_uploads.js
149
+ - lib/generators/s3_cors_fileupload/install/templates/s3_uploads_controller.rb
150
+ - lib/generators/s3_cors_fileupload/install/templates/source_file.rb
151
+ - lib/generators/s3_cors_fileupload/install/templates/views/_template_download.html.erb
152
+ - lib/generators/s3_cors_fileupload/install/templates/views/_template_upload.html.erb
153
+ - lib/generators/s3_cors_fileupload/install/templates/views/_template_uploaded.html.erb
154
+ - lib/generators/s3_cors_fileupload/install/templates/views/index.html.erb
155
+ - lib/s3_cors_fileupload.rb
156
+ - lib/s3_cors_fileupload/rails.rb
157
+ - lib/s3_cors_fileupload/rails/config.rb
158
+ - lib/s3_cors_fileupload/rails/engine.rb
159
+ - lib/s3_cors_fileupload/rails/form_helper.rb
160
+ - lib/s3_cors_fileupload/rails/policy_helper.rb
161
+ - lib/s3_cors_fileupload/version.rb
162
+ - s3_cors_fileupload.gemspec
163
+ - spec/s3_cors_fileupload/version_spec.rb
164
+ - spec/s3_cors_fileupload_spec.rb
165
+ - spec/spec_helper.rb
166
+ - vendor/assets/images/loading.gif
167
+ - vendor/assets/images/progressbar.gif
168
+ - vendor/assets/javascripts/s3_cors_fileupload/index.js
169
+ - vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload-ui.js
170
+ - vendor/assets/javascripts/s3_cors_fileupload/jquery.fileupload.js
171
+ - vendor/assets/javascripts/s3_cors_fileupload/jquery.iframe-transport.js
172
+ - vendor/assets/javascripts/s3_cors_fileupload/vendor/jquery.ui.widget.js
173
+ - vendor/assets/javascripts/s3_cors_fileupload/vendor/load-image.js
174
+ - vendor/assets/javascripts/s3_cors_fileupload/vendor/tmpl.js
175
+ - vendor/assets/stylesheets/jquery.fileupload-ui.css.erb
176
+ homepage: http://github.com/fullbridge-batkins/s3_cors_fileupload
177
+ licenses:
178
+ - MIT
179
+ post_install_message:
180
+ rdoc_options: []
181
+ require_paths:
182
+ - lib
183
+ required_ruby_version: !ruby/object:Gem::Requirement
184
+ none: false
185
+ requirements:
186
+ - - ! '>='
187
+ - !ruby/object:Gem::Version
188
+ version: '0'
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ none: false
191
+ requirements:
192
+ - - ! '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ requirements: []
196
+ rubyforge_project:
197
+ rubygems_version: 1.8.24
198
+ signing_key:
199
+ specification_version: 3
200
+ summary: File uploads for Rails ~> 3.1 to AWS-S3 via CORS using the jQuery-File-Upload
201
+ script
202
+ test_files:
203
+ - spec/s3_cors_fileupload/version_spec.rb
204
+ - spec/s3_cors_fileupload_spec.rb
205
+ - spec/spec_helper.rb