mailer-log 0.2.0 → 0.2.3
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 +4 -4
- data/app/controllers/mailer_log/admin_controller.rb +2 -6
- data/app/controllers/mailer_log/webhooks_controller.rb +2 -3
- data/app/helpers/mailer_log/spa_helper.rb +15 -18
- data/app/views/mailer_log/spa/index.html.erb +4 -4
- data/config/routes.rb +3 -6
- data/lib/mailer_log/engine.rb +13 -0
- data/lib/mailer_log/version.rb +1 -1
- data/public/mailer_log/index.html +2 -2
- metadata +1 -2
- data/app/controllers/mailer_log/assets_controller.rb +0 -42
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9549a1146ae922459b930c92b3e8d2b597967c31260cecf809eb91cd484d5de8
|
|
4
|
+
data.tar.gz: 2f6866fa48fc93054fcaf91e6b3538752df86287caa79b21d5daeb85a692f80b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f4c505ce0eb042ca077d9e9ad66fd699606f03a9c643c5b785ff3c9f508fb27b8b5407dff23e01ec75a5063be0b45a4c70d538091c767a594b95480798a3bba2
|
|
7
|
+
data.tar.gz: c02ec1955f93c463b9452f13a21577d502c33976e20beffeb724ebf0f5aaebd3d8dda0c7b7070baa020d823b41ec3cd4c71da1b9e382ede95d493747d52a6203
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module MailerLog
|
|
4
4
|
class AdminController < ::AdminsController
|
|
5
|
-
|
|
5
|
+
helper Rails.application.routes.url_helpers
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
before_action :authenticate_mailer_log!
|
|
8
8
|
|
|
9
9
|
private
|
|
10
10
|
|
|
@@ -13,9 +13,5 @@ module MailerLog
|
|
|
13
13
|
|
|
14
14
|
MailerLog.configuration.authenticate_with_proc.call(self)
|
|
15
15
|
end
|
|
16
|
-
|
|
17
|
-
def render_not_found
|
|
18
|
-
raise ActionController::RoutingError, 'Not Found'
|
|
19
|
-
end
|
|
20
16
|
end
|
|
21
17
|
end
|
|
@@ -5,7 +5,7 @@ module MailerLog
|
|
|
5
5
|
skip_before_action :verify_authenticity_token
|
|
6
6
|
|
|
7
7
|
before_action :verify_signature
|
|
8
|
-
before_action :
|
|
8
|
+
before_action :handle_deduplicate_event
|
|
9
9
|
|
|
10
10
|
# POST /mailer_log/webhooks/mailgun
|
|
11
11
|
def mailgun
|
|
@@ -55,12 +55,11 @@ module MailerLog
|
|
|
55
55
|
head :unauthorized
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
def
|
|
58
|
+
def handle_deduplicate_event
|
|
59
59
|
event_id = params.dig('event-data', 'id')
|
|
60
60
|
return true unless event_id
|
|
61
61
|
|
|
62
62
|
cache_key = "mailer_log:event:#{event_id}"
|
|
63
|
-
|
|
64
63
|
if Rails.cache.exist?(cache_key)
|
|
65
64
|
head :ok
|
|
66
65
|
return false
|
|
@@ -2,18 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module MailerLog
|
|
4
4
|
module SpaHelper
|
|
5
|
-
|
|
6
|
-
manifest = mailer_log_manifest
|
|
7
|
-
base_path = request.script_name
|
|
8
|
-
return "#{base_path}/assets/#{name}" unless manifest
|
|
9
|
-
|
|
10
|
-
entry = manifest[name] || manifest["src/#{name}"] || manifest["assets/#{name}"]
|
|
11
|
-
return "#{base_path}/assets/#{name}" unless entry
|
|
12
|
-
|
|
13
|
-
file = entry.is_a?(Hash) ? entry['file'] : entry
|
|
14
|
-
# Manifest paths already include 'assets/' prefix
|
|
15
|
-
"#{base_path}/#{file}"
|
|
16
|
-
end
|
|
5
|
+
ASSET_BASE_PATH = '/mailer_log'
|
|
17
6
|
|
|
18
7
|
def mailer_log_js_entry
|
|
19
8
|
manifest = mailer_log_manifest
|
|
@@ -22,7 +11,8 @@ module MailerLog
|
|
|
22
11
|
entry = manifest['index.html'] || manifest['src/main.js']
|
|
23
12
|
return nil unless entry
|
|
24
13
|
|
|
25
|
-
entry.is_a?(Hash) ? entry['file'] : entry
|
|
14
|
+
file = entry.is_a?(Hash) ? entry['file'] : entry
|
|
15
|
+
"#{ASSET_BASE_PATH}/#{file}"
|
|
26
16
|
end
|
|
27
17
|
|
|
28
18
|
def mailer_log_css_entry
|
|
@@ -32,18 +22,25 @@ module MailerLog
|
|
|
32
22
|
entry = manifest['index.html']
|
|
33
23
|
return nil unless entry.is_a?(Hash)
|
|
34
24
|
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
css_file = entry['css']&.first
|
|
26
|
+
return nil unless css_file
|
|
27
|
+
|
|
28
|
+
"#{ASSET_BASE_PATH}/#{css_file}"
|
|
37
29
|
end
|
|
38
30
|
|
|
39
31
|
private
|
|
40
32
|
|
|
41
33
|
def mailer_log_manifest
|
|
42
34
|
@mailer_log_manifest ||= begin
|
|
43
|
-
|
|
44
|
-
|
|
35
|
+
# First check Rails app's public (after assets:precompile)
|
|
36
|
+
rails_manifest = Rails.root.join('public', 'mailer_log', '.vite', 'manifest.json')
|
|
37
|
+
return JSON.parse(File.read(rails_manifest)) if File.exist?(rails_manifest)
|
|
38
|
+
|
|
39
|
+
# Fallback to gem's built-in assets
|
|
40
|
+
gem_manifest = MailerLog::Engine.root.join('public', 'mailer_log', '.vite', 'manifest.json')
|
|
41
|
+
return JSON.parse(File.read(gem_manifest)) if File.exist?(gem_manifest)
|
|
45
42
|
|
|
46
|
-
|
|
43
|
+
nil
|
|
47
44
|
end
|
|
48
45
|
end
|
|
49
46
|
end
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Email Log</title>
|
|
7
7
|
<% if (css = mailer_log_css_entry) %>
|
|
8
|
-
<link rel="stylesheet" href="<%=
|
|
8
|
+
<link rel="stylesheet" href="<%= css %>">
|
|
9
9
|
<% else %>
|
|
10
|
-
<script type="module" src="http://localhost:5173/@vite/client"></script>
|
|
10
|
+
<script type="module" src="http://localhost:5173/mailer_log/@vite/client"></script>
|
|
11
11
|
<% end %>
|
|
12
12
|
</head>
|
|
13
13
|
<body class="bg-gray-100 min-h-screen">
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
<% end %>
|
|
24
24
|
<div id="app"></div>
|
|
25
25
|
<% if (js = mailer_log_js_entry) %>
|
|
26
|
-
<script type="module" src="<%=
|
|
26
|
+
<script type="module" src="<%= js %>"></script>
|
|
27
27
|
<% else %>
|
|
28
|
-
<script type="module" src="http://localhost:5173/src/main.js"></script>
|
|
28
|
+
<script type="module" src="http://localhost:5173/mailer_log/src/main.js"></script>
|
|
29
29
|
<% end %>
|
|
30
30
|
</body>
|
|
31
31
|
</html>
|
data/config/routes.rb
CHANGED
|
@@ -10,10 +10,7 @@ MailerLog::Engine.routes.draw do
|
|
|
10
10
|
resources :mailers, only: :index
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
#
|
|
14
|
-
get '
|
|
15
|
-
|
|
16
|
-
# SPA catch-all - serves Vue app for all other routes
|
|
17
|
-
get '/', to: 'spa#index'
|
|
18
|
-
get '/*path', to: 'spa#index', constraints: ->(req) { !req.path.start_with?('/api', '/webhooks', '/assets') }
|
|
13
|
+
# SPA catch-all - serves Vue app for all routes
|
|
14
|
+
get '*path', to: 'spa#index'
|
|
15
|
+
root to: 'spa#index'
|
|
19
16
|
end
|
data/lib/mailer_log/engine.rb
CHANGED
|
@@ -29,6 +29,19 @@ module MailerLog
|
|
|
29
29
|
g.factory_bot dir: 'spec/factories'
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
+
# Serve gem's static assets at /mailer_log/
|
|
33
|
+
initializer 'mailer_log.static_assets' do |app|
|
|
34
|
+
next unless app.config.public_file_server.enabled
|
|
35
|
+
|
|
36
|
+
gem_public = MailerLog::Engine.root.join('public').to_s
|
|
37
|
+
app.middleware.insert_before(
|
|
38
|
+
ActionDispatch::Static,
|
|
39
|
+
ActionDispatch::Static,
|
|
40
|
+
gem_public,
|
|
41
|
+
headers: { 'Cache-Control' => 'public, max-age=31536000' }
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
32
45
|
# Load rake tasks
|
|
33
46
|
rake_tasks do
|
|
34
47
|
load MailerLog::Engine.root.join('lib', 'tasks', 'mailer_log.rake')
|
data/lib/mailer_log/version.rb
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
6
|
<title>Email Log</title>
|
|
7
|
-
<script type="module" crossorigin src="/
|
|
8
|
-
<link rel="stylesheet" crossorigin href="/
|
|
7
|
+
<script type="module" crossorigin src="/mailer_log/assets/mailer_log-zD1d7Bvi.js"></script>
|
|
8
|
+
<link rel="stylesheet" crossorigin href="/mailer_log/assets/index-D3WsYsVX.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
|
11
11
|
<div id="app"></div>
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mailer-log
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- TrafficRunners
|
|
@@ -75,7 +75,6 @@ files:
|
|
|
75
75
|
- app/controllers/mailer_log/api/emails_controller.rb
|
|
76
76
|
- app/controllers/mailer_log/api/mailers_controller.rb
|
|
77
77
|
- app/controllers/mailer_log/application_controller.rb
|
|
78
|
-
- app/controllers/mailer_log/assets_controller.rb
|
|
79
78
|
- app/controllers/mailer_log/spa_controller.rb
|
|
80
79
|
- app/controllers/mailer_log/webhooks_controller.rb
|
|
81
80
|
- app/helpers/mailer_log/spa_helper.rb
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module MailerLog
|
|
4
|
-
class AssetsController < ActionController::Base
|
|
5
|
-
skip_forgery_protection
|
|
6
|
-
|
|
7
|
-
def show
|
|
8
|
-
file_path = MailerLog::Engine.root.join('public', 'mailer_log', 'assets', params[:path])
|
|
9
|
-
|
|
10
|
-
if File.exist?(file_path) && file_path.to_s.start_with?(MailerLog::Engine.root.join('public', 'mailer_log').to_s)
|
|
11
|
-
content_type = content_type_for(file_path)
|
|
12
|
-
send_file file_path, type: content_type, disposition: 'inline'
|
|
13
|
-
else
|
|
14
|
-
head :not_found
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
def content_type_for(file_path)
|
|
21
|
-
extension = File.extname(file_path).downcase
|
|
22
|
-
case extension
|
|
23
|
-
when '.js'
|
|
24
|
-
'application/javascript'
|
|
25
|
-
when '.css'
|
|
26
|
-
'text/css'
|
|
27
|
-
when '.map'
|
|
28
|
-
'application/json'
|
|
29
|
-
when '.svg'
|
|
30
|
-
'image/svg+xml'
|
|
31
|
-
when '.png'
|
|
32
|
-
'image/png'
|
|
33
|
-
when '.jpg', '.jpeg'
|
|
34
|
-
'image/jpeg'
|
|
35
|
-
when '.woff', '.woff2'
|
|
36
|
-
'font/woff2'
|
|
37
|
-
else
|
|
38
|
-
'application/octet-stream'
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|