spud_media 0.9.7 → 1.0.0.rc1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d7b6b5fa84c4a3a36db6186d469051782cba93fe
4
+ data.tar.gz: 68c0d642b5af1827165ea2984c1d094bfe69d36a
5
+ SHA512:
6
+ metadata.gz: ec056de961a21b5d51c6086216e3090d15548333501147aa1d00ce854a682befe33b1edabae1a6aaa84a4a69df6ce06ca0f948eada73393086951ce04d192ab3
7
+ data.tar.gz: dae05ef3195f08dc484d617266702771d9d5fc9aef557ee91d51ad9d99b82250da33e047ad770f6149e69e5144cdb62dcf141de70e588e92cede2c53b295c768
@@ -19,15 +19,15 @@ spud.admin.media = new function(){
19
19
 
20
20
  this.edit = function(){
21
21
  cropimage = $('#spud_media_cropper_image');
22
- // IE8 isn't handling the image load event properly, so...
23
- setTimeout(function(){
22
+
24
23
  if(cropimage[0].complete){
25
- self.initializeEditor();
24
+ self.initializeEditor.call(self);
26
25
  }
27
26
  else{
28
- self.edit();
27
+ $(copimage[0]).load(function() {
28
+ self.initializeEditor.call(self);
29
+ })
29
30
  }
30
- }, 50);
31
31
  };
32
32
 
33
33
  this.initializeEditor = function(){
@@ -42,7 +42,7 @@ spud.admin.media = new function(){
42
42
 
43
43
  // the max width is 900px (at least until the UI can handle more than that)
44
44
  if(originalWidth > 900){
45
- maxcropscale = Math.floor(900 / originalWidth * 100);
45
+ maxcropscale = Math.floor((900 / originalWidth)* 100);
46
46
  }
47
47
  else{
48
48
  maxcropscale = 100;
@@ -65,8 +65,10 @@ spud.admin.media = new function(){
65
65
  // update height of artbox to match height of scaled image
66
66
  cropartbox.height(originalHeight * (maxcropscale / 100));
67
67
 
68
+
68
69
  self.resizeAndCenter(cropscale);
69
70
 
71
+
70
72
  $('body').on('change', '#spud_media_crop_s', self.changedMediaCropScale);
71
73
  $('body').on('click', '#spud_media_cropper_resize_up, #spud_media_cropper_resize_down', self.incrementMediaCropScale);
72
74
  $('body').on('change', '#spud_media_crop_x, #spud_media_crop_y, #spud_media_crop_w, #spud_media_crop_h', self.changedMediaCropDimensions);
@@ -81,8 +83,8 @@ spud.admin.media = new function(){
81
83
  }
82
84
 
83
85
  // initialize jcrop. snap to pre-existing selection if one exists.
84
- var _width = Math.min(900, (originalWidth * (percent / 100)));
85
- var _height = originalHeight * (_width / originalWidth);
86
+ var _width = Math.floor(Math.min(900, (originalWidth * (percent / 100))));
87
+ var _height = Math.floor(originalHeight * (_width / originalWidth));
86
88
  cropimage.Jcrop({
87
89
  boxWidth:_width,
88
90
  boxHeight:_height,
@@ -96,8 +98,8 @@ spud.admin.media = new function(){
96
98
  );
97
99
 
98
100
  // using the outer container, center the jcrop object in the artboard
99
- var _left = (900 - _width) / 2;
100
- var _top = (cropartbox.height() - _height) / 6;
101
+ var _left = Math.floor((900 - _width) / 2);
102
+ var _top = Math.floor((cropartbox.height() - _height) / 6);
101
103
  cropcontainer.css({
102
104
  left:_left,
103
105
  top:_top
@@ -172,4 +174,4 @@ spud.admin.media = new function(){
172
174
  return false;
173
175
  }
174
176
  };
175
- };
177
+ };
@@ -19,7 +19,7 @@ class Spud::Admin::MediaController < Spud::Admin::ApplicationController
19
19
  def create
20
20
  @page_name = "New Media"
21
21
  add_breadcrumb "New", :new_spud_admin_medium_path
22
- @media = SpudMedia.new(params[:spud_media])
22
+ @media = SpudMedia.new(media_params)
23
23
  location = spud_admin_media_path
24
24
  if @media.save
25
25
  flash[:notice] = "File uploaded successfully"
@@ -47,7 +47,7 @@ class Spud::Admin::MediaController < Spud::Admin::ApplicationController
47
47
  end
48
48
 
49
49
  def update
50
- if @media.update_attributes(params[:spud_media])
50
+ if @media.update_attributes(media_params)
51
51
  @media.attachment.reprocess!
52
52
  end
53
53
  respond_with @media, :location => spud_admin_media_url
@@ -73,4 +73,8 @@ private
73
73
  end
74
74
 
75
75
  end
76
+
77
+ def media_params
78
+ params.require(:spud_media).permit(:attachment_content_type,:attachment_file_name,:attachment_file_size,:attachment, :is_protected, :crop_x, :crop_y, :crop_w, :crop_h, :crop_s)
79
+ end
76
80
  end
@@ -11,7 +11,7 @@ class Spud::Admin::MediaPickerController < Spud::Admin::ApplicationController
11
11
  end
12
12
 
13
13
  def create
14
- @media = SpudMedia.new(params[:spud_media])
14
+ @media = SpudMedia.new(media_params)
15
15
  if @media.save
16
16
  if request.xhr?
17
17
  render 'create', :status => 200
@@ -25,4 +25,9 @@ class Spud::Admin::MediaPickerController < Spud::Admin::ApplicationController
25
25
  end
26
26
  end
27
27
 
28
- end
28
+ private
29
+ def media_params
30
+ params.require(:spud_media).permit(:attachment_content_type,:attachment_file_name,:attachment_file_size,:attachment, :is_protected, :crop_x, :crop_y, :crop_w, :crop_h, :crop_s)
31
+ end
32
+
33
+ end
@@ -14,10 +14,10 @@ class SpudMedia < ActiveRecord::Base
14
14
  :url => Spud::Media.storage_url,
15
15
  :styles => lambda { |attachment| attachment.instance.dynamic_styles }
16
16
 
17
- attr_accessible :attachment_content_type,:attachment_file_name,:attachment_file_size,:attachment, :is_protected, :crop_x, :crop_y, :crop_w, :crop_h, :crop_s
17
+ # attr_accessible :attachment_content_type,:attachment_file_name,:attachment_file_size,:attachment, :is_protected, :crop_x, :crop_y, :crop_w, :crop_h, :crop_s
18
18
 
19
19
  validates_numericality_of :crop_x, :crop_y, :crop_w, :crop_h, :crop_s, :allow_nil => true
20
-
20
+ validates :attachment, :presence => true
21
21
  before_create :rename_file
22
22
  before_update :rename_file
23
23
  #after_create :validate_permissions
@@ -29,13 +29,17 @@ class SpudMedia < ActiveRecord::Base
29
29
  return
30
30
  end
31
31
  # remove periods and other unsafe characters from file name to make routing easier
32
- extension = File.extname(attachment_file_name)
33
- filename = attachment_file_name.chomp(extension).parameterize
34
- attachment.instance_write :file_name, filename + extension
32
+ if self.attachment_file_name.blank? == false
33
+ extension = File.extname(attachment_file_name)
34
+ filename = attachment_file_name.chomp(extension).parameterize
35
+ attachment.instance_write :file_name, filename + extension
36
+ end
35
37
  end
36
38
 
37
39
  def image_from_type
38
-
40
+ if self.attachment_content_type.blank?
41
+ return "spud/admin/files_thumbs/dat_thumb.png"
42
+ end
39
43
  if self.is_image? || self.is_pdf?
40
44
  return self.attachment_url(:small)
41
45
 
@@ -74,7 +78,7 @@ class SpudMedia < ActiveRecord::Base
74
78
  end
75
79
 
76
80
  def is_image?
77
- if self.attachment_content_type.match(/jpeg|jpg|png/)
81
+ if self.attachment_content_type.blank? == false && self.attachment_content_type.match(/jpeg|jpg|png/)
78
82
  return true
79
83
  else
80
84
  return false
@@ -47,4 +47,4 @@
47
47
 
48
48
  <script type="text/javascript">
49
49
  $(window).load(spud.admin.media.edit);
50
- </script>
50
+ </script>
@@ -3,7 +3,7 @@
3
3
  <title>Spud Media Picker</title>
4
4
  <%= stylesheet_link_tag *Spud::Core.config.admin_stylesheets %>
5
5
  <%= javascript_include_tag *Spud::Core.config.admin_javascripts %>
6
- <%= javascript_include_tag 'tiny_mce/tiny_mce_popup' %>
6
+ <%= javascript_include_tag 'tinymce/tiny_mce_popup' %>
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body class="spud_media_picker">
@@ -100,4 +100,4 @@
100
100
  </script>
101
101
 
102
102
  </body>
103
- </html>
103
+ </html>
@@ -10,5 +10,5 @@ Rails.application.routes.draw do
10
10
  end
11
11
 
12
12
  #get '/media/protected/:id/:style/:filename' => 'ProtectedMedia#show', :as => 'protected_media'
13
- get Spud::Media.config.storage_url => 'ProtectedMedia#show', :as => 'protected_media'
13
+ get Spud::Media.config.storage_url => 'protected_media#show', :as => 'protected_media'
14
14
  end
@@ -1,5 +1,6 @@
1
1
  require 'spud_core'
2
2
  require 'paperclip'
3
+ require 'tinymce-rails'
3
4
  module Spud
4
5
  module Media
5
6
  class Engine < Rails::Engine
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Media
3
- VERSION = "0.9.7"
3
+ VERSION = "1.0.0.rc1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,116 +1,102 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spud_media
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
5
- prerelease:
4
+ version: 1.0.0.rc1
6
5
  platform: ruby
7
6
  authors:
8
7
  - David Estes
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-07-13 00:00:00.000000000 Z
11
+ date: 2014-01-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: 3.2.2
19
+ version: 4.0.0
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: 3.2.2
26
+ version: 4.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: spud_core
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
- version: 0.9.0
33
+ version: 1.0.0.rc1
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
- version: 0.9.0
40
+ version: 1.0.0.rc1
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: paperclip
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: mysql2
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - '='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
- version: 0.3.11
61
+ version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - '='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
- version: 0.3.11
68
+ version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: rspec
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
73
  - - '='
84
74
  - !ruby/object:Gem::Version
85
- version: 2.8.0
75
+ version: 2.14.0
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
80
  - - '='
92
81
  - !ruby/object:Gem::Version
93
- version: 2.8.0
82
+ version: 2.14.0
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: rspec-rails
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
87
  - - '='
100
88
  - !ruby/object:Gem::Version
101
- version: 2.8.1
89
+ version: 2.14.0
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
94
  - - '='
108
95
  - !ruby/object:Gem::Version
109
- version: 2.8.1
96
+ version: 2.14.0
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: shoulda
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
101
  - - ~>
116
102
  - !ruby/object:Gem::Version
@@ -118,7 +104,6 @@ dependencies:
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
108
  - - ~>
124
109
  - !ruby/object:Gem::Version
@@ -126,55 +111,48 @@ dependencies:
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: factory_girl
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - '='
115
+ - - ~>
132
116
  - !ruby/object:Gem::Version
133
- version: 2.5.0
117
+ version: '3.0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - '='
122
+ - - ~>
140
123
  - !ruby/object:Gem::Version
141
- version: 2.5.0
124
+ version: '3.0'
142
125
  - !ruby/object:Gem::Dependency
143
- name: mocha
126
+ name: database_cleaner
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
129
  - - '='
148
130
  - !ruby/object:Gem::Version
149
- version: 0.10.3
131
+ version: 1.0.0.RC1
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
136
  - - '='
156
137
  - !ruby/object:Gem::Version
157
- version: 0.10.3
138
+ version: 1.0.0.RC1
158
139
  - !ruby/object:Gem::Dependency
159
- name: database_cleaner
140
+ name: mocha
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
143
  - - '='
164
144
  - !ruby/object:Gem::Version
165
- version: 0.7.1
145
+ version: 0.14.0
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
150
  - - '='
172
151
  - !ruby/object:Gem::Version
173
- version: 0.7.1
152
+ version: 0.14.0
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: simplecov
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
157
  - - ~>
180
158
  - !ruby/object:Gem::Version
@@ -182,7 +160,6 @@ dependencies:
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
164
  - - ~>
188
165
  - !ruby/object:Gem::Version
@@ -256,34 +233,27 @@ files:
256
233
  - MIT-LICENSE
257
234
  - Rakefile
258
235
  - Readme.markdown
259
- homepage: http://www.github.com/davydotcom/spud_media
236
+ homepage: http://www.github.com/spud-rails/spud_media
260
237
  licenses: []
238
+ metadata: {}
261
239
  post_install_message:
262
240
  rdoc_options: []
263
241
  require_paths:
264
242
  - lib
265
243
  required_ruby_version: !ruby/object:Gem::Requirement
266
- none: false
267
244
  requirements:
268
- - - ! '>='
245
+ - - '>='
269
246
  - !ruby/object:Gem::Version
270
247
  version: '0'
271
- segments:
272
- - 0
273
- hash: -416899076259161455
274
248
  required_rubygems_version: !ruby/object:Gem::Requirement
275
- none: false
276
249
  requirements:
277
- - - ! '>='
250
+ - - '>'
278
251
  - !ruby/object:Gem::Version
279
- version: '0'
280
- segments:
281
- - 0
282
- hash: -416899076259161455
252
+ version: 1.3.1
283
253
  requirements: []
284
254
  rubyforge_project:
285
- rubygems_version: 1.8.25
255
+ rubygems_version: 2.0.5
286
256
  signing_key:
287
- specification_version: 3
257
+ specification_version: 4
288
258
  summary: Spud File upload/management module
289
259
  test_files: []