attachment_magick 0.2.7 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -5,6 +5,7 @@ PATH
5
5
  dragonfly (>= 0.9.4)
6
6
  jquery-rails (>= 0.2.7)
7
7
  marcosinger-auto_html (>= 1.3.4)
8
+ marcosinger-css_parser (>= 1.3.0)
8
9
  rack-cache (>= 1.0)
9
10
 
10
11
  GEM
@@ -59,7 +60,7 @@ GEM
59
60
  ruby-progressbar (>= 0.0.9)
60
61
  columnize (0.3.2)
61
62
  culerity (0.2.15)
62
- dragonfly (0.9.4)
63
+ dragonfly (0.9.5)
63
64
  rack
64
65
  erubis (2.6.6)
65
66
  abstract (>= 1.0.0)
@@ -67,7 +68,7 @@ GEM
67
68
  rake (>= 0.8.7)
68
69
  hpricot (0.8.4)
69
70
  i18n (0.5.0)
70
- jquery-rails (1.0.11)
71
+ jquery-rails (1.0.13)
71
72
  railties (~> 3.0)
72
73
  thor (~> 0.14)
73
74
  json_pure (1.5.1)
@@ -80,6 +81,7 @@ GEM
80
81
  treetop (~> 1.4.8)
81
82
  marcosinger-auto_html (1.3.5)
82
83
  hpricot (>= 0.8.4)
84
+ marcosinger-css_parser (1.3.0)
83
85
  mime-types (1.16)
84
86
  minitest (2.1.0)
85
87
  mongo (1.3.0)
@@ -92,7 +94,7 @@ GEM
92
94
  nokogiri (1.4.4)
93
95
  polyglot (0.3.1)
94
96
  rack (1.2.2)
95
- rack-cache (1.0.2)
97
+ rack-cache (1.0.3)
96
98
  rack (>= 0.4)
97
99
  rack-mount (0.6.14)
98
100
  rack (>= 1.0.0)
@@ -6,8 +6,8 @@ Gem::Specification.new do |s|
6
6
  s.name = "attachment_magick"
7
7
  s.version = AttachmentMagick::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Marco Antônio Singer", "Carlos Brando"]
10
- s.email = ["markaum@gmail.com", "eduardobrando@gmail.com"]
9
+ s.authors = ["Marco Antônio Singer", "Carlos Brando", "Lucas Renan"]
10
+ s.email = ["markaum@gmail.com", "eduardobrando@gmail.com", "contato@lucasrenan.com"]
11
11
  s.homepage = "http://github.com/marcosinger/attachment_magick"
12
12
  s.summary = "little more magick when you upload image files (with SwfUpload and Dragonfly)"
13
13
 
@@ -22,4 +22,5 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency 'rack-cache', '>= 1.0'
23
23
  s.add_dependency 'jquery-rails', '>= 0.2.7'
24
24
  s.add_dependency 'marcosinger-auto_html', '>= 1.3.4'
25
+ s.add_dependency 'marcosinger-css_parser', '>= 1.3.0'
25
26
  end
@@ -1,7 +1,9 @@
1
1
  require "attachment_magick/configuration/custom_style"
2
+ require 'css_parser'
2
3
 
3
4
  module AttachmentMagick
4
5
  class Configuration
6
+ include CssParser
5
7
 
6
8
  attr_accessor :columns_amount
7
9
  attr_accessor :columns_width
@@ -26,5 +28,27 @@ module AttachmentMagick
26
28
  return @custom_styles
27
29
  end
28
30
  end
