effective_logging 1.2.6 → 1.3.0

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: 2228b86e941881682313e5f2a8cd91cc2b0f5bd0
4
- data.tar.gz: a863213ce10ff78822d9733fbf356bee1ef6826b
3
+ metadata.gz: 38bbc6736b8fba0b72a99e53e51916085da485fb
4
+ data.tar.gz: 3f1ce2418ee99754521a050f6e12f226d68750c2
5
5
  SHA512:
6
- metadata.gz: f9eeb731fe916d13881cb35ff16cf2d001383a8cbf40d26f57e0fa94dd6f6d2c32d4ac2218726207599489afe2e4d631d1248d74f71420053483e23b8e81005b
7
- data.tar.gz: 72ee7d4ba3d0727c0e2357ecaa091667d23a17a9c19697b5ac6f5a915529f865ba7817b34d291eea765977104ba575d234f507b5993fa68aa7aa34beee50b599
6
+ metadata.gz: 82561fb927e598e6d801d74bb48d86572d72143bffd148aa7461165c64754c219f9b166f01a3c4ff9ddbe74e57d36c210c300f5a592307579effd885fb669863
7
+ data.tar.gz: 07d3ae20220b4ee763593c2aa4596733b9f9c92b8f1c52699a735c58b3d72efe0d41ba4b7503da93b31e97ee9adb8b1b4432e9c1c992d0efb959bd5a76df3d44
@@ -1,6 +1,6 @@
1
1
  module Effective
2
2
  class LogsController < ApplicationController
3
- skip_log_page_views
3
+ skip_log_page_views quiet: true
4
4
  before_filter :authenticate_user!, :only => [:index, :show] # Devise ensure logged in
5
5
 
6
6
  # This is a post from our Javascript
@@ -55,6 +55,22 @@ module Effective
55
55
  EffectiveLogging.authorized?(self, :show, @log)
56
56
  end
57
57
 
58
+ def html_part
59
+ @log = Effective::Log.find(params[:id])
60
+
61
+ EffectiveLogging.authorized?(self, :show, @log)
62
+
63
+ value = @log.details[(params[:key] || '').to_sym].to_s
64
+
65
+ open = value.index('<!DOCTYPE html') || value.index('<html')
66
+ close = value.rindex('</html>') if open.present?
67
+
68
+ if open.present? && close.present?
69
+ render text: value[open...(close+7)]
70
+ else
71
+ render text: value
72
+ end
73
+ end
58
74
 
59
75
  private
60
76
 
@@ -60,15 +60,40 @@ module EffectiveLoggingHelper
60
60
  end
61
61
  end
62
62
 
63
- def format_log_details_value(value)
63
+ def format_log_details_value(log, key)
64
+ value = log.details[key]
65
+
64
66
  if value.kind_of?(Hash)
65
67
  tableize_hash(value, :class => 'table', :style => 'width: 50%', :th => true)
66
68
  elsif value.kind_of?(Array)
67
- value.map { |value| simple_format(sanitize(value.to_s, :tags => ALLOWED_TAGS, :attributes => ALLOWED_ATTRIBUTES), {}, :sanitize => false) }.join('').html_safe
69
+ value.map { |value| effective_logging_simple_format(value) }.join.html_safe
68
70
  else
69
- simple_format(sanitize(value.to_s, :tags => ALLOWED_TAGS, :attributes => ALLOWED_ATTRIBUTES), {}, :sanitize => false)
71
+ value = value.to_s
72
+
73
+ open = value.index('<!DOCTYPE html') || value.index('<html')
74
+ close = value.rindex('</html>') if open.present?
75
+ return effective_logging_simple_format(value) unless (open.present? && close.present?)
76
+
77
+ before = value[0...open]
78
+ after = value[(close+7)..-1]
79
+ divide = before.sub!('<hr>', '').present?
80
+
81
+ [
82
+ h(before).gsub("\n", '<br>'),
83
+ (content_tag(:hr) if divide),
84
+ content_tag(:iframe, '',
85
+ src: effective_logging.html_part_log_path(log, key: key),
86
+ style: 'frameborder: 0; border: 0; width: 100%; height: 100%;',
87
+ onload: "this.style.height=this.contentDocument.body.scrollHeight + 'px';",
88
+ scrolling: 'no'),
89
+ h(after).gsub("\n", '<br>')
90
+ ].compact.join.html_safe
70
91
  end
