lalala 4.0.0.dev.126 → 4.0.0.dev.128
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/formtastic/inputs/grid_input.rb +14 -7
- data/lib/lalala/uploaders/file.rb +23 -1
- data/lib/lalala/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0da73c5555e578485c8df8b6dc103ee52979291c
|
4
|
+
data.tar.gz: 2f59ea454308bd2b49142c135d35f803f5074034
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0e0d67b87ed890810cdbdedce96a9e7f21c86f5f2dc12c25db98ef4dc944641aed55e10c07d4d132b72ba7c65ff5f7229b9b757896bb4baf05d9697b7cd6bac
|
7
|
+
data.tar.gz: aa31db8c0c12f1ed3d82784bba3d8da2098982d86fbe69c4995faa23c7b1f6059931466dd197d637bb4e7ce195e0380eb6c8a6da6ddc8747d1e58edbd91c6c9d
|
@@ -5,9 +5,9 @@ class Formtastic::Inputs::GridInput
|
|
5
5
|
object = builder.object
|
6
6
|
assets = object.send(method)
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
asset_model_class = object.class.reflect_on_association(method).class_name.constantize
|
9
|
+
asset_attributes = asset_model_class.accessible_attributes.to_a
|
10
|
+
asset_attributes.select! { |x| x.size > 0 and !%w(asset translations_writer).include?(x) }
|
11
11
|
|
12
12
|
ul = template.content_tag :ul do
|
13
13
|
html = template.raw("")
|
@@ -15,11 +15,18 @@ class Formtastic::Inputs::GridInput
|
|
15
15
|
assets.each_with_index do |asset, idx|
|
16
16
|
html += template.content_tag :li, class: "asset" do
|
17
17
|
builder.fields_for(method, asset) do |f|
|
18
|
-
|
18
|
+
lalala_thumb = f.object.asset.lalala_thumb
|
19
|
+
|
20
|
+
if lalala_thumb
|
21
|
+
link_inner_html = template.image_tag(lalala_thumb.url)
|
22
|
+
else
|
23
|
+
link_inner_html = ""
|
24
|
+
end
|
25
|
+
|
19
26
|
asset_html = template.raw("")
|
20
|
-
asset_html << template.link_to(
|
27
|
+
asset_html << template.link_to(link_inner_html, f.object.asset.url)
|
21
28
|
asset_html << template.content_tag(:ol, { class: "attributes" }) do
|
22
|
-
inputs =
|
29
|
+
inputs = asset_attributes.map do |ia|
|
23
30
|
f.input ia.to_sym, placeholder: ia
|
24
31
|
end
|
25
32
|
|
@@ -34,7 +41,7 @@ class Formtastic::Inputs::GridInput
|
|
34
41
|
|
35
42
|
html += template.content_tag :li do
|
36
43
|
builder.fields_for(method, assets.build) do |f|
|
37
|
-
f.file_field :asset, multiple: true, accept:
|
44
|
+
f.file_field :asset, multiple: true, accept: asset_model_class.extension_white_list
|
38
45
|
end
|
39
46
|
end
|
40
47
|
|
@@ -12,7 +12,7 @@ class Lalala::Uploaders::File < CarrierWave::Uploader::Base
|
|
12
12
|
super_url = super
|
13
13
|
if Rails.env.production? or Rails.env.staging?
|
14
14
|
if super_url
|
15
|
-
File.join("/storage/assets", super_url)
|
15
|
+
AssetURL.new(File.join("/storage/assets", super_url))
|
16
16
|
else
|
17
17
|
super_url
|
18
18
|
end
|
@@ -21,4 +21,26 @@ class Lalala::Uploaders::File < CarrierWave::Uploader::Base
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
# This class circumvents the Sprockets asset path rewriting
|
25
|
+
# by pretending that it is a full URL.
|
26
|
+
#
|
27
|
+
# @see
|
28
|
+
# https://mrhenry.basecamphq.com/projects/10235776-hetpaleis/todo_items/164031435/comments (internal)
|
29
|
+
# http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_tag
|
30
|
+
# http://apidock.com/rails/v3.2.13/ActionView/Helpers/AssetTagHelper/path_to_image
|
31
|
+
# http://apidock.com/rails/ActionView/Helpers/AssetTagHelper/image_path
|
32
|
+
# http://apidock.com/rails/ActionView/AssetPaths/compute_public_path
|
33
|
+
# http://apidock.com/rails/v3.2.13/ActionView/AssetPaths/is_uri%3F
|
34
|
+
class AssetURL < String
|
35
|
+
|
36
|
+
def to_s
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def =~(pattern)
|
41
|
+
return true
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
24
46
|
end
|
data/lib/lalala/version.rb
CHANGED