31
+
32
+ def parse_stylesheet(stylesheet)
33
+ return if stylesheet.blank?
34
+
35
+ stylesheet_file = Dir.glob(File.join(Rails.root, "public", "**", "#{stylesheet}")).first
36
+ parser = CssParser::Parser.new
37
+
38
+ if stylesheet_file
39
+ parser.load_uri!(stylesheet_file)
40
+
41
+ all_containers = parser.find_by_selector(/\.container/).keys
42
+ container = all_containers.first
43
+ container_width = parser.find_by_selector(/\.container/)[container]["width"].to_i
44
+ grid_1 = parser.find_by_selector(/\b(grid_1)\b/).values
45
+ grid_1_width = grid_1.detect{|attr| attr["width"]}["width"].to_i
46
+ gutter = grid_1.map{|attr| attr.values_at('margin-left')}.flatten.compact.join.to_i
47
+
48
+ @columns_width = grid_1_width
49
+ @gutter = gutter
50
+ @columns_amount = container_width/(@columns_width+@gutter*2)
51
+ end
52
+ end
29
53
  end
30
54
  end
@@ -1,3 +1,3 @@
1
1
  module AttachmentMagick
2
- VERSION = "0.2.7"
2
+ VERSION = "0.3"
3
3
  end
@@ -99,6 +99,30 @@ class AttachmentMagickTest < ActiveSupport::TestCase
99
99
  assert_equal 1024, Artist.attachment_magick_default_options[:styles][:full][:width]
100
100
  end
101
101
 
102
+ def test_setup_with_stylesheet
103
+ assert_equal 19, AttachmentMagick.configuration.columns_amount
104
+ assert_equal 54, AttachmentMagick.configuration.columns_width
105
+ assert_equal 3, AttachmentMagick.configuration.gutter
106
+
107
+ AttachmentMagick.setup {|config| config.parse_stylesheet 'old_grid.css'}
108
+
109
+ assert_equal 12, AttachmentMagick.configuration.columns_amount
110
+ assert_equal 60, AttachmentMagick.configuration.columns_width
111
+ assert_equal 10, AttachmentMagick.configuration.gutter
112
+
113
+ AttachmentMagick.setup {|config| config.parse_stylesheet 'grid.css'}
114
+
115
+ assert_equal 19, AttachmentMagick.configuration.columns_amount
116
+ assert_equal 54, AttachmentMagick.configuration.columns_width
117
+ assert_equal 4, AttachmentMagick.configuration.gutter
118
+
119
+ AttachmentMagick.setup {|config| config.parse_stylesheet 'not_found.css'}
120
+
121
+ assert_equal 19, AttachmentMagick.configuration.columns_amount
122
+ assert_equal 54, AttachmentMagick.configuration.columns_width
123
+ assert_equal 4, AttachmentMagick.configuration.gutter
124
+ end
125
+
102
126
  private
103
127
 
104
128
  def order_array(array)
