effective_logging 1.10.15 → 1.10.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0682646a2c7421ae64c51f60d4ab6cd87e1fba68
4
- data.tar.gz: fde030b741ec05381269623ef3e9e51e5efb923c
3
+ metadata.gz: fcaff27699ddd3c334777ddd01aedcf1c2d5bc9f
4
+ data.tar.gz: 67b5881b597afefe2a8e8898431ecaa69b1c72a7
5
5
  SHA512:
6
- metadata.gz: a846b9f6c2e242dbc8415fc851cdf366a9e5c21fadd399262cd9d7b29afa011f4287c93f38cc725c6e696b13dc8e77c4081c25255ff45eb4bb77ad176e0d657a
7
- data.tar.gz: 5d535d0026e1adcda96b8e62153104eab7d074661b87b3afac2f7987b1a14eb4e4e4083a97c2daf97ebac28b17b3e2a99509b5524627a8a5c79482a35663a835
6
+ metadata.gz: 6b5bb0f1e5b0a5c9a66b683585788868d9d3bac8443445dd48f58bb196f959f465c581c7b96714c5d50df55b19009c8904d960d7da2046df9712b0cc531b571c
7
+ data.tar.gz: d48f46e7133f5dfb3a5b90de83a576d098f100c182a5c7c9a88682beed2598da19d859957f89cd0ddaca66612689aee07c395ee6e6b61dabfbb82a830f7e278e
@@ -37,7 +37,7 @@ unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
37
37
  col :logs_count, visible: false
38
38
 
39
39
  col :details, visible: false, sort: false do |log|
40
- tableize_hash(log.details.except(:email), th: true, sub_th: false, width: '100%')
40
+ tableize_hash(log.details.except(:email))
41
41
  end
42
42
 
43
43
  unless attributes[:actions] == false
@@ -1,6 +1,4 @@
1
1
  module EffectiveLoggingHelper
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 bootstrap_class_for_status(status)
6
4
  case status
@@ -23,33 +21,6 @@ module EffectiveLoggingHelper
23
21
  parents.compact.reverse
24
22
  end
25
23
 
26
- # Call me with :th => true, :sub_th => false
27
- # Any other options are sent to the table tag
28
- def tableize_hash(hash, options = {})
29
- if hash.present? && hash.kind_of?(Hash)
30
- content_tag(:table, class: options[:class]) do
31
- content_tag(:tbody) do
32
- hash.map do |k, v|
33
- content_tag(:tr) do
34
- content_tag((options[:th] ? :th : :td), k) +
35
- content_tag(:td) do
36
- if v.kind_of?(Hash)
37
- tableize_hash(v, options.merge({class: 'table table-hover', th: (options.key?(:sub_th) ? options[:sub_th] : options[:th])}))
38
- elsif v.kind_of?(Array)
39
- '[' + v.join(', ') + ']'
40
- else
41
- v.to_s
42
- end
43
- end
44
- end
45
- end.join('').html_safe
46
- end
47
- end.html_safe
48
- else
49
- hash.to_s.html_safe
50
- end
51
- end
52
-
53
24
  # This is called on the Logs#show Admin page, and is intended for override by the application
54
25
  def effective_logging_object_link_to(obj, action = :show)
55
26
  if obj.kind_of?(User)
@@ -63,40 +34,30 @@ module EffectiveLoggingHelper
63
34
  end
64
35
  end
65
36
 
37
+ # tabelize_hash and format_resource_value are from effective_resources
66
38
  def format_log_details_value(log, key)
67
39
  value = log.details[key]
68
40
 
69
- if value.kind_of?(Hash)
70
- tableize_hash(value, class: 'table table-hover', th: true)
71
- elsif value.kind_of?(Array)
72
- value.map { |value| effective_logging_simple_format(value) }.join.html_safe
73
- else
74
- value = value.to_s
75
-
76
- open = value.index('<!DOCTYPE html') || value.index('<html')
77
- close = value.rindex('</html>') if open.present?
78
- return effective_logging_simple_format(value) unless (open.present? && close.present?)
79
-
80
- before = value[0...open]
81
- after = value[(close+7)..-1]
82
- divide = before.sub!('<hr>', '').present?
83
-
84
- [
85
- h(before).gsub("\n", '<br>'),
86
- (content_tag(:hr) if divide),
87
- content_tag(:iframe, '',
88
- src: effective_logging.html_part_log_path(log, key: key),
89
- style: 'frameborder: 0; border: 0; width: 100%; height: 100%;',
90
- onload: "this.style.height=(this.contentDocument.body.scrollHeight + 30) + 'px';",
91
- scrolling: 'no'),
92
- h(after).gsub("\n", '<br>')
93
- ].compact.join.html_safe
94
- end
41
+ return tableize_hash(value) unless value.kind_of?(String)
42
+
43
+ open = value.index('<!DOCTYPE html') || value.index('<html')
44
+ close = value.rindex('</html>') if open.present?
45
+ return format_resource_value(value) unless (open.present? && close.present?)
46
+
47
+ before = value[0...open]
48
+ after = value[(close+7)..-1]
49
+ divide = before.sub!('<hr>', '').present?
50
+
51
+ [
52
+ h(before).gsub("\n", '<br>'),
53
+ (content_tag(:hr) if divide),
54
+ content_tag(:iframe, '',
55
+ src: effective_logging.html_part_log_path(log, key: key),
56
+ style: 'frameborder: 0; border: 0; width: 100%; height: 100%;',
57
+ onload: "this.style.height=(this.contentDocument.body.scrollHeight + 30) + 'px';",
58
+ scrolling: 'no'),
59
+ h(after).gsub("\n", '<br>')
60
+ ].compact.join.html_safe
95
61
  end
96
62
 
97
- def effective_logging_simple_format(value)
98
- simple_format(sanitize(value.to_s, :tags => ALLOWED_TAGS, :attributes => ALLOWED_ATTRIBUTES), {}, :sanitize => false)
99
- end
100
-
101
-
102
63
  end
@@ -14,7 +14,7 @@ module ActsAsLoggable
14
14
  end
15
15
 
16
16
  included do
17
- has_many :logged_changes, -> { where(status: EffectiveLogging.log_changes_status) }, as: :associated, class_name: Effective::Log
17
+ has_many :logged_changes, -> { where(status: EffectiveLogging.log_changes_status) }, as: :associated, class_name: 'Effective::Log'
18
18
 
19
19
  around_save do |_, block|
20
20
  @acts_as_loggable_new_record = new_record?
@@ -41,7 +41,7 @@ if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
41
41
  table_column :logs_count, visible: false
42
42
 
43
43
  table_column :details, visible: false, sortable: false do |log|
44
- tableize_hash(log.details.except(:email), th: true, sub_th: false, width: '100%')
44
+ tableize_hash(log.details.except(:email), th: true, sub_th: false)
45
45
  end
46
46
 
47
47
  unless attributes[:actions] == false
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '1.10.15'.freeze
2
+ VERSION = '1.10.16'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.15
4
+ version: 1.10.16
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-06-05 00:00:00.000000000 Z
11
+ date: 2017-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails