better_mailer_previews 1.0.1 → 1.0.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36d68792cf007535eae383bb8eb153c3a70be0b8a9bd8b96a30d0627bab8a657
|
|
4
|
+
data.tar.gz: 0f619790868880c9134cd48225260c2d6aa1f051e252d9c8297ebcb5e60a52e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4d79e1fbb03b4159e1a96fb5e180a3a1b1cce468bcaf39c4beccd71d62b98977a7e8eb434925a65bf064cd3076fbd8d4c40aa7e31c342ee4585358a34e49b1b1
|
|
7
|
+
data.tar.gz: b2d298320e303a19be0da6d38fbd10ea6b6deeaa30f3284f17a8108d35edf6233b6cfe47f5a60dbb47cc4aff3e229c4356d68564b0832cc5398c53289eed74ae
|
data/README.md
CHANGED
|
@@ -8,6 +8,7 @@ This gem/engine builds on top of native Rails mailer previews, with a few key en
|
|
|
8
8
|
- **Easily resize individual mailers, for testing responsive layouts**
|
|
9
9
|
- **Forward your previews to an email address (uses the default ActionMailer delivery method for your app).**
|
|
10
10
|
- **Fully compatible with, and can live alongside, native [Rails ActionMailer Previews](https://guides.rubyonrails.org/action_mailer_basics.html#previewing-emails)**
|
|
11
|
+
- **Supports namespaced mailers (think User::SignupMailer) as of v1.0.1**
|
|
11
12
|
|
|
12
13
|
Here's a little demo I've put together ↓
|
|
13
14
|
|
|
@@ -3,13 +3,12 @@ module BetterMailerPreviews
|
|
|
3
3
|
layout "better_mailer_previews/application"
|
|
4
4
|
|
|
5
5
|
def index
|
|
6
|
-
|
|
7
|
-
preview_emails = mailer_previews.map do |preview|
|
|
6
|
+
preview_emails_to_render = ActionMailer::Preview.all.map do |preview|
|
|
8
7
|
{ preview: preview, emails: preview.emails }
|
|
9
8
|
end
|
|
10
9
|
|
|
11
10
|
@urls_by_mailer = {}
|
|
12
|
-
|
|
11
|
+
preview_emails_to_render.each do |entry|
|
|
13
12
|
mailer_name = entry[:preview].name.underscore.gsub("_preview", "")
|
|
14
13
|
urls = entry[:emails].map do |email|
|
|
15
14
|
email_name = email.underscore
|
|
@@ -22,8 +21,11 @@ module BetterMailerPreviews
|
|
|
22
21
|
def show
|
|
23
22
|
@mailer_path = params[:mailer_path]
|
|
24
23
|
@email_type = params[:email_type]
|
|
24
|
+
@email_address = cookies[:better_mailer_previews_email_address]
|
|
25
25
|
|
|
26
|
+
# construct URL for <iframe>, passing through any query params
|
|
26
27
|
@url_for_mailer = "/rails/mailers/#{@mailer_path}/#{@email_type}"
|
|
28
|
+
@url_for_mailer += "?#{request.query_string}" unless request.query_string.empty?
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def send_email
|
|
@@ -34,6 +36,9 @@ module BetterMailerPreviews
|
|
|
34
36
|
email_type = params[:email_type]
|
|
35
37
|
email_address = params[:email_address]
|
|
36
38
|
|
|
39
|
+
# save email in a cookie so we can re-populate the form
|
|
40
|
+
cookies[:better_mailer_previews_email_address] = email_address
|
|
41
|
+
|
|
37
42
|
# Instantiate the preview class (ie: InvoiceMailerPreview),
|
|
38
43
|
# then render it's preview html into a string.
|
|
39
44
|
preview_class_string = mailer_path.split("/").map(&:camelize).join("::").concat("Preview")
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<div class="w-full flex justify-between items-end">
|
|
2
|
-
<
|
|
2
|
+
<div class="flex flex-col">
|
|
3
|
+
<%= link_to '← home', root_path, class: "text-sm text-gray-400 w-fit hover:text-gray-700 hover:underline" %>
|
|
4
|
+
<h1 class="text-5xl font-medium tracking-tighter"><%= @mailer_path.titleize %> — <%= @email_type.titleize %></h1>
|
|
5
|
+
</div>
|
|
3
6
|
<div class="">
|
|
4
7
|
<%= form_with url: send_mailer_email_path(mailer_path: @mailer_path, email_type: @email_type),
|
|
5
8
|
method: :post,
|
|
6
9
|
local: true,
|
|
7
10
|
class: "flex items-end gap-x-2" do |form| %>
|
|
8
11
|
<div class="flex-1">
|
|
9
|
-
<%= form.text_field :email_address, placeholder: "email address...", class: "border text-sm px-1 py-0.5 bg-gray-50 rounded-sm", required: true %>
|
|
12
|
+
<%= form.text_field :email_address, value: @email_address, placeholder: "email address...", class: "border text-sm px-1 py-0.5 bg-gray-50 rounded-sm", required: true %>
|
|
10
13
|
</div>
|
|
11
14
|
<div>
|
|
12
15
|
<%= form.submit "Send Email", class: "text-sm border px-1 py-0.5 hover:bg-gray-200 hover:cursor-pointer rounded-sm" %>
|
|
@@ -15,7 +18,7 @@
|
|
|
15
18
|
<p class="text-xs text-gray-400 mt-1 w-64"><%= flash[:notice] %></p>
|
|
16
19
|
</div>
|
|
17
20
|
</div>
|
|
18
|
-
<div class="flex
|
|
21
|
+
<div class="flex mt-6 mb-4 py-4 border gap-x-8 items-center">
|
|
19
22
|
<div class="w-3/4 pr-12 pb-4 border-r-2 resize-x overflow-auto">
|
|
20
23
|
<div class="shrink-0 flex items-center bg-gray-950 py-2 px-4 z-10 rounded-t-lg">
|
|
21
24
|
<div class="hidden sm:block shrink-0 mr-2 h-4 w-4 bg-gray-600 rounded-full"></div>
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: better_mailer_previews
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Harrison Broadbent
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2024-06-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|