applicious_utils 0.1.47 → 0.1.48

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.
@@ -1,3 +1,3 @@
1
1
  module AppliciousUtils
2
- VERSION = "0.1.47"
2
+ VERSION = "0.1.48"
3
3
  end
@@ -1,26 +1,10 @@
1
1
  module AppliciousUtils
2
2
  module ViewHelpers
3
3
 
4
- # Creates an instance of a plupload S3 file uploader
5
- ###
6
- # required parameters:
7
- ###
8
- # key s3 'path' to uploaded files
9
- #
10
- ###
11
- # optional parameters:
12
- ###
13
- # s3_config_filename filename of s3 config yaml file (full path), defaults to "#{RAILS_ROOT}/config/amazon_s3.yml"
14
- #
15
- # content_type binary/octet-stream
16
- #
17
- # acl public-read
18
- #
19
- # expiration_date 10.hours.from_now.utc.iso8601
20
- #
21
- # max_filesize 2.megabytes
4
+ # Creates an instance of a plupload S3 file uploader
5
+ # Derived from https://github.com/iwasrobbed/Rails3-S3-Uploader-Plupload
22
6
 
23
- def s3_uploader(options = {})
7
+ def applicious_uploader(options = {})
24
8
  options[:s3_config_filename] ||= Rails.root.join('config', 'amazon_s3.yml')
25
9
  config = YAML.load_file(options[:s3_config_filename])[Rails.env].symbolize_keys
26
10
  bucket = config[:bucket_name]
@@ -34,7 +18,9 @@ module AppliciousUtils
34
18
  options[:content_type] ||= 'image/' # Videos would be binary/octet-stream
35
19
  options[:filter_title] ||= 'Images'
36
20
  options[:filter_extentions] ||= 'jpg,jpeg,gif,png,bmp'
37
-
21
+
22
+ filename_token = "#{SecureRandom.hex(10)}_#{Time.now.to_i}"
23
+
38
24
  id = options[:id] ? "_#{options[:id]}" : ''
39
25
 
40
26
  policy = Base64.encode64(
@@ -77,8 +63,8 @@ module AppliciousUtils
77
63
  multi_selection: false,
78
64
  multipart: true,
79
65
  multipart_params: {
80
- 'key': 'uploads/#{SecureRandom.hex(10)}_#{Time.now.to_i}_${filename}',
81
- 'Filename': 'uploads/#{SecureRandom.hex(10)}_#{Time.now.to_i}_${filename}', // adding this to keep consistency across the runtimes
66
+ 'key': 'uploads/#{filename_token}_${filename}',
67
+ 'Filename': 'uploads/#{filename_token}_${filename}', // adding this to keep consistency across the runtimes
82
68
  'acl': '#{options[:acl]}',
83
69
  'Content-Type': '#{options[:content_type]}',
84
70
  'success_action_status': '201',
@@ -1,6 +1,6 @@
1
1
  require 'rails/generators'
2
2
 
3
- class UploaderGenerator < Rails::Generators::Base
3
+ class AppliciousUploaderGenerator < Rails::Generators::Base
4
4
  def self.source_root
5
5
  @source_root ||= File.join(File.dirname(__FILE__), 'templates')
6
6
  end
@@ -12,7 +12,5 @@ class UploaderGenerator < Rails::Generators::Base
12
12
  copy_file "applicious_uploader.js.coffee", "app/assets/javascripts/applicious_uploader.js.coffee"
13
13
  copy_file "crossdomain.xml", "public/applicious/UPLOAD_TO_S3/crossdomain.xml"
14
14
  copy_file "clientaccesspolicy.xml", "public/applicious/UPLOAD_TO_S3/clientaccesspolicy.xml"
15
-
16
- #template "session_store.rb", "app/config/initializers/session_store.rb"
17
15
  end
18
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: applicious_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.47
4
+ version: 0.1.48
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -80,12 +80,11 @@ files:
80
80
  - lib/applicious_utils/version.rb
81
81
  - lib/applicious_utils/view_helpers.rb
82
82
  - lib/applicious_utils.rb
83
+ - lib/generators/applicious_uploader_generator.rb
83
84
  - lib/generators/templates/amazon_s3.yml
84
85
  - lib/generators/templates/applicious_uploader.js.coffee
85
86
  - lib/generators/templates/clientaccesspolicy.xml
86
87
  - lib/generators/templates/crossdomain.xml
87
- - lib/generators/templates/session_store.rb
88
- - lib/generators/uploader_generator.rb
89
88
  - Rakefile
90
89
  homepage: http://appliciousagency.com
91
90
  licenses: []
@@ -1,69 +0,0 @@
1
- =begin
2
- <script type="text/javascript">
3
- <% session_key_name = Rails.application.config.session_options[:key] %>
4
-
5
- // Default options
6
- $(function() {
7
- var uploader = new plupload.Uploader({
8
- runtimes: 'html5,flash',
9
- //url: '<%= photos_path %>',
10
- //container : 'container',
11
- browse_button : 'applicious_uploader',
12
- max_file_size : '10mb',
13
- flash_swf_url : '<%= asset_path("plupload.flash.swf") %>',
14
-
15
- multipart: true,
16
- multipart_params: {
17
- '_http_accept': 'application/javascript',
18
- 'authenticity_token' : '<%= form_authenticity_token %>',
19
- '<%= session_key_name %>' : encodeURIComponent('<%= u cookies[session_key_name] %>')
20
- },
21
-
22
- filters : [
23
- //{title : "Zip files", extensions : "zip"},
24
- {title : "Image files", extensions : "jpeg,jpg,gif,png"},
25
- ],
26
-
27
- //resize : {width : 320, height : 240, quality : 90},
28
-
29
- filters : [
30
- {title : "Image files", extensions : "jpg,gif,png"},
31
- {title : "Zip files", extensions : "zip"}
32
- ],
33
- });
34
-
35
- uploader.bind('FilesAdded', function(up, files) {
36
- $.each(files, function(i, file) {
37
- $('#filelist').append(
38
- '<div id="' + file.id + '">' +
39
- file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' +
40
- '</div>');
41
- });
42
-
43
- up.refresh(); // Reposition Flash/Silverlight
44
- });
45
-
46
-
47
- uploader.bind('UploadProgress', function(up, file) {
48
- AP.log( up, file );
49
- });
50
-
51
- uploader.bind('Error', function(up, err) {
52
- AP.log( up, err );
53
- up.refresh(); // Reposition Flash/Silverlight
54
- });
55
-
56
- uploader.bind('FileUploaded', function(up, file) {
57
- AP.log( up, file );
58
- });
59
-
60
- uploader.init();
61
-
62
- $('#uploadfiles').click(function(e) {
63
- uploader.start();
64
- e.preventDefault();
65
- });
66
-
67
- });
68
- </script>
69
- =end