@@ -0,0 +1,374 @@
1
+ /*
2
+ Variable Grid System.
3
+ Learn more ~ http://www.spry-soft.com/grids/
4
+ Based on 960 Grid System - http://960.gs/
5
+
6
+ Licensed under GPL and MIT.
7
+ */
8
+
9
+ /*
10
+ Forces backgrounds to span full width,
11
+ even if there is horizontal scrolling.
12
+ Increase this if your layout is wider.
13
+
14
+ Note: IE6 works fine without this fix.
15
+ */
16
+
17
+ body {
18
+ min-width: 960px;
19
+ }
20
+
21
+ /* Containers
22
+ ----------------------------------------------------------------------------------------------------*/
23
+ .container_12 {
24
+ margin-left: auto;
25
+ margin-right: auto;
26
+ width: 960px;
27
+ }
28
+
29
+ /* Grid >> Global
30
+ ----------------------------------------------------------------------------------------------------*/
31
+
32
+
33
+ .grid_1,
34
+ .grid_2,
35
+ .grid_3,
36
+ .grid_4,
37
+ .grid_5,
38
+ .grid_6,
39
+ .grid_7,
40
+ .grid_8,
41
+ .grid_9,
42
+ .grid_10,
43
+ .grid_11,
44
+ .grid_12 {
45
+ display:inline;
46
+ float: left;
47
+ position: relative;
48
+ margin-left: 10px;
49
+ margin-right: 10px;
50
+ }
51
+
52
+
53
+
54
+ .push_1, .pull_1,
55
+ .push_2, .pull_2,
56
+ .push_3, .pull_3,
57
+ .push_4, .pull_4,
58
+ .push_5, .pull_5,
59
+ .push_6, .pull_6,
60
+ .push_7, .pull_7,
61
+ .push_8, .pull_8,
62
+ .push_9, .pull_9,
63
+ .push_10, .pull_10,
64
+ .push_11, .pull_11,
65
+ .push_12, .pull_12 {
66
+ position:relative;
67
+ }
68
+
69
+
70
+ /* Grid >> Children (Alpha ~ First, Omega ~ Last)
71
+ ----------------------------------------------------------------------------------------------------*/
72
+
73
+ .alpha {
74
+ margin-left: 0;
75
+ }
76
+
77
+ .omega {
78
+ margin-right: 0;
79
+ }
80
+
81
+ /* Grid >> 12 Columns
82
+ ----------------------------------------------------------------------------------------------------*/
83
+
84
+
85
+ .container_12 .grid_1 {
86
+ width:60px;
87
+ }
88
+
89
+ .container_12 .grid_2 {
90
+ width:140px;
91
+ }
92
+
93
+ .container_12 .grid_3 {
94
+ width:220px;
95
+ }
96
+
97
+ .container_12 .grid_4 {
98
+ width:300px;
99
+ }
100
+
101
+ .container_12 .grid_5 {
102
+ width:380px;
103
+ }
104
+
105
+ .container_12 .grid_6 {
106
+ width:460px;
107
+ }
108
+
109
+ .container_12 .grid_7 {
110
+ width:540px;
111
+ }
112
+
113
+ .container_12 .grid_8 {
114
+ width:620px;
115
+ }
116
+
117
+ .container_12 .grid_9 {
118
+ width:700px;
119
+ }
120
+
121
+ .container_12 .grid_10 {
122
+ width:780px;
123
+ }
124
+
125
+ .container_12 .grid_11 {
126
+ width:860px;
127
+ }
128
+
129
+ .container_12 .grid_12 {
130
+ width:940px;
131
+ }
132
+
133
+
134
+
135
+
136
+ /* Prefix Extra Space >> 12 Columns
137
+ ----------------------------------------------------------------------------------------------------*/
138
+
139
+
140
+ .container_12 .prefix_1 {
141
+ padding-left:80px;
142
+ }
143
+
144
+ .container_12 .prefix_2 {
145
+ padding-left:160px;
146
+ }
147
+
148
+ .container_12 .prefix_3 {
149
+ padding-left:240px;
150
+ }
151
+
152
+ .container_12 .prefix_4 {
153
+ padding-left:320px;
154
+ }
155
+
156
+ .container_12 .prefix_5 {
157
+ padding-left:400px;
158
+ }
159
+
160
+ .container_12 .prefix_6 {
161
+ padding-left:480px;
162
+ }
163
+
164
+ .container_12 .prefix_7 {
165
+ padding-left:560px;
166
+ }
167
+
168
+ .container_12 .prefix_8 {
169
+ padding-left:640px;
170
+ }
171
+
172
+ .container_12 .prefix_9 {
173
+ padding-left:720px;
174
+ }
175
+
176
+ .container_12 .prefix_10 {
177
+ padding-left:800px;
178
+ }
179
+
180
+ .container_12 .prefix_11 {
181
+ padding-left:880px;
182
+ }
183
+
184
+
185
+
186
+ /* Suffix Extra Space >> 12 Columns
187
+ ----------------------------------------------------------------------------------------------------*/
188
+
189
+
190
+ .container_12 .suffix_1 {
191
+ padding-right:80px;
192
+ }
193
+
194
+ .container_12 .suffix_2 {
195
+ padding-right:160px;
196
+ }
197
+
198
+ .container_12 .suffix_3 {
199
+ padding-right:240px;
200
+ }
201
+
202
+ .container_12 .suffix_4 {
203
+ padding-right:320px;
204
+ }
205
+
206
+ .container_12 .suffix_5 {
207
+ padding-right:400px;
208
+ }
209
+
210
+ .container_12 .suffix_6 {
211
+ padding-right:480px;
212
+ }
213
+
214
+ .container_12 .suffix_7 {
215
+ padding-right:560px;
216
+ }
217
+
218
+ .container_12 .suffix_8 {
219
+ padding-right:640px;
220
+ }
221
+
222
+ .container_12 .suffix_9 {
223
+ padding-right:720px;
224
+ }
225
+
226
+ .container_12 .suffix_10 {
227
+ padding-right:800px;
228
+ }
229
+
230
+ .container_12 .suffix_11 {
231
+ padding-right:880px;
232
+ }
233
+
234
+
235
+
236
+ /* Push Space >> 12 Columns
237
+ ----------------------------------------------------------------------------------------------------*/
238
+
239
+
240
+ .container_12 .push_1 {
241
+ left:80px;
242
+ }
243
+
244
+ .container_12 .push_2 {
245
+ left:160px;
246
+ }
247
+
248
+ .container_12 .push_3 {
249
+ left:240px;
250
+ }
251
+
252
+ .container_12 .push_4 {
253
+ left:320px;
254
+ }
255
+
256
+ .container_12 .push_5 {
257
+ left:400px;
258
+ }
259
+
260
+ .container_12 .push_6 {
261
+ left:480px;
262
+ }
263
+
264
+ .container_12 .push_7 {
265
+ left:560px;
266
+ }
267
+
268
+ .container_12 .push_8 {
269
+ left:640px;
270
+ }
271
+
272
+ .container_12 .push_9 {
273
+ left:720px;
274
+ }
275
+
276
+ .container_12 .push_10 {
277
+ left:800px;
278
+ }
279
+
280
+ .container_12 .push_11 {
281
+ left:880px;
282
+ }
283
+
284
+
285
+
286
+ /* Pull Space >> 12 Columns
287
+ ----------------------------------------------------------------------------------------------------*/
288
+
289
+
290
+ .container_12 .pull_1 {
291
+ left:-80px;
292
+ }
293
+
294
+ .container_12 .pull_2 {
295
+ left:-160px;
296
+ }
297
+
298
+ .container_12 .pull_3 {
299
+ left:-240px;
300
+ }
301
+
302
+ .container_12 .pull_4 {
303
+ left:-320px;
304
+ }
305
+
306
+ .container_12 .pull_5 {
307
+ left:-400px;
308
+ }
309
+
310
+ .container_12 .pull_6 {
311
+ left:-480px;
312
+ }
313
+
314
+ .container_12 .pull_7 {
315
+ left:-560px;
316
+ }
317
+
318
+ .container_12 .pull_8 {
319
+ left:-640px;
320
+ }
321
+
322
+ .container_12 .pull_9 {
323
+ left:-720px;
324
+ }
325
+
326
+ .container_12 .pull_10 {
327
+ left:-800px;
328
+ }
329
+
330
+ .container_12 .pull_11 {
331
+ left:-880px;
332
+ }
333
+
334
+
335
+
336
+
337
+ /* `Clear Floated Elements
338
+ ----------------------------------------------------------------------------------------------------*/
339
+
340
+ /* http://sonspring.com/journal/clearing-floats */
341
+
342
+ .clear {
343
+ clear: both;
344
+ display: block;
345
+ overflow: hidden;
346
+ visibility: hidden;
347
+ width: 0;
348
+ height: 0;
349
+ }
350
+
351
+ /* http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified */
352
+
353
+ .clearfix:before,
354
+ .clearfix:after {
355
+ content: '\0020';
356
+ display: block;
357
+ overflow: hidden;
358
+ visibility: hidden;
359
+ width: 0;
360
+ height: 0;
361
+ }
362
+
363
+ .clearfix:after {
364
+ clear: both;
365
+ }
366
+
367
+ /*
368
+ The following zoom:1 rule is specifically for IE6 + IE7.
369
+ Move to separate stylesheet if invalid CSS is a problem.
370
+ */
371
+
372
+ .clearfix {
373
+ zoom: 1;
374
+ }
metadata CHANGED
@@ -1,21 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachment_magick
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: '0.3'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Marco Antônio Singer
9
9
  - Carlos Brando