71
92
  end
72
93
 
94
+ def effective_logging_simple_format(value)
95
+ simple_format(sanitize(value.to_s, :tags => ALLOWED_TAGS, :attributes => ALLOWED_ATTRIBUTES), {}, :sanitize => false)
96
+ end
97
+
73
98
 
74
99
  end
@@ -16,6 +16,8 @@
16
16
  &nbsp;
17
17
  = log.created_at.strftime("%Y-%m-%d %H:%M:%S")
18
18
  = '(' + time_ago_in_words(log.created_at) + ' ago)'
19
+ %br
20
+ %br
19
21
 
20
22
  .col-lg-6
21
23
  - if log.user.present?
@@ -35,10 +37,9 @@
35
37
  - next unless value.present?
36
38
  .row
37
39
  .col-lg-12
38
- %br
39
40
  %p
40
41
  %strong= "#{key.to_s.titleize}:"
41
- = format_log_details_value(value)
42
+ = format_log_details_value(log, key)
42
43
 
43
44
  - if log.logs.present?
44
45
  .row
@@ -2,7 +2,9 @@ EffectiveLogging::Engine.routes.draw do
2
2
  scope :module => 'effective' do
3
3
  # Create is our javascript POST event for EffectiveLogging from JS side
4
4
  # The show and index routes are for user specific logs
5
- resources :logs, :only => [:create, :show, :index]
5
+ resources :logs, :only => [:create, :show, :index] do
6
+ member { get :html_part }
7
+ end
6
8
  end
7
9
 
8
10
  if defined?(EffectiveDatatables)
@@ -8,7 +8,7 @@ module EffectiveLogging
8
8
  message_header.gsub!(";\r\n charset", '; charset')
9
9
 
10
10
  # Cleanup the Body
11
- if (message_body = message.body.to_s).include?('<html>')
11
+ if (message_body = message.body.to_s).include?('<html')
12
12
  message_body.gsub!(/(\r)*\n\s*/, '')
13
13
  message_body.gsub!("<!DOCTYPE html>", '')
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '1.2.6'.freeze
2
+ VERSION = '1.3.0'.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.2.6
4
+ version: 1.3.0
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: 2015-12-16 00:00:00.000000000 Z
11
+ date: 2016-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -88,8 +88,11 @@ executables: []
88
88
  extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
- - app/assets/javascripts/effective_logging/effective_logger.js.coffee.erb
91
+ - MIT-LICENSE
92
+ - README.md
93
+ - Rakefile
92
94
  - app/assets/javascripts/effective_logging.js
95
+ - app/assets/javascripts/effective_logging/effective_logger.js.coffee.erb
93
96
  - app/controllers/admin/logs_controller.rb
94
97
  - app/controllers/effective/logs_controller.rb
95
98
  - app/helpers/effective_logging_helper.rb
@@ -106,18 +109,15 @@ files:
106
109
  - app/views/effective/logs/show.html.haml
107
110
  - config/routes.rb
108
111
  - db/migrate/01_create_effective_logging.rb.erb
112
+ - lib/effective_logging.rb
109
113
  - lib/effective_logging/email_logger.rb
110
114
  - lib/effective_logging/engine.rb
111
115
  - lib/effective_logging/log_page_views.rb
112
116
  - lib/effective_logging/user_logger.rb
113
117
  - lib/effective_logging/version.rb
114
- - lib/effective_logging.rb
115
118
  - lib/generators/effective_logging/install_generator.rb
116
- - lib/generators/templates/effective_logging.rb
117
119
  - lib/generators/templates/README
118
- - MIT-LICENSE
119
- - Rakefile
120
- - README.md
120
+ - lib/generators/templates/effective_logging.rb
121
121
  - spec/effective_logging_spec.rb
122
122
  - spec/spec_helper.rb
123
123
  homepage: https://github.com/code-and-effect/effective_logging
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  requirements: []
142
142
  rubyforge_project:
143
- rubygems_version: 2.0.14
143
+ rubygems_version: 2.4.6
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Automatically log all sent emails, user logins, and page views. This also