effective_trash 0.2.4 → 0.2.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92e6355d34b1b5d1e73b50589906cfe539315aa7
|
4
|
+
data.tar.gz: 5aa4eb0e2378f874b5d332fcfb64c44d688994c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13c35c0f114774263e289ed237ffa8a5827753df1030fc0b3b4486de5f1a9b0456df8a1e921beb3fcf0d4375742fd935cd7901fa0fc2fb51586c20596147e093
|
7
|
+
data.tar.gz: 624af54a2026c9aed71a2a9d3b5a750d0be980641829265635882f6f71f84533da1d6331fd9fb1d983a1daa213ffd5091d90e389d5550cf2e4119897ffa50040
|
@@ -15,7 +15,7 @@ unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
|
|
15
15
|
col :trashed_to_s, label: 'Item'
|
16
16
|
|
17
17
|
col :details, visible: false do |trash|
|
18
|
-
tableize_hash(trash.details
|
18
|
+
tableize_hash(trash.details)
|
19
19
|
end
|
20
20
|
|
21
21
|
unless attributes[:actions] == false
|
@@ -1,71 +1,7 @@
|
|
1
1
|
module EffectiveTrashHelper
|
2
|
-
ALLOWED_TAGS = ActionView::Base.sanitized_allowed_tags.to_a + ['table', 'thead', 'tbody', 'tfoot', 'tr', 'td', 'th']
|
3
|
-
ALLOWED_ATTRIBUTES = ActionView::Base.sanitized_allowed_attributes.to_a + ['colspan', 'rowspan']
|
4
2
|
|
5
3
|
def render_trash(trash)
|
6
4
|
render(partial: 'effective/trash/trash', locals: {trash: trash})
|
7
5
|
end
|
8
6
|
|
9
|
-
# Call me with :th => true, :sub_th => false
|
10
|
-
# Any other options are sent to the table tag
|
11
|
-
def tableize_hash(hash, options = {})
|
12
|
-
if hash.present? && hash.kind_of?(Hash)
|
13
|
-
content_tag(:table, class: options[:class]) do
|
14
|
-
content_tag(:tbody) do
|
15
|
-
hash.map do |k, v|
|
16
|
-
content_tag(:tr) do
|
17
|
-
content_tag((options[:th] ? :th : :td), k) +
|
18
|
-
content_tag(:td) do
|
19
|
-
if v.kind_of?(Hash)
|
20
|
-
tableize_hash(v, options.merge({class: 'table table-hover', th: (options.key?(:sub_th) ? options[:sub_th] : options[:th])}))
|
21
|
-
elsif v.kind_of?(Array)
|
22
|
-
'[' + v.join(', ') + ']'
|
23
|
-
else
|
24
|
-
v.to_s
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end.join('').html_safe
|
29
|
-
end
|
30
|
-
end.html_safe
|
31
|
-
else
|
32
|
-
hash.to_s.html_safe
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def format_trash_details_value(trash, key)
|
37
|
-
value = trash.details[key]
|
38
|
-
|
39
|
-
if value.kind_of?(Hash)
|
40
|
-
tableize_hash(value, :class => 'table', :th => true)
|
41
|
-
elsif value.kind_of?(Array)
|
42
|
-
value.map { |value| effective_trash_simple_format(value) }.join.html_safe
|
43
|
-
else
|
44
|
-
value = value.to_s
|
45
|
-
|
46
|
-
open = value.index('<!DOCTYPE html') || value.index('<html')
|
47
|
-
close = value.rindex('</html>') if open.present?
|
48
|
-
return effective_trash_simple_format(value) unless (open.present? && close.present?)
|
49
|
-
|
50
|
-
before = value[0...open]
|
51
|
-
after = value[(close+7)..-1]
|
52
|
-
divide = before.sub!('<hr>', '').present?
|
53
|
-
|
54
|
-
[
|
55
|
-
h(before).gsub("\n", '<br>'),
|
56
|
-
(content_tag(:hr) if divide),
|
57
|
-
content_tag(:iframe, '',
|
58
|
-
src: '#',
|
59
|
-
style: 'frameborder: 0; border: 0; width: 100%; height: 100%;',
|
60
|
-
onload: "this.style.height=(this.contentDocument.body.scrollHeight + 30) + 'px';",
|
61
|
-
scrolling: 'no'),
|
62
|
-
h(after).gsub("\n", '<br>')
|
63
|
-
].compact.join.html_safe
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def effective_trash_simple_format(value)
|
68
|
-
simple_format(sanitize(value.to_s, :tags => ALLOWED_TAGS, :attributes => ALLOWED_ATTRIBUTES), {}, :sanitize => false)
|
69
|
-
end
|
70
|
-
|
71
7
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_trash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-05
|
11
|
+
date: 2017-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|