10
+ - Lucas Renan
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2011-08-29 00:00:00.000000000 -03:00
14
+ date: 2011-08-30 00:00:00.000000000 -03:00
14
15
  default_executable:
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: dragonfly
18
- requirement: &2156952800 !ruby/object:Gem::Requirement
19
+ requirement: &2153183920 !ruby/object:Gem::Requirement
19
20
  none: false
20
21
  requirements:
21
22
  - - ! '>='
@@ -23,10 +24,10 @@ dependencies:
23
24
  version: 0.9.4
24
25
  type: :runtime
25
26
  prerelease: false
26
- version_requirements: *2156952800
27
+ version_requirements: *2153183920
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: rack-cache
29
- requirement: &2156952300 !ruby/object:Gem::Requirement
30
+ requirement: &2153183420 !ruby/object:Gem::Requirement
30
31
  none: false
31
32
  requirements:
32
33
  - - ! '>='
@@ -34,10 +35,10 @@ dependencies:
34
35
  version: '1.0'
35
36
  type: :runtime
36
37
  prerelease: false
37
- version_requirements: *2156952300
38
+ version_requirements: *2153183420
38
39
  - !ruby/object:Gem::Dependency
39
40
  name: jquery-rails
40
- requirement: &2156951840 !ruby/object:Gem::Requirement
41
+ requirement: &2153182960 !ruby/object:Gem::Requirement
41
42
  none: false
42
43
  requirements:
43
44
  - - ! '>='
@@ -45,10 +46,10 @@ dependencies:
45
46
  version: 0.2.7
46
47
  type: :runtime
47
48
  prerelease: false
48
- version_requirements: *2156951840
49
+ version_requirements: *2153182960
49
50
  - !ruby/object:Gem::Dependency
50
51
  name: marcosinger-auto_html
51
- requirement: &2156951380 !ruby/object:Gem::Requirement
52
+ requirement: &2153182500 !ruby/object:Gem::Requirement
52
53
  none: false
53
54
  requirements:
54
55
  - - ! '>='
@@ -56,11 +57,23 @@ dependencies:
56
57
  version: 1.3.4
57
58
  type: :runtime
58
59
  prerelease: false
59
- version_requirements: *2156951380
60
+ version_requirements: *2153182500
61
+ - !ruby/object:Gem::Dependency
62
+ name: marcosinger-css_parser
63
+ requirement: &2153182040 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.0
69
+ type: :runtime
70
+ prerelease: false
71
+ version_requirements: *2153182040
60
72
  description:
61
73
  email:
62
74
  - markaum@gmail.com
63
75
  - eduardobrando@gmail.com
76
+ - contato@lucasrenan.com
64
77
  executables: []
65
78
  extensions: []
66
79
  extra_rdoc_files: []
@@ -164,6 +177,7 @@ files:
164
177
  - test/dummy/public/stylesheets/.gitkeep
165
178
  - test/dummy/public/stylesheets/attachment_magick.css
166
179
  - test/dummy/public/stylesheets/grid.css
180
+ - test/dummy/public/stylesheets/old_grid.css
167
181
  - test/dummy/public/stylesheets/swfupload.css
168
182
  - test/dummy/public/stylesheets/text.css
169
183
  - test/dummy/script/rails
@@ -266,6 +280,7 @@ test_files:
266
280
  - test/dummy/public/stylesheets/.gitkeep
267
281
  - test/dummy/public/stylesheets/attachment_magick.css
268
282
  - test/dummy/public/stylesheets/grid.css
283
+ - test/dummy/public/stylesheets/old_grid.css
269
284
  - test/dummy/public/stylesheets/swfupload.css
270
285
  - test/dummy/public/stylesheets/text.css
271
286
  - test/dummy/script/rails