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 +4 -4
- data/lib/lalala/engine.rb +7 -5
- data/lib/lalala/ext_action_dispatch/multi_file_upload.rb +50 -0
- data/lib/lalala/ext_action_dispatch.rb +5 -0
- data/lib/lalala/ext_rack.rb +0 -1
- data/lib/lalala/version.rb +1 -1
- data/lib/lalala.rb +2 -1
- metadata +4 -3
- data/lib/lalala/ext_rack/multiple_file_upload_support.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 73609f4472f75f7fdf1b713692c0c68a53d2e10c
|
4
|
+
data.tar.gz: e26976faaa534964bb51a6425ae026c75ea2c88c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/lalala/ext_rack.rb
CHANGED
data/lib/lalala/version.rb
CHANGED
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.
|
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
|
+
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
|