rails_email_preview 0.2.22 → 0.2.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +39 -22
- data/Rakefile +4 -2
- data/app/controllers/rails_email_preview/emails_controller.rb +4 -4
- data/app/helpers/rails_email_preview/emails_helper.rb +23 -2
- data/app/views/layouts/rails_email_preview/email.html.slim +9 -0
- data/app/views/rails_email_preview/emails/_format_nav.html.slim +5 -4
- data/app/views/rails_email_preview/emails/_headers.html.slim +6 -4
- data/app/views/rails_email_preview/emails/_headers_and_nav.html.slim +8 -0
- data/app/views/rails_email_preview/emails/_headers_content.html.slim +0 -0
- data/app/views/rails_email_preview/emails/_i18n_nav.html.slim +5 -4
- data/app/views/rails_email_preview/emails/_nav.html.slim +13 -0
- data/app/views/rails_email_preview/emails/index.html.slim +10 -9
- data/app/views/rails_email_preview/emails/show.html.slim +5 -17
- data/config/locales/de.yml +2 -0
- data/config/locales/en.yml +2 -0
- data/config/locales/ru.yml +2 -0
- data/config/routes.rb +5 -3
- data/lib/rails_email_preview/version.rb +1 -1
- data/lib/rails_email_preview/view_hooks.rb +102 -0
- data/lib/rails_email_preview.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c931cf860483798ae783d2a8009543fa2c1d267a
|
4
|
+
data.tar.gz: d24a6cedfdbd15dbdad7d36929f266c643abc0f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ffb92ddf75f5b2e12ab1fda1edbcbc37ab952f2613b6202802390335629e9e9b548e05538da6617fe3f33325d5e867efe76558dc349a4561c5f6b027c1848d3
|
7
|
+
data.tar.gz: 27229704b52d6d92a3f8dccbdc7bda3b0f742d49907c8ac047e77da2502cad344043f6de44c262a78ec2aa288d75d09be27dafff791053b87364649e734b4f1e
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ REP can use your application styles, markup is compatible with [bootstrap 3][rep
|
|
16
16
|
Add [![Gem Version][gem-badge]][gem] to Gemfile:
|
17
17
|
|
18
18
|
```ruby
|
19
|
-
gem 'rails_email_preview', '~> 0.2.
|
19
|
+
gem 'rails_email_preview', '~> 0.2.23'
|
20
20
|
```
|
21
21
|
|
22
22
|
Add an initializer and the routes:
|
@@ -67,21 +67,21 @@ end
|
|
67
67
|
All parameters in the search query will be available to the preview class as instance variables.
|
68
68
|
For example, if URL to mailer preview looks like:
|
69
69
|
|
70
|
-
|
71
|
-
/emails/user_mailer_preview-welcome?user_id=1
|
72
|
-
```
|
70
|
+
/emails/user_mailer_preview-welcome?**user_id=1**
|
73
71
|
|
74
72
|
The method `welcome` in `UserMailerPreview` have a `@user_id` instance variable defined:
|
75
73
|
|
76
74
|
```ruby
|
77
75
|
class UserMailerPreview
|
78
76
|
def welcome
|
79
|
-
user = @user_id ? User.find(@user_id) :
|
77
|
+
user = @user_id ? User.find(@user_id) : mock_user
|
80
78
|
UserMailer.welcome(user)
|
81
79
|
end
|
82
80
|
end
|
83
81
|
```
|
84
82
|
|
83
|
+
Now you can preview or send the welcome email to a specific user.
|
84
|
+
|
85
85
|
### Routing
|
86
86
|
|
87
87
|
You can access REP urls like this:
|
@@ -117,7 +117,7 @@ REP works with [Comfortable Mexican Sofa CMS](https://github.com/comfy/comfortab
|
|
117
117
|
[Premailer](https://github.com/alexdunae/premailer) automatically translates standard CSS rules into old-school inline styles. Integration can be done by using the <code>before_render</code> hook.
|
118
118
|
|
119
119
|
To integrate Premailer with your Rails app you can use either [actionmailer_inline_css](https://github.com/ndbroadbent/actionmailer_inline_css) or [premailer-rails](https://github.com/fphilipe/premailer-rails).
|
120
|
-
Simply uncomment the relevant options in [the initializer](https://github.com/glebm/rails_email_preview/
|
120
|
+
Simply uncomment the relevant options in [the initializer](https://github.com/glebm/rails_email_preview/config/initializers/rails_email_preview.rb). *initializer is generated during `rails g rails_email_preview:install`*
|
121
121
|
|
122
122
|
### I18n
|
123
123
|
|
@@ -163,29 +163,32 @@ Rails.application.config.to_prepare do
|
|
163
163
|
end
|
164
164
|
```
|
165
165
|
|
166
|
-
|
166
|
+
You can `//= require 'rails_email_preview/layout'` REP-specific styles (`@import 'rails_email_preview/layout'` for SASS).
|
167
|
+
|
168
|
+
REP also allows you to customize some of the element classes via [`RailsEmailPreview.style`](/lib/rails_email_preview.rb#L34).
|
169
|
+
|
170
|
+
You can also override any individual view by placing a file with the same path in your project's `app/views`,
|
171
|
+
e.g. `app/views/rails_email_preview/emails/index.html.slim`.
|
172
|
+
|
173
|
+
#### Hooks
|
174
|
+
|
175
|
+
You can add content around or replacing REP UI elements by registering view hooks in the initializer:
|
167
176
|
|
168
177
|
```ruby
|
169
|
-
|
170
|
-
|
171
|
-
btn_active_class: 'btn btn-primary active',
|
172
|
-
btn_group_class: 'btn-group',
|
173
|
-
list_group_class: 'list-group',
|
174
|
-
list_group_item_class: 'list-group-item',
|
175
|
-
panel_class: 'panel',
|
176
|
-
row_class: 'row',
|
177
|
-
column_class: 'col-%{n}'
|
178
|
-
}
|
179
|
-
```
|
178
|
+
# Pass position (before, after, or replace) and render arguments:
|
179
|
+
RailsEmailPreview.view_hooks.add_render :list, :before, partial: 'shared/hello'
|
180
180
|
|
181
|
-
|
181
|
+
# Pass hook id and position (before, after, or replace):
|
182
|
+
RailsEmailPreview.view_hooks.add :headers_content, :after do |mail:, preview:|
|
183
|
+
raw "<dt>ID</dt><dd>#{h mail.header['X-APP-EMAIL-ID']}</dd>"
|
184
|
+
end
|
185
|
+
```
|
182
186
|
|
183
|
-
|
184
|
-
e.g. `app/views/rails_email_preview/emails/index.html.slim`. *PRs accepted* if you need hooks.
|
187
|
+
All of the available hooks can be found [here](/lib/rails_email_preview/view_hooks.rb#L10).
|
185
188
|
|
186
189
|
### Authentication & authorization
|
187
190
|
|
188
|
-
You can specify the parent controller for REP controller, and it will inherit all before filters.
|
191
|
+
You can specify the parent controller for REP controller, and it will inherit all the before filters.
|
189
192
|
Note that this must be placed before any other references to REP application controller in the initializer (and before `layout=` call):
|
190
193
|
|
191
194
|
```ruby
|
@@ -207,6 +210,20 @@ Rails.application.config.to_prepare do
|
|
207
210
|
end
|
208
211
|
```
|
209
212
|
|
213
|
+
## Development
|
214
|
+
|
215
|
+
Run the tests:
|
216
|
+
|
217
|
+
```console
|
218
|
+
$ rspec
|
219
|
+
```
|
220
|
+
|
221
|
+
Start a development web server on [localhost:9292](http://localhost:9292):
|
222
|
+
|
223
|
+
```console
|
224
|
+
$ rake dev
|
225
|
+
```
|
226
|
+
|
210
227
|
This project rocks and uses MIT-LICENSE.
|
211
228
|
|
212
229
|
[rep-nav-screenshot]: https://raw.github.com/glebm/rails_email_preview/master/doc/img/rep-nav.png "Email List Screenshot"
|
data/Rakefile
CHANGED
@@ -20,14 +20,16 @@ task default: :spec
|
|
20
20
|
|
21
21
|
desc 'Start development web server'
|
22
22
|
task :dev do
|
23
|
+
host = 'localhost'
|
24
|
+
port = 9292
|
23
25
|
require 'puma'
|
24
26
|
require 'rails/commands/server'
|
25
27
|
ENV['RACK_ENV'] = ENV['RAILS_ENV'] = 'development'
|
26
28
|
Dir.chdir 'spec/dummy'
|
27
29
|
Rack::Server.start(
|
28
30
|
environment: 'development',
|
29
|
-
Host:
|
30
|
-
Port:
|
31
|
+
Host: host,
|
32
|
+
Port: port,
|
31
33
|
config: 'config.ru',
|
32
34
|
server: 'puma'
|
33
35
|
)
|
@@ -28,9 +28,9 @@ module RailsEmailPreview
|
|
28
28
|
|
29
29
|
# Download attachment
|
30
30
|
def show_attachment
|
31
|
-
filename = "#{params[:filename]}.#{
|
31
|
+
filename = "#{params[:filename]}.#{params[:format]}"
|
32
32
|
attachment = preview_mail(false).attachments.find { |a| a.filename == filename }
|
33
|
-
send_data attachment.body.raw_source
|
33
|
+
send_data attachment.body.raw_source, filename: filename
|
34
34
|
end
|
35
35
|
|
36
36
|
# Really deliver an email
|
@@ -53,7 +53,7 @@ module RailsEmailPreview
|
|
53
53
|
end
|
54
54
|
|
55
55
|
# Used by CMS integration to refetch header after editing
|
56
|
-
def
|
56
|
+
def show_headers
|
57
57
|
render partial: 'rails_email_preview/emails/headers', locals: {mail: mail_and_body.first}
|
58
58
|
end
|
59
59
|
|
@@ -103,7 +103,7 @@ module RailsEmailPreview
|
|
103
103
|
else
|
104
104
|
mail
|
105
105
|
end
|
106
|
-
|
106
|
+
return "<pre id='error'>#{html_escape(t('rep.errors.email_missing_format'))}</pre>" if !body_part
|
107
107
|
if body_part.content_type =~ /plain/
|
108
108
|
"<pre id='message_body'>#{html_escape(body_part.body.to_s)}</pre>".html_safe
|
109
109
|
else
|
@@ -39,9 +39,9 @@ module RailsEmailPreview::EmailsHelper
|
|
39
39
|
|
40
40
|
def attachment_links(mail)
|
41
41
|
mail.attachments.map do |attachment|
|
42
|
-
url = rails_email_preview.rep_raw_email_attachment_path(
|
42
|
+
url = rails_email_preview.rep_raw_email_attachment_path(preview_params.merge(filename: attachment.filename))
|
43
43
|
link_to(attachment.filename, url)
|
44
|
-
end.
|
44
|
+
end.to_sentence.html_safe
|
45
45
|
end
|
46
46
|
|
47
47
|
def format_header_value(value)
|
@@ -76,4 +76,25 @@ module RailsEmailPreview::EmailsHelper
|
|
76
76
|
def rep_btn_group_class
|
77
77
|
rep_style[:btn_group_class]
|
78
78
|
end
|
79
|
+
|
80
|
+
|
81
|
+
def with_index_hook(key, &block)
|
82
|
+
render_hook key, list: @list, previews: @previews, &block
|
83
|
+
end
|
84
|
+
|
85
|
+
def with_show_hook(key, &block)
|
86
|
+
render_hook key, mail: @mail, preview: @preview, &block
|
87
|
+
end
|
88
|
+
|
89
|
+
def render_hook(key, args, &block)
|
90
|
+
view_hooks.render(key, args, self, &block)
|
91
|
+
end
|
92
|
+
|
93
|
+
def hook?(key)
|
94
|
+
view_hooks.for?(key)
|
95
|
+
end
|
96
|
+
|
97
|
+
def view_hooks
|
98
|
+
RailsEmailPreview.view_hooks
|
99
|
+
end
|
79
100
|
end
|
@@ -7,6 +7,15 @@ html
|
|
7
7
|
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
|
8
8
|
word-break: break-word;
|
9
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
|
+
}
|
10
19
|
body {
|
11
20
|
background-color:white;
|
12
21
|
}
|
@@ -1,4 +1,6 @@
|
|
1
|
-
|
2
|
-
-
|
3
|
-
|
4
|
-
|
1
|
+
= with_show_hook :headers do
|
2
|
+
dl.rep-headers-list.dl-horizontal
|
3
|
+
= with_show_hook :headers_content do
|
4
|
+
- human_headers mail do |name, value|
|
5
|
+
dt = name
|
6
|
+
dd = value
|
@@ -0,0 +1,8 @@
|
|
1
|
+
div class=rep_style[:panel_class]
|
2
|
+
div class=rep_style[:panel_body_class]
|
3
|
+
div class=rep_style[:row_class]
|
4
|
+
#email-headers data-url=rails_email_preview.rep_email_headers_path(preview_params) class=rep_col_class(8)
|
5
|
+
/ content updated by JS on demand from the iframe
|
6
|
+
= render 'rails_email_preview/emails/headers', mail: @mail
|
7
|
+
.text-right class=rep_col_class(4)
|
8
|
+
= render 'nav'
|
File without changes
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
p
|
2
|
+
span class=rep_btn_group_class
|
3
|
+
- @preview.locales.each do |locale|
|
4
|
+
a *change_locale_attr(locale)
|
5
|
+
= locale_name locale
|
@@ -0,0 +1,13 @@
|
|
1
|
+
-# Locale, format and actions
|
2
|
+
= with_show_hook :nav do
|
3
|
+
|
4
|
+
.rep-email-options.text-right
|
5
|
+
- if I18n.available_locales.length > 1
|
6
|
+
= with_show_hook :nav_i18n do
|
7
|
+
= render 'rails_email_preview/emails/i18n_nav'
|
8
|
+
= with_show_hook :nav_format do
|
9
|
+
= render 'rails_email_preview/emails/format_nav'
|
10
|
+
- if RailsEmailPreview.enable_send_email
|
11
|
+
= with_show_hook :nav_send do
|
12
|
+
= render 'rails_email_preview/emails/send_form'
|
13
|
+
|
@@ -4,15 +4,16 @@ ruby:
|
|
4
4
|
|
5
5
|
h1 = t '.list_title'
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
= p.
|
7
|
+
= with_index_hook :list do
|
8
|
+
div class=rep_row_class
|
9
|
+
- list.columns do |groups|
|
10
|
+
div class=rep_col_class(6)
|
11
|
+
- groups.each do |title, group_previews|
|
12
|
+
h2 = title
|
13
|
+
div class=rep_style[:list_group_class]
|
14
|
+
- group_previews.each do |p|
|
15
|
+
a class=rep_style[:list_group_item_class] href=rails_email_preview.rep_email_path(preview_id: p.id, email_locale: @email_locale)
|
16
|
+
= p.method_name
|
16
17
|
hr
|
17
18
|
p.text-center.text-small.text-info
|
18
19
|
| #{t 'rep.base.email', count: previews.length} #{t 'rep.base.in'} #{t 'rep.base.mailer', count: list.groups.length }
|
@@ -5,21 +5,9 @@
|
|
5
5
|
li: a href=rails_email_preview.rep_emails_path(email_locale: @email_locale) #{t '.breadcrumb_list'}
|
6
6
|
li.active: a href=(request.path) = @preview.name
|
7
7
|
|
8
|
-
|
9
|
-
|
10
|
-
div class=rep_style[:row_class]
|
11
|
-
-# From, To, Subject and other headers
|
12
|
-
#email-headers data-url=rails_email_preview.rep_email_headers_path(preview_params) class=rep_col_class(8)
|
13
|
-
= render 'rails_email_preview/emails/headers', mail: @mail
|
14
|
-
-# Locale, format and actions
|
15
|
-
.text-right class=rep_col_class(4)
|
16
|
-
.rep-email-options.text-right
|
17
|
-
- if I18n.available_locales.length > 1
|
18
|
-
p= render 'rails_email_preview/emails/i18n_nav'
|
19
|
-
p= render 'rails_email_preview/emails/format_nav'
|
20
|
-
- if RailsEmailPreview.enable_send_email
|
21
|
-
= render 'rails_email_preview/emails/send_form'
|
8
|
+
= with_show_hook :headers_and_nav do
|
9
|
+
= render 'rails_email_preview/emails/headers_and_nav'
|
22
10
|
|
23
|
-
|
24
|
-
|
25
|
-
|
11
|
+
= with_show_hook :email_body do
|
12
|
+
/ actual email content, rendered in an iframe to prevent browser styles from interfering
|
13
|
+
= render 'rails_email_preview/emails/email_iframe'
|
data/config/locales/de.yml
CHANGED
data/config/locales/en.yml
CHANGED
@@ -22,6 +22,8 @@ en:
|
|
22
22
|
no_delivery_method: Please set 'config.action_mailer.delivery_method' to send emails in '%{environment}' environment
|
23
23
|
provide_email: Send to which address?
|
24
24
|
sent_notice: Sent to %{address} via %{delivery_method}
|
25
|
+
errors:
|
26
|
+
email_missing_format: Format missing
|
25
27
|
layouts:
|
26
28
|
rails_email_preview:
|
27
29
|
application:
|
data/config/locales/ru.yml
CHANGED
@@ -26,6 +26,8 @@ ru:
|
|
26
26
|
no_delivery_method: "Настройте 'config.action_mailer.delivery_method', чтобы отправлять письма в среде '%{environment}'"
|
27
27
|
provide_email: "На какой адрес отправить?"
|
28
28
|
sent_notice: "Оправлено на %{address} через %{delivery_method}"
|
29
|
+
errors:
|
30
|
+
email_missing_format: "Формат отсутствует"
|
29
31
|
layouts:
|
30
32
|
rails_email_preview:
|
31
33
|
application:
|
data/config/routes.rb
CHANGED
@@ -3,16 +3,18 @@ RailsEmailPreview::Engine.routes.draw do
|
|
3
3
|
scope path: '(:email_locale)',
|
4
4
|
# This constraint resolves ambiguity with :preview_id, allowing locale to be optional
|
5
5
|
constraints: {email_locale: /#{I18n.available_locales.map(&Regexp.method(:escape)) * '|'}/},
|
6
|
-
defaults: {email_locale: I18n.default_locale} do
|
6
|
+
defaults: {email_locale: I18n.default_locale.to_s} do
|
7
7
|
get '/' => :index, as: :rep_emails
|
8
8
|
scope path: ':preview_id', constraints: {preview_id: /\w+-\w+/} do
|
9
|
-
scope '(:part_type)',
|
9
|
+
scope '(:part_type)',
|
10
|
+
constraints: {part_type: /html|plain|raw/},
|
11
|
+
defaults: {part_type: 'html'} do
|
10
12
|
get '' => :show, as: :rep_email
|
11
13
|
get 'body' => :show_body, as: :rep_raw_email
|
12
14
|
end
|
13
15
|
post 'deliver' => :test_deliver, as: :rep_test_deliver
|
14
16
|
get 'attachments/:filename' => :show_attachment, as: :rep_raw_email_attachment
|
15
|
-
get 'headers' => :
|
17
|
+
get 'headers' => :show_headers, as: :rep_email_headers
|
16
18
|
end
|
17
19
|
# alias rep_emails_url to its stable api name
|
18
20
|
get '/' => :index, as: :rep_root
|
@@ -0,0 +1,102 @@
|
|
1
|
+
module RailsEmailPreview
|
2
|
+
# Add hooks before, after, or replacing a UI element
|
3
|
+
class ViewHooks
|
4
|
+
args = {
|
5
|
+
index: [:list, :previews].freeze,
|
6
|
+
show: [:mail, :preview].freeze
|
7
|
+
}
|
8
|
+
# All valid hooks and their argument names
|
9
|
+
SCHEMA = {
|
10
|
+
list: args[:index],
|
11
|
+
headers_and_nav: args[:show],
|
12
|
+
headers: args[:show],
|
13
|
+
headers_content: args[:show],
|
14
|
+
nav: args[:show],
|
15
|
+
nav_i18n: args[:show],
|
16
|
+
nav_format: args[:show],
|
17
|
+
nav_send: args[:show],
|
18
|
+
email_body: args[:show],
|
19
|
+
}
|
20
|
+
POSITIONS = [:before, :replace, :after].freeze
|
21
|
+
|
22
|
+
def initialize
|
23
|
+
@hooks = Hooks.new
|
24
|
+
end
|
25
|
+
|
26
|
+
# @param [Symbol] id
|
27
|
+
# @param [:before, :replace, :after] pos
|
28
|
+
# @example
|
29
|
+
# view_hooks.add_render :list, :before, partial: 'shared/hello'
|
30
|
+
def add_render(id, pos, *render_args)
|
31
|
+
render_args = render_args.deep_dup
|
32
|
+
render_opts = render_args.extract_options!
|
33
|
+
add id, pos do |locals = {}|
|
34
|
+
render *render_args, render_opts.merge(
|
35
|
+
locals: (render_opts[:locals] || {}).merge(locals))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# @param [Symbol] id
|
40
|
+
# @param [:before, :replace, :after] pos
|
41
|
+
# @example
|
42
|
+
# view_hooks.add :headers_content, :after do |mail:, preview:|
|
43
|
+
# raw "<b>ID</b>: #{h mail.header['X-APP-EMAIL-ID']}"
|
44
|
+
# end
|
45
|
+
def add(id, pos, &block)
|
46
|
+
@hooks[id][pos] << block
|
47
|
+
end
|
48
|
+
|
49
|
+
def render(hook_id, locals, template, &content)
|
50
|
+
at = @hooks[hook_id]
|
51
|
+
validate_locals! hook_id, locals
|
52
|
+
parts = [
|
53
|
+
render_providers(at[:before], locals, template),
|
54
|
+
if at[:replace].present?
|
55
|
+
render_providers(at[:replace], locals, template)
|
56
|
+
else
|
57
|
+
template.capture { content.call(locals) }
|
58
|
+
end,
|
59
|
+
render_providers(at[:after], locals, template)
|
60
|
+
]
|
61
|
+
template.safe_join(parts, '')
|
62
|
+
end
|
63
|
+
|
64
|
+
# Find available hooks with simple static analysis of the gem's views
|
65
|
+
# @return [Array<String>] return hook names
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def render_providers(providers, locals, template)
|
70
|
+
template.safe_join providers.map { |provider| template.instance_exec(locals, &provider) }, ''
|
71
|
+
end
|
72
|
+
|
73
|
+
def validate_locals!(hook_id, locals)
|
74
|
+
if locals.keys.sort != SCHEMA[hook_id].sort
|
75
|
+
raise ArgumentError.new("Invalid arguments #{locals.keys}. Valid: #{SCHEMA[hook_id]}")
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Hooks < DelegateClass(Hash)
|
80
|
+
def initialize
|
81
|
+
super Hash.new { |h, id|
|
82
|
+
validate_id! id
|
83
|
+
h[id] = Hash.new { |hh, pos|
|
84
|
+
validate_pos! pos
|
85
|
+
hh[pos] = []
|
86
|
+
}
|
87
|
+
}
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
|
92
|
+
def validate_id!(id)
|
93
|
+
raise ArgumentError.new('hook id must be a symbol') unless Symbol === id
|
94
|
+
raise ArgumentError.new("Invalid hook #{id}. Valid: #{SCHEMA.keys * ', '}.") unless SCHEMA.key?(id)
|
95
|
+
end
|
96
|
+
|
97
|
+
def validate_pos!(pos)
|
98
|
+
raise ArgumentError.new("Invalid position #{pos}. Valid: #{POSITIONS * ', '}") unless POSITIONS.include?(pos)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
data/lib/rails_email_preview.rb
CHANGED
@@ -3,6 +3,7 @@ require 'rails_email_preview/engine'
|
|
3
3
|
require 'rails_email_preview/main_app_route_delegator'
|
4
4
|
require 'rails_email_preview/version'
|
5
5
|
require 'rails_email_preview/delivery_handler'
|
6
|
+
require 'rails_email_preview/view_hooks'
|
6
7
|
|
7
8
|
require 'slim'
|
8
9
|
require 'slim-rails'
|
@@ -43,7 +44,10 @@ module RailsEmailPreview
|
|
43
44
|
column_class: 'col-sm-%{n}'
|
44
45
|
}
|
45
46
|
|
47
|
+
@view_hooks = RailsEmailPreview::ViewHooks.new
|
46
48
|
class << self
|
49
|
+
# @return [RailsEmailPreview::ViewHooks]
|
50
|
+
attr_reader :view_hooks
|
47
51
|
def preview_classes=(classes)
|
48
52
|
@preview_classes = classes
|
49
53
|
RailsEmailPreview::Preview.load_all(classes)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_email_preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Mazovetskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -178,7 +178,10 @@ files:
|
|
178
178
|
- app/views/rails_email_preview/emails/_email_iframe.html.slim
|
179
179
|
- app/views/rails_email_preview/emails/_format_nav.html.slim
|
180
180
|
- app/views/rails_email_preview/emails/_headers.html.slim
|
181
|
+
- app/views/rails_email_preview/emails/_headers_and_nav.html.slim
|
182
|
+
- app/views/rails_email_preview/emails/_headers_content.html.slim
|
181
183
|
- app/views/rails_email_preview/emails/_i18n_nav.html.slim
|
184
|
+
- app/views/rails_email_preview/emails/_nav.html.slim
|
182
185
|
- app/views/rails_email_preview/emails/_send_form.html.slim
|
183
186
|
- app/views/rails_email_preview/emails/index.html.slim
|
184
187
|
- app/views/rails_email_preview/emails/show.html.slim
|
@@ -196,6 +199,7 @@ files:
|
|
196
199
|
- lib/rails_email_preview/integrations/comfortable_mexica_sofa.rb
|
197
200
|
- lib/rails_email_preview/main_app_route_delegator.rb
|
198
201
|
- lib/rails_email_preview/version.rb
|
202
|
+
- lib/rails_email_preview/view_hooks.rb
|
199
203
|
homepage: https://github.com/glebm/rails_email_preview
|
200
204
|
licenses:
|
201
205
|
- MIT
|