mailer-log 0.2.3 → 0.2.4
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/helpers/mailer_log/spa_helper.rb +35 -7
- data/app/views/mailer_log/spa/index.html.erb +6 -6
- data/lib/mailer_log/engine.rb +2 -1
- data/lib/mailer_log/version.rb +1 -1
- data/lib/tasks/mailer_log.rake +14 -21
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3785cbf9b2307b102f2665f7d1d243a8ea47a5c24279880bff1909e8f73bd298
|
|
4
|
+
data.tar.gz: acec07a5240eecd4aa838003efa4121593983aaab5854412aa847df1c264ea8c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2f9049e41b9200d4fcccafa04c25c145d255cff23fbb2cdd094e7fcf8892671b5046901ca92f8180f9c69302a1650745fe34320f898c6f8ff009858e3e74647a
|
|
7
|
+
data.tar.gz: dee222520c88d07c49b99a65d16c988ab5b4d3875653e57c03ed03acbe87368ecdda0eeb60787da3c61f50de7b3334365804bdbada95855370314ca35a877355
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
module MailerLog
|
|
4
4
|
module SpaHelper
|
|
5
|
-
ASSET_BASE_PATH = '/mailer_log'
|
|
6
|
-
|
|
7
5
|
def mailer_log_js_entry
|
|
6
|
+
return nil if mailer_log_dev_server_url
|
|
7
|
+
|
|
8
8
|
manifest = mailer_log_manifest
|
|
9
9
|
return nil unless manifest
|
|
10
10
|
|
|
@@ -12,10 +12,12 @@ module MailerLog
|
|
|
12
12
|
return nil unless entry
|
|
13
13
|
|
|
14
14
|
file = entry.is_a?(Hash) ? entry['file'] : entry
|
|
15
|
-
"#{
|
|
15
|
+
"#{asset_base_path}/#{file}"
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def mailer_log_css_entry
|
|
19
|
+
return nil if mailer_log_dev_server_url
|
|
20
|
+
|
|
19
21
|
manifest = mailer_log_manifest
|
|
20
22
|
return nil unless manifest
|
|
21
23
|
|
|
@@ -25,18 +27,44 @@ module MailerLog
|
|
|
25
27
|
css_file = entry['css']&.first
|
|
26
28
|
return nil unless css_file
|
|
27
29
|
|
|
28
|
-
"#{
|
|
30
|
+
"#{asset_base_path}/#{css_file}"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def mailer_log_dev_server_url
|
|
34
|
+
return nil unless ENV['MAILER_LOG_DEV_SERVER_URL']
|
|
35
|
+
|
|
36
|
+
"#{ENV['MAILER_LOG_DEV_SERVER_URL']}/mailer_log"
|
|
29
37
|
end
|
|
30
38
|
|
|
31
39
|
private
|
|
32
40
|
|
|
41
|
+
def asset_base_path
|
|
42
|
+
# In dev, middleware serves from gem's public dir at /mailer_log/
|
|
43
|
+
# In production, assets are copied to asset pipeline dir
|
|
44
|
+
if Rails.application.config.public_file_server.enabled
|
|
45
|
+
'/mailer_log'
|
|
46
|
+
else
|
|
47
|
+
"/#{asset_output_dir}/mailer_log"
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def asset_output_dir
|
|
52
|
+
@asset_output_dir ||= if defined?(ViteRuby)
|
|
53
|
+
ViteRuby.config.public_output_dir
|
|
54
|
+
elsif defined?(Webpacker)
|
|
55
|
+
Webpacker.config.public_output_path.basename.to_s
|
|
56
|
+
else
|
|
57
|
+
'assets'
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
33
61
|
def mailer_log_manifest
|
|
34
62
|
@mailer_log_manifest ||= begin
|
|
35
|
-
#
|
|
36
|
-
rails_manifest = Rails.root.join('public', 'mailer_log', '.vite', 'manifest.json')
|
|
63
|
+
# Check Rails app's asset output directory (after assets:precompile)
|
|
64
|
+
rails_manifest = Rails.root.join('public', asset_output_dir, 'mailer_log', '.vite', 'manifest.json')
|
|
37
65
|
return JSON.parse(File.read(rails_manifest)) if File.exist?(rails_manifest)
|
|
38
66
|
|
|
39
|
-
# Fallback to gem's built-in assets
|
|
67
|
+
# Fallback to gem's built-in assets (served via middleware in dev)
|
|
40
68
|
gem_manifest = MailerLog::Engine.root.join('public', 'mailer_log', '.vite', 'manifest.json')
|
|
41
69
|
return JSON.parse(File.read(gem_manifest)) if File.exist?(gem_manifest)
|
|
42
70
|
|
|
@@ -4,10 +4,10 @@
|
|
|
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
|
-
<% if (
|
|
7
|
+
<% if (dev_url = mailer_log_dev_server_url) %>
|
|
8
|
+
<script type="module" src="<%= dev_url %>/@vite/client"></script>
|
|
9
|
+
<% elsif (css = mailer_log_css_entry) %>
|
|
8
10
|
<link rel="stylesheet" href="<%= css %>">
|
|
9
|
-
<% else %>
|
|
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">
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
<%= render partial: header_partial %>
|
|
23
23
|
<% end %>
|
|
24
24
|
<div id="app"></div>
|
|
25
|
-
<% if (
|
|
25
|
+
<% if (dev_url = mailer_log_dev_server_url) %>
|
|
26
|
+
<script type="module" src="<%= dev_url %>/src/main.js"></script>
|
|
27
|
+
<% elsif (js = mailer_log_js_entry) %>
|
|
26
28
|
<script type="module" src="<%= js %>"></script>
|
|
27
|
-
<% else %>
|
|
28
|
-
<script type="module" src="http://localhost:5173/mailer_log/src/main.js"></script>
|
|
29
29
|
<% end %>
|
|
30
30
|
</body>
|
|
31
31
|
</html>
|
data/lib/mailer_log/engine.rb
CHANGED
|
@@ -29,7 +29,8 @@ module MailerLog
|
|
|
29
29
|
g.factory_bot dir: 'spec/factories'
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
# Serve gem's static assets
|
|
32
|
+
# Serve gem's static assets in development
|
|
33
|
+
# In production, assets are copied via rake task and served by nginx
|
|
33
34
|
initializer 'mailer_log.static_assets' do |app|
|
|
34
35
|
next unless app.config.public_file_server.enabled
|
|
35
36
|
|
data/lib/mailer_log/version.rb
CHANGED
data/lib/tasks/mailer_log.rake
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
namespace :mailer_log do
|
|
4
|
-
desc 'Copy MailerLog assets to
|
|
4
|
+
desc 'Copy MailerLog assets to asset pipeline output directory'
|
|
5
5
|
task install_assets: :environment do
|
|
6
6
|
source = MailerLog::Engine.root.join('public', 'mailer_log')
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
# Detect asset output directory from ViteRuby or Webpacker
|
|
9
|
+
output_dir = if defined?(ViteRuby)
|
|
10
|
+
ViteRuby.config.public_output_dir
|
|
11
|
+
elsif defined?(Webpacker)
|
|
12
|
+
Webpacker.config.public_output_path.basename.to_s
|
|
13
|
+
else
|
|
14
|
+
'assets'
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
destination = Rails.root.join('public', output_dir, 'mailer_log')
|
|
8
18
|
|
|
9
19
|
unless source.exist?
|
|
10
20
|
puts "ERROR: MailerLog assets not found at #{source}"
|
|
@@ -12,30 +22,13 @@ namespace :mailer_log do
|
|
|
12
22
|
end
|
|
13
23
|
|
|
14
24
|
FileUtils.rm_rf(destination) if destination.exist?
|
|
25
|
+
FileUtils.mkdir_p(destination.dirname)
|
|
15
26
|
FileUtils.cp_r(source, destination)
|
|
16
27
|
puts "MailerLog assets copied to #{destination}"
|
|
17
28
|
end
|
|
18
|
-
|
|
19
|
-
desc 'Build MailerLog Vue.js frontend (for gem development only)'
|
|
20
|
-
task :build_frontend do
|
|
21
|
-
frontend_dir = MailerLog::Engine.root.join('frontend')
|
|
22
|
-
|
|
23
|
-
unless frontend_dir.exist?
|
|
24
|
-
puts 'ERROR: Frontend source not available (only in gem source, not RubyGems)'
|
|
25
|
-
exit 1
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
puts 'Installing npm dependencies...'
|
|
29
|
-
system('npm install', chdir: frontend_dir.to_s) || raise('npm install failed')
|
|
30
|
-
|
|
31
|
-
puts 'Building frontend...'
|
|
32
|
-
system('npm run build', chdir: frontend_dir.to_s) || raise('npm build failed')
|
|
33
|
-
|
|
34
|
-
puts 'Frontend built successfully!'
|
|
35
|
-
end
|
|
36
29
|
end
|
|
37
30
|
|
|
38
|
-
# Hook into assets:precompile
|
|
31
|
+
# Hook into assets:precompile
|
|
39
32
|
if Rake::Task.task_defined?('assets:precompile')
|
|
40
33
|
Rake::Task['assets:precompile'].enhance do
|
|
41
34
|
Rake::Task['mailer_log:install_assets'].invoke
|