lalala 4.0.0.dev.157 → 4.0.0.dev.160

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ebcf9874e30a5ff5be77c9527fe11c85dac444ef
4
- data.tar.gz: 70aa26ee89ffd6bde58cb49c267e8a242485ee3c
3
+ metadata.gz: 73609f4472f75f7fdf1b713692c0c68a53d2e10c
4
+ data.tar.gz: e26976faaa534964bb51a6425ae026c75ea2c88c
5
5
  SHA512:
6
- metadata.gz: d77ddb91712874912bd41cd81b2e2b060f02f8b615191ffa72f268eb92aa3c22a9f0f1cb9e7e145bc6b4a56f2135bf55ff72de58b9ae2e8ea82a90eec5320e32
7
- data.tar.gz: 25cb004cddf823b95cdb0fd3bbf39136e1e784c1555e44d3d712f30655a8c4a91d81dcf540163df9ead64f870ab9064aee7121f0f4014bbffc23d99bc6fe3469
6
+ metadata.gz: e4e84e8afa2ecb0dd0dd9990445b607ef4baabf3b8fa53d9065ddd08e971785cc657b12210e7bb8b839cd132941364ac7568f28d13802f1e00830c35c55a3d52
7
+ data.tar.gz: 51f390345d6daad5986c7f1ad0ce7c24688dccd167c43501859dda7f1b65f3de98a4ae432dd8453cf9140515dce7a24f884a1c3e9b633c7d8c3e542e07818297
data/lib/lalala/engine.rb CHANGED
@@ -45,10 +45,6 @@ module Lalala
45
45
  'ActionDispatch::Flash',
46
46
  Lalala::ExtRack::PageLoader)
47
47
 
48
- stack.insert_before(
49
- 'ActionDispatch::Head',
50
- Lalala::ExtRack::MultipleFileUploadSupport)
51
-
52
48
  end
53
49
 
54
50
  initializer "lalala.assets", :group => :assets do |app|
@@ -104,7 +100,13 @@ module Lalala
104
100
  end
105
101
 
106
102
  ActiveSupport.on_load :action_controller do
107
- ActionDispatch::Routing::Mapper.send :include, Lalala::Pages::RouteMapper
103
+
104
+ ActionDispatch::Routing::Mapper.send(
105
+ :include, Lalala::Pages::RouteMapper)
106
+
107
+ ActionDispatch::Request.send(
108
+ :include, Lalala::ExtActionDispatch::MultiFileUpload)
109
+
108
110
  end
109
111
 
110
112
  end
@@ -0,0 +1,50 @@
1
+ module Lalala::ExtActionDispatch::MultiFileUpload
2
+
3
+ private
4
+
5
+ def normalize_parameters(value)
6
+ value = super(value)
7
+
8
+ if Hash === value
9
+ value.each do |key, v|
10
+ value[key] = correct_assets_hash_nesting(key, v)
11
+ end
12
+ end
13
+
14
+ return value
15
+ end
16
+
17
+ def correct_assets_hash_nesting(key, value)
18
+ unless key.to_s.ends_with?("_attributes")
19
+ return value
20
+ end
21
+
22
+ unless Hash === value
23
+ return value
24
+ end
25
+
26
+ if value.size == 0
27
+ return value
28
+ end
29
+
30
+ last_id = value.keys.sort_by(&:to_i).last
31
+ last_id = "#{last_id}"
32
+ assets = value[last_id].try(:[], "asset")
33
+
34
+ unless Array === assets
35
+ return value
36
+ end
37
+
38
+ unless assets.all?{ |i| ActionDispatch::Http::UploadedFile === i }
39
+ return value
40
+ end
41
+
42
+ assets.each do |file|
43
+ value[last_id] = { "asset" => file }.with_indifferent_access
44
+ last_id.succ!
45
+ end
46
+
47
+ return value
48
+ end
49
+
50
+ end
@@ -0,0 +1,5 @@
1
+ module Lalala::ExtActionDispatch
2
+ extend ActiveSupport::Autoload
3
+
4
+ autoload :MultiFileUpload
5
+ end
@@ -4,6 +4,5 @@ module Lalala::ExtRack
4
4
  autoload :CanonicalURL
5
5
  autoload :PageLoader
6
6
  autoload :I18nNegotiator
7
- autoload :MultipleFileUploadSupport
8
7
 
9
8
  end
@@ -1,6 +1,6 @@
1
1
  module Lalala
2
2
  VERSION = "4.0.0"
3
- BUILD = "157"
3
+ BUILD = "160"
4
4
 
5
5
  if BUILD != ("{{BUILD_NUMBER" + "}}") # prevent sed replacement (see script/ci)
6
6
  BUILD_VERSION = "#{VERSION}.dev.#{BUILD}"
data/lib/lalala.rb CHANGED
@@ -40,9 +40,10 @@ module Lalala
40
40
  require 'formtastic/inputs/grid_input'
41
41
  require 'formtastic/inputs/single_file_input'
42
42
 
43
+ autoload :ExtActionDispatch
43
44
  autoload :ExtActiveRecord
44
- autoload :ExtRack
45
45
  autoload :ExtI18n
46
+ autoload :ExtRack
46
47
  autoload :ExtWithAdvisoryLock
47
48
 
48
49
  autoload :Markdown
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lalala
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.dev.157
4
+ version: 4.0.0.dev.160
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2013-05-16 00:00:00.000000000 Z
16
+ date: 2013-05-17 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: carrierwave
@@ -1371,6 +1371,8 @@ files:
1371
1371
  - lib/lalala/core/class_inheritable_setting.rb
1372
1372
  - lib/lalala/development.rb
1373
1373
  - lib/lalala/engine.rb
1374
+ - lib/lalala/ext_action_dispatch.rb
1375
+ - lib/lalala/ext_action_dispatch/multi_file_upload.rb
1374
1376
  - lib/lalala/ext_active_record.rb
1375
1377
  - lib/lalala/ext_active_record/assets.rb
1376
1378
  - lib/lalala/ext_active_record/i18n_translations_writer.rb
@@ -1384,7 +1386,6 @@ files:
1384
1386
  - lib/lalala/ext_rack.rb
1385
1387
  - lib/lalala/ext_rack/canonical_url.rb
1386
1388
  - lib/lalala/ext_rack/i18n_negotiator.rb
1387
- - lib/lalala/ext_rack/multiple_file_upload_support.rb
1388
1389
  - lib/lalala/ext_rack/page_loader.rb
1389
1390
  - lib/lalala/ext_with_advisory_lock.rb
1390
1391
  - lib/lalala/ext_with_advisory_lock/flock.rb
@@ -1,48 +0,0 @@
1
- class Lalala::ExtRack::MultipleFileUploadSupport
2
-
3
- METHODS = /^POST|PUT|PATCH$/
4
-
5
- def initialize(app)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- if METHODS === env["REQUEST_METHOD"]
11
- params = env["rack.request.form_hash"]
12
- correct_assets_hash_nesting(params)
13
- end
14
-
15
- @app.call(env)
16
- end
17
-
18
- def correct_assets_hash_nesting(params, parent=nil, key=nil)
19
- if key and key.to_s.ends_with?("_attributes")
20
- return if params.size == 0
21
-
22
- last_id = params.keys.sort_by(&:to_i).last
23
- last_id = "#{last_id}"
24
-
25
- return if params[last_id]["asset"].nil?
26
-
27
- last = params.delete(last_id)
28
- assets = last["asset"]
29
-
30
- return unless Array === assets
31
-
32
- assets.each do |file|
33
- if file.present?
34
- params[last_id] = { "asset" => file }.with_indifferent_access
35
- last_id.succ!
36
- end
37
- end
38
-
39
- else
40
- case params
41
- when Hash then params.each { |k, v| correct_assets_hash_nesting(v, params, k) }
42
- when Array then params.each { |v| correct_assets_hash_nesting(v) }
43
- end
44
-
45
- end
46
- end
47
-
48
- end