tb_media 1.0.6 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.markdown +1 -0
- data/app/assets/javascripts/admin/media/picker.js +19 -8
- data/app/controllers/admin/media_picker_controller.rb +1 -1
- data/app/models/spud_media.rb +12 -3
- data/app/views/admin/media_picker/_media.html.erb +1 -1
- data/lib/spud_media/configuration.rb +3 -1
- data/lib/spud_media/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e003b647c6daf3a4154d9f4be103bbd7c0967c4b
|
4
|
+
data.tar.gz: 0ca6e7cec76779943f3d0285c634fc4b7e0e5871
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6131013a9382913db5263624078d7b242371fb2d5d4ebe6392401f07fff197099aca03597facf7e387bc90ef66e80d00ef74a5879de258ffc0c4bc6a118370b7
|
7
|
+
data.tar.gz: 2fd6a6e22a8de93cd57a555e6526d243657d8230a6a3a06503d5538b1998e01106a5d756865816c5c8473735f96dab31b3ab2b3b5e645b45b582f51063a87068
|
data/Readme.markdown
CHANGED
@@ -30,6 +30,7 @@ TB Media accepts the following configuration options:
|
|
30
30
|
config.storage_path = "public/system/spud_media/:id/:style/:basename.:extension"
|
31
31
|
config.storage_path_protected = "public/system/spud_media_protected/:id/:style/:basename.:extension"
|
32
32
|
config.storage_url = "/system/spud_media/:id/:style/:basename.:extension"
|
33
|
+
config.max_upload_size = 15.megabytes
|
33
34
|
end
|
34
35
|
|
35
36
|
## File Protection
|
@@ -136,16 +136,29 @@ spud.admin.mediapicker = new function(){
|
|
136
136
|
|
137
137
|
this.onFileUploadProgress = function(e){
|
138
138
|
var percent = Math.round(e.loaded * 100 / e.total);
|
139
|
+
self.setProgressBarPrecent(percent);
|
140
|
+
};
|
141
|
+
|
142
|
+
this.onFileUploadComplete = function(e){
|
143
|
+
if(e.target.status == 200){
|
144
|
+
var html = e.target.response;
|
145
|
+
self.onLegacyUploadComplete(html);
|
146
|
+
}
|
147
|
+
else{
|
148
|
+
window.alert('Error: ' + e.target.responseText);
|
149
|
+
self.setProgressBarPrecent(0);
|
150
|
+
}
|
151
|
+
};
|
152
|
+
|
153
|
+
this.setProgressBarPrecent = function(percent){
|
139
154
|
var progress = $('.spud_media_picker_upload_progress');
|
140
155
|
progress.find('.bar').css({width: percent + '%'});
|
141
156
|
if(percent == 100){
|
142
157
|
progress.addClass('progress-success');
|
143
158
|
}
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
var html = e.target.response;
|
148
|
-
self.onLegacyUploadComplete(html);
|
159
|
+
else{
|
160
|
+
progress.removeClass('progress-success');
|
161
|
+
}
|
149
162
|
};
|
150
163
|
|
151
164
|
this.onFileUploadError = function(e){
|
@@ -166,11 +179,9 @@ spud.admin.mediapicker = new function(){
|
|
166
179
|
};
|
167
180
|
|
168
181
|
this.resetUploadForm = function(){
|
169
|
-
// reset twitter bootstrap "loading" button state
|
170
|
-
$('.spud_media_picker_tab_upload_submit').button('reset');
|
171
182
|
$('#spud_media_attachment').val('');
|
172
183
|
$('.spud_media_picker_upload_progress').hide();
|
173
|
-
|
184
|
+
self.setProgressBarPrecent(0);
|
174
185
|
};
|
175
186
|
|
176
187
|
this.activatedAdvancedTab = function(){
|
data/app/models/spud_media.rb
CHANGED
@@ -14,9 +14,16 @@ class SpudMedia < ActiveRecord::Base
|
|
14
14
|
|
15
15
|
validates_numericality_of :crop_x, :crop_y, :crop_w, :crop_h, :crop_s, :allow_nil => true
|
16
16
|
|
17
|
+
extend ActionView::Helpers::NumberHelper
|
18
|
+
|
17
19
|
validates_attachment :attachment,
|
18
20
|
:presence => true,
|
19
|
-
:content_type => {:content_type => Spud::Media::CONTENT_TYPES}
|
21
|
+
:content_type => {:content_type => Spud::Media::CONTENT_TYPES},
|
22
|
+
:size => {
|
23
|
+
:less_than => Spud::Media.max_upload_size,
|
24
|
+
:message => "size cannot exceed " + number_to_human_size(Spud::Media.max_upload_size),
|
25
|
+
:if => Proc.new{|p| Spud::Media.max_upload_size > 0}
|
26
|
+
}
|
20
27
|
|
21
28
|
before_create :rename_file
|
22
29
|
#after_create :validate_permissions
|
@@ -93,7 +100,9 @@ class SpudMedia < ActiveRecord::Base
|
|
93
100
|
if is_image? #|| is_pdf?
|
94
101
|
styles[:small] = '50'
|
95
102
|
if has_custom_crop?
|
96
|
-
styles[:cropped] = {:geometry => '', :convert_options => "-resize #{crop_s}% -crop #{crop_w}x#{crop_h}+#{crop_x}+#{crop_y}"}
|
103
|
+
styles[:cropped] = {:geometry => '', :convert_options => "-strip -resize #{crop_s}% -crop #{crop_w}x#{crop_h}+#{crop_x}+#{crop_y}"}
|
104
|
+
else
|
105
|
+
styles[:cropped] = {:geometry => '1280x1280>', :format => :jpg, :convert_options => '-strip -quality 85', :source_file_options => '-density 72'}
|
97
106
|
end
|
98
107
|
end
|
99
108
|
return styles
|
@@ -105,7 +114,7 @@ class SpudMedia < ActiveRecord::Base
|
|
105
114
|
def attachment_url(style=nil)
|
106
115
|
# defaults to cropped style if that style exists, otherwise use original
|
107
116
|
if !style
|
108
|
-
style = (is_image?
|
117
|
+
style = (is_image?) ? 'cropped' : 'original'
|
109
118
|
end
|
110
119
|
if Spud::Media.paperclip_storage == :s3 && is_protected
|
111
120
|
return Paperclip::Interpolations.interpolate(Spud::Media.config.storage_url, attachment, style)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= content_tag :div, :class => 'spud_media_picker_item',
|
2
2
|
'data-id' => media.id,
|
3
3
|
'data-type' => (media.is_image? ? 'img' : 'file'),
|
4
|
-
'data-url' => media.
|
4
|
+
'data-url' => media.attachment_url,
|
5
5
|
'data-name' => media.attachment_file_name,
|
6
6
|
'data-size' => media.attachment_file_size,
|
7
7
|
'data-lastmod' => media.attachment_updated_at.blank? == false ? media.attachment_updated_at.strftime("%l:%M %p, %D") : '',
|
@@ -1,11 +1,13 @@
|
|
1
1
|
module Spud
|
2
2
|
module Media
|
3
3
|
include ActiveSupport::Configurable
|
4
|
-
|
4
|
+
require 'active_support/core_ext/numeric/bytes'
|
5
|
+
config_accessor :paperclip_storage, :s3_credentials, :storage_path, :storage_path_protected, :storage_url, :max_upload_size
|
5
6
|
self.paperclip_storage = :filesystem
|
6
7
|
self.s3_credentials = "#{Rails.root}/config/s3.yml"
|
7
8
|
self.storage_path = ":rails_root/public/system/spud_media/:id/:style/:basename.:extension"
|
8
9
|
self.storage_path_protected = ":rails_root/public/system/spud_media_protected/:id/:style/:basename.:extension"
|
9
10
|
self.storage_url = "/system/spud_media/:id/:style/:basename.:extension"
|
11
|
+
self.max_upload_size = 15.megabytes
|
10
12
|
end
|
11
13
|
end
|
data/lib/spud_media/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tb_media
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Westlake Design
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.2.
|
33
|
+
version: 1.2.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.2.
|
40
|
+
version: 1.2.7
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: paperclip
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|