simple_email_preview 1.0.0
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 +7 -0
- data/Gemfile +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +162 -0
- data/Rakefile +62 -0
- data/app/assets/images/simple_email_preview/favicon.png +0 -0
- data/app/assets/javascripts/simple_email_preview/application.js +1 -0
- data/app/assets/stylesheets/simple_email_preview/_bootstrap3.sass +68 -0
- data/app/assets/stylesheets/simple_email_preview/_default.sass +230 -0
- data/app/assets/stylesheets/simple_email_preview/application.scss +10 -0
- data/app/controllers/simple_email_preview/application_controller.rb +19 -0
- data/app/controllers/simple_email_preview/emails_controller.rb +194 -0
- data/app/helpers/simple_email_preview/emails_helper.rb +85 -0
- data/app/models/simple_email_preview/preview.rb +86 -0
- data/app/presenters/simple_email_preview/preview_list_presenter.rb +38 -0
- data/app/views/layouts/simple_email_preview/_flash_notices.html.erb +7 -0
- data/app/views/layouts/simple_email_preview/application.html.erb +16 -0
- data/app/views/layouts/simple_email_preview/email.html.erb +30 -0
- data/app/views/simple_email_preview/emails/_email_iframe.html.erb +88 -0
- data/app/views/simple_email_preview/emails/_format_nav.html.erb +4 -0
- data/app/views/simple_email_preview/emails/_headers.html.erb +10 -0
- data/app/views/simple_email_preview/emails/_headers_and_nav.html.erb +12 -0
- data/app/views/simple_email_preview/emails/_i18n_nav.html.erb +3 -0
- data/app/views/simple_email_preview/emails/_nav.html.erb +18 -0
- data/app/views/simple_email_preview/emails/_send_form.html.erb +11 -0
- data/app/views/simple_email_preview/emails/index.html.erb +36 -0
- data/app/views/simple_email_preview/emails/show.html.erb +23 -0
- data/config/i18n-tasks.yml +10 -0
- data/config/initializers/simple_email_preview.rb +14 -0
- data/config/locales/de.yml +47 -0
- data/config/locales/en.yml +47 -0
- data/config/locales/es.yml +47 -0
- data/config/locales/ja.yml +47 -0
- data/config/locales/ru.yml +51 -0
- data/config/routes.rb +23 -0
- data/lib/generators/simple_email_preview/install_generator.rb +17 -0
- data/lib/generators/simple_email_preview/update_previews_generator.rb +45 -0
- data/lib/simple_email_preview.rb +105 -0
- data/lib/simple_email_preview/delivery_handler.rb +15 -0
- data/lib/simple_email_preview/engine.rb +14 -0
- data/lib/simple_email_preview/main_app_route_delegator.rb +20 -0
- data/lib/simple_email_preview/version.rb +3 -0
- data/lib/simple_email_preview/view_hooks.rb +102 -0
- metadata +231 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<style type="text/css">
|
5
|
+
#message_body, #raw_message {
|
6
|
+
font-family: Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
|
7
|
+
word-break: break-word;
|
8
|
+
}
|
9
|
+
|
10
|
+
#error {
|
11
|
+
padding: 15px;
|
12
|
+
margin-bottom: 20px;
|
13
|
+
border: 1px solid transparent;
|
14
|
+
border-radius: 4px;
|
15
|
+
background-color: #f2dede;
|
16
|
+
border-color: #ebccd1;
|
17
|
+
color: #a94442;
|
18
|
+
}
|
19
|
+
|
20
|
+
body {
|
21
|
+
background-color: white;
|
22
|
+
}
|
23
|
+
</style>
|
24
|
+
<script>document.addEventListener('DOMContentLoaded', window.parent.rep.iframeOnDOMContentLoaded, true);</script>
|
25
|
+
</head>
|
26
|
+
<body>
|
27
|
+
<div id="content" class="container">
|
28
|
+
<%= yield %></div>
|
29
|
+
</body>
|
30
|
+
</html>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
<script>
|
2
|
+
(function (doc) {
|
3
|
+
var rep = window['rep'] || (window['rep'] = { resizeAttached: false });
|
4
|
+
rep.loaded = false;
|
5
|
+
|
6
|
+
function findIframe() {
|
7
|
+
return doc.getElementById('src-iframe');
|
8
|
+
}
|
9
|
+
|
10
|
+
function resizeIframe() {
|
11
|
+
var el = findIframe();
|
12
|
+
if (!el) {
|
13
|
+
rep.loaded = false;
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
var iframeBody = el.contentWindow.document.body;
|
17
|
+
if (iframeBody) {
|
18
|
+
el.style.height = (getBodyHeight(iframeBody)) + "px";
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
function getBodyHeight(body) {
|
23
|
+
var boundingRect = body.getBoundingClientRect();
|
24
|
+
var style = body.ownerDocument.defaultView.getComputedStyle(body);
|
25
|
+
var marginY = parseInt(style['margin-bottom'], 10) +
|
26
|
+
parseInt(style['margin-top'], 10);
|
27
|
+
// There may be a horizontal scrollbar adding to the height.
|
28
|
+
var scrollbarHeight = 17;
|
29
|
+
return scrollbarHeight + marginY + Math.max(
|
30
|
+
body.scrollHeight, body.offsetHeight, body.clientHeight,
|
31
|
+
boundingRect.height + boundingRect.top) +
|
32
|
+
// no idea why these 4px are needed:
|
33
|
+
4;
|
34
|
+
}
|
35
|
+
|
36
|
+
function fetchHeaders() {
|
37
|
+
var headersView = doc.getElementById('email-headers'),
|
38
|
+
xhr = new XMLHttpRequest();
|
39
|
+
xhr.open('GET', headersView.getAttribute('data-url'), true);
|
40
|
+
xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
41
|
+
xhr.send(null);
|
42
|
+
xhr.onreadystatechange = function () {
|
43
|
+
if (xhr.readyState === 4) {
|
44
|
+
headersView.innerHTML = xhr.responseText;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
// Called from the iframe via window.parent
|
50
|
+
rep.iframeOnDOMContentLoaded = function () {
|
51
|
+
rep.loaded = true;
|
52
|
+
resizeIframe();
|
53
|
+
// CMS refresh headers hook
|
54
|
+
if (rep.fetchHeadersOnNextLoad) {
|
55
|
+
rep.fetchHeadersOnNextLoad = false;
|
56
|
+
fetchHeaders();
|
57
|
+
}
|
58
|
+
};
|
59
|
+
|
60
|
+
// This is only called back once the iframe has finished loading everything, including images
|
61
|
+
rep.iframeOnLoad = resizeIframe;
|
62
|
+
|
63
|
+
// Resize on window resize
|
64
|
+
if (!rep.resizeAttached) {
|
65
|
+
window.addEventListener('resize', function () {
|
66
|
+
if (rep.loaded) resizeIframe();
|
67
|
+
}, true);
|
68
|
+
rep.resizeAttached = true
|
69
|
+
}
|
70
|
+
|
71
|
+
// Only show progress bar after some time to avoid flashing
|
72
|
+
setTimeout(function () {
|
73
|
+
doc.getElementById('email-progress-bar').style.display = 'block';
|
74
|
+
}, 350);
|
75
|
+
})(document);
|
76
|
+
</script>
|
77
|
+
|
78
|
+
<div style="min-height: 450px; position: relative">
|
79
|
+
<div id="email-progress-bar" class="progress"
|
80
|
+
style="display: none; position: absolute; z-index: -1; width: 100%; text-align: center">
|
81
|
+
<div class="progress-bar progress-bar-striped active" style='width:100%'>
|
82
|
+
<%= t 'rep.base.loading' %>
|
83
|
+
</div>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
<iframe id="src-iframe" srcdoc="<%= @mail_body_html.to_str %>" seamless="seamless" onload="rep.iframeOnLoad()"
|
87
|
+
style="width:100%;border:none;padding:0;margin:0;height:0"></iframe>
|
88
|
+
</div>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<div class="rep--panel">
|
2
|
+
<div class="<%= rep_style[:row_class] %>">
|
3
|
+
<div id="email-headers" class="rep--email-headers"
|
4
|
+
data-url="<%= simple_email_preview.rep_email_headers_path(preview_params) %>">
|
5
|
+
<%# content updated by JS on demand from the iframe %>
|
6
|
+
<%= render 'simple_email_preview/emails/headers', mail: @mail %>
|
7
|
+
</div>
|
8
|
+
<div class="rep--email-nav-container">
|
9
|
+
<%= render 'nav' %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%# Locale, format and actions %>
|
2
|
+
<%= with_show_hook :nav do %>
|
3
|
+
<div class="rep--email-options">
|
4
|
+
<% if I18n.available_locales.length > 1 %>
|
5
|
+
<%= with_show_hook :nav_i18n do %>
|
6
|
+
<%= render 'simple_email_preview/emails/i18n_nav' %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
<%= with_show_hook :nav_format do %>
|
10
|
+
<%= render 'simple_email_preview/emails/format_nav' %>
|
11
|
+
<% end %>
|
12
|
+
<% if SimpleEmailPreview.enable_send_email %>
|
13
|
+
<%= with_show_hook :nav_send do %>
|
14
|
+
<%= render 'simple_email_preview/emails/send_form' %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%= form_tag simple_email_preview.rep_test_deliver_url(params: preview_params), method: :post,
|
2
|
+
class: 'rep--send-to-form' do %>
|
3
|
+
<%= hidden_field_tag :email_locale, @email_locale %>
|
4
|
+
<%# Indentation ensures the lack of a space in between the button and the field: %>
|
5
|
+
<%= content_tag :button, t('.send_btn'), type: 'submit',
|
6
|
+
class: rep_style[:btn_danger_class],
|
7
|
+
'data-confirm' => t('.send_are_you_sure') -%>
|
8
|
+
<%= text_field_tag :recipient_email, '', type: :email, required: true,
|
9
|
+
class: rep_style[:form_control_class],
|
10
|
+
placeholder: t('.send_recipient_placeholder') -%>
|
11
|
+
<% end %>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<%
|
2
|
+
list = @list
|
3
|
+
previews = @previews
|
4
|
+
%>
|
5
|
+
|
6
|
+
<div class="rep--main-container">
|
7
|
+
<h1><%= t '.list_title' %></h1>
|
8
|
+
|
9
|
+
<%= with_index_hook :list do %>
|
10
|
+
<div class="<%= rep_style[:row_class] %>">
|
11
|
+
<% list.columns do |groups| %>
|
12
|
+
<div class="rep--email-list-half">
|
13
|
+
<% groups.each do |title, group_previews| %>
|
14
|
+
<h2><%= title %></h2>
|
15
|
+
<div class="<%= rep_style[:list_group_class] %>">
|
16
|
+
<% group_previews.each do |p| %>
|
17
|
+
<a class="<%= rep_style[:list_group_item_class] %>"
|
18
|
+
href="<%= simple_email_preview.rep_email_path(preview_id: p.id, email_locale: @email_locale) %>">
|
19
|
+
<%= p.humanized_method_name %>
|
20
|
+
</a>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
<% end %>
|
24
|
+
</div>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
<% end %>
|
28
|
+
<hr/>
|
29
|
+
<p class="rep--footer">
|
30
|
+
<%= t 'rep.base.email', count: previews.length %> <%= t 'rep.base.in' %> <%= t 'rep.base.mailer', count: list.groups.length %>
|
31
|
+
<br/>
|
32
|
+
<a href="https://github.com/glebm/simple_email_preview" target="_blank">
|
33
|
+
<!-- REP <%#= SimpleEmailPreview::VERSION %>-->
|
34
|
+
</a>
|
35
|
+
</p>
|
36
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%- # Using ERB for this template to have precise control of tag indentation for correct rendering of raw and text. -%>
|
2
|
+
<div class="rep--main-container">
|
3
|
+
<div id="email-show" class="rep--email-show">
|
4
|
+
<%= with_show_hook :breadcrumb do %>
|
5
|
+
<ol class="rep--breadcrumbs">
|
6
|
+
<%= with_show_hook :breadcrumb_content do %>
|
7
|
+
<li class="rep--breadcrumbs__breadcrumb">
|
8
|
+
<a href="<%= simple_email_preview.rep_emails_path(email_locale: @email_locale) %>"><%= t '.breadcrumb_list' %></a>
|
9
|
+
</li><li class="rep--breadcrumbs__breadcrumb-active"><a href="<%= request.path %>"><%= @preview.name %></a></li>
|
10
|
+
<% end %>
|
11
|
+
</ol>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= with_show_hook :headers_and_nav do %>
|
15
|
+
<%= render 'simple_email_preview/emails/headers_and_nav' %>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<%= with_show_hook :email_body do %>
|
19
|
+
<%- # actual email content, rendered in an iframe to prevent browser styles from interfering -%>
|
20
|
+
<%= render 'simple_email_preview/emails/email_iframe' %>
|
21
|
+
<% end %>
|
22
|
+
</div>
|
23
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'simple_email_preview'
|
2
|
+
require 'breadcrumbs_on_rails'
|
3
|
+
|
4
|
+
Rails.application.config.to_prepare do
|
5
|
+
# Render REP inside a custom layout (set to 'application' to use app layout, default is REP's own layout)
|
6
|
+
# This will also make application routes accessible from within REP:
|
7
|
+
# SimpleEmailPreview.layout = 'admin'
|
8
|
+
|
9
|
+
# Set UI locale to something other than :en
|
10
|
+
SimpleEmailPreview.locale = :en
|
11
|
+
|
12
|
+
# Auto-load preview classes from:
|
13
|
+
SimpleEmailPreview.preview_classes = SimpleEmailPreview.find_preview_classes('app/mailer_previews')
|
14
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
de:
|
3
|
+
rep:
|
4
|
+
base:
|
5
|
+
email:
|
6
|
+
one: 1 E-Mail
|
7
|
+
other: "%{count} E-Mails"
|
8
|
+
mailer:
|
9
|
+
one: 1 Mailer
|
10
|
+
other: "%{count} Mailer"
|
11
|
+
in: in
|
12
|
+
loading: Lade...
|
13
|
+
test_deliver:
|
14
|
+
no_delivery_method: Bitte setze 'config.action_mailer.delivery_method' um E-Mails in der „%{environment}“ Umgebung zu senden.
|
15
|
+
provide_email: An welche Adresse senden?
|
16
|
+
sent_notice: Senden an %{address} mit %{delivery_method}
|
17
|
+
headers:
|
18
|
+
subject: Betreff
|
19
|
+
from: Aus
|
20
|
+
to: Zu
|
21
|
+
reply_to: Beantworten
|
22
|
+
cc: CC
|
23
|
+
bcc: BCC
|
24
|
+
attachments: Anhänge
|
25
|
+
errors:
|
26
|
+
email_missing_format: Format fehlenden
|
27
|
+
layouts:
|
28
|
+
simple_email_preview:
|
29
|
+
application:
|
30
|
+
head_title: E-Mails - REP
|
31
|
+
simple_email_preview:
|
32
|
+
emails:
|
33
|
+
index:
|
34
|
+
list_title: Anwendungs E-Mails
|
35
|
+
show:
|
36
|
+
breadcrumb_list: E-Mails
|
37
|
+
send_form:
|
38
|
+
send_are_you_sure: Diese Aktion wird diese E-Mail wirklich versenden. Bist du sicher?
|
39
|
+
send_btn: Senden an
|
40
|
+
send_recipient_placeholder: E-Mails
|
41
|
+
integrations:
|
42
|
+
cms:
|
43
|
+
customize_cms_for_simple_email_preview:
|
44
|
+
edit_email: E-Mail bearbeiten
|
45
|
+
view_link: Anzeigen
|
46
|
+
errors:
|
47
|
+
site_missing: Bitte erstellen Sie eine CMS-Website für %{locale} zuerst. Bei der Verwendung von mehreren Gebietsschemas sollte der Standort gespiegelt werden.
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
rep:
|
4
|
+
headers:
|
5
|
+
subject: Subject
|
6
|
+
from: From
|
7
|
+
to: To
|
8
|
+
reply_to: Reply to
|
9
|
+
cc: CC
|
10
|
+
bcc: BCC
|
11
|
+
attachments: Attachments
|
12
|
+
base:
|
13
|
+
email:
|
14
|
+
one: 1 email
|
15
|
+
other: "%{count} emails"
|
16
|
+
mailer:
|
17
|
+
one: 1 mailer
|
18
|
+
other: "%{count} mailers"
|
19
|
+
in: in
|
20
|
+
loading: Loading...
|
21
|
+
test_deliver:
|
22
|
+
no_delivery_method: Please set 'config.action_mailer.delivery_method' to send emails in '%{environment}' environment
|
23
|
+
provide_email: Send to which address?
|
24
|
+
sent_notice: Sent to %{address} via %{delivery_method}
|
25
|
+
errors:
|
26
|
+
email_missing_format: Format missing
|
27
|
+
layouts:
|
28
|
+
simple_email_preview:
|
29
|
+
application:
|
30
|
+
head_title: Emails - REP
|
31
|
+
simple_email_preview:
|
32
|
+
emails:
|
33
|
+
index:
|
34
|
+
list_title: Application Emails
|
35
|
+
show:
|
36
|
+
breadcrumb_list: Emails
|
37
|
+
send_form:
|
38
|
+
send_are_you_sure: This will actually send this email. Are you sure?
|
39
|
+
send_btn: Send to
|
40
|
+
send_recipient_placeholder: Email
|
41
|
+
integrations:
|
42
|
+
cms:
|
43
|
+
errors:
|
44
|
+
site_missing: Please create a CMS site for %{locale} first. When using multiple locales the site should be Mirrored.
|
45
|
+
customize_cms_for_simple_email_preview:
|
46
|
+
edit_email: Editing email
|
47
|
+
view_link: View
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
es:
|
3
|
+
rep:
|
4
|
+
headers:
|
5
|
+
subject: Asunto
|
6
|
+
from: De
|
7
|
+
to: A
|
8
|
+
reply_to: Responder a
|
9
|
+
cc: CC
|
10
|
+
bcc: BCC
|
11
|
+
attachments: Adjuntos
|
12
|
+
base:
|
13
|
+
email:
|
14
|
+
one: 1 email
|
15
|
+
other: "%{count} emails"
|
16
|
+
mailer:
|
17
|
+
one: 1 mailer
|
18
|
+
other: "%{count} mailers"
|
19
|
+
in: en
|
20
|
+
loading: Cargando...
|
21
|
+
test_deliver:
|
22
|
+
no_delivery_method: Por favor configura 'config.action_mailer.delivery_method' para enviar correos en el entorno de '%{environment}'
|
23
|
+
provide_email: ¿A que dirección?
|
24
|
+
sent_notice: Enviado a %{address} vía %{delivery_method}
|
25
|
+
errors:
|
26
|
+
email_missing_format: Falta formato
|
27
|
+
layouts:
|
28
|
+
simple_email_preview:
|
29
|
+
application:
|
30
|
+
head_title: Emails - REP
|
31
|
+
simple_email_preview:
|
32
|
+
emails:
|
33
|
+
index:
|
34
|
+
list_title: Emails de la aplicación
|
35
|
+
show:
|
36
|
+
breadcrumb_list: Emails
|
37
|
+
send_form:
|
38
|
+
send_are_you_sure: Esto enviara el email. ¿Estás seguro?
|
39
|
+
send_btn: Enviar a
|
40
|
+
send_recipient_placeholder: Email
|
41
|
+
integrations:
|
42
|
+
cms:
|
43
|
+
errors:
|
44
|
+
site_missing: Por favor, primero crea un CMS para %{locale}. Cuando estes usando varios idiomas el site debería estar
|
45
|
+
customize_cms_for_simple_email_preview:
|
46
|
+
edit_email: Editando el email
|
47
|
+
view_link: Ver
|
@@ -0,0 +1,47 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
rep:
|
4
|
+
headers:
|
5
|
+
subject: Subject
|
6
|
+
from: From
|
7
|
+
to: To
|
8
|
+
reply_to: Reply to
|
9
|
+
cc: CC
|
10
|
+
bcc: BCC
|
11
|
+
attachments: Attachments
|
12
|
+
base:
|
13
|
+
email:
|
14
|
+
one: 1 email
|
15
|
+
other: "%{count} emails"
|
16
|
+
mailer:
|
17
|
+
one: 1 mailer
|
18
|
+
other: "%{count} mailers"
|
19
|
+
in: in
|
20
|
+
loading: Loading...
|
21
|
+
test_deliver:
|
22
|
+
no_delivery_method: Please set 'config.action_mailer.delivery_method' to send emails in '%{environment}' environment
|
23
|
+
provide_email: Send to which address?
|
24
|
+
sent_notice: Sent to %{address} via %{delivery_method}
|
25
|
+
errors:
|
26
|
+
email_missing_format: Format missing
|
27
|
+
layouts:
|
28
|
+
simple_email_preview:
|
29
|
+
application:
|
30
|
+
head_title: Emails - REP
|
31
|
+
simple_email_preview:
|
32
|
+
emails:
|
33
|
+
index:
|
34
|
+
list_title: Application Emails
|
35
|
+
show:
|
36
|
+
breadcrumb_list: Emails
|
37
|
+
send_form:
|
38
|
+
send_are_you_sure: This will actually send this email. Are you sure?
|
39
|
+
send_btn: Send to
|
40
|
+
send_recipient_placeholder: Email
|
41
|
+
integrations:
|
42
|
+
cms:
|
43
|
+
errors:
|
44
|
+
site_missing: Please create a CMS site for %{locale} first. When using multiple locales the site should be Mirrored.
|
45
|
+
customize_cms_for_simple_email_preview:
|
46
|
+
edit_email: Editing email
|
47
|
+
view_link: View
|