rails_email_preview 0.2.20 → 0.2.21
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/Gemfile +1 -1
- data/README.md +18 -21
- data/app/controllers/rails_email_preview/emails_controller.rb +16 -2
- data/app/helpers/rails_email_preview/emails_helper.rb +14 -6
- data/app/views/integrations/cms/_customize_cms_for_rails_email_preview.html.slim +3 -2
- data/config/i18n-tasks.yml +4 -1
- data/config/locales/de.yml +22 -15
- data/config/locales/en.yml +20 -15
- data/config/routes.rb +1 -0
- data/lib/rails_email_preview/integrations/comfortable_mexica_sofa.rb +93 -51
- data/lib/rails_email_preview/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6a3a68dcd424b8bad4c8835e9a43cfb388ccadd
|
4
|
+
data.tar.gz: 0c878a6582eee10408bf7bc522b60fb49961b77e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc4d460e598e8daaaa8b81ee000c51ae6fecd382be0a705ceff5bd36895f54e47f91b69cfb056f396012b0ace6fc29baf85f7038f559c76e914d77bdcba802a2
|
7
|
+
data.tar.gz: eee63446fb36c5e0c5675de0ed9d7a24f8bcedf4c1bd504ca2a1ac6f3a44ebdacd07593a3eed7e1b0c5aebd5671b50db0afb3764b68437fe307923489a48f41a
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
Rails Email Preview [![Build Status]
|
2
|
-
================================
|
1
|
+
# Rails Email Preview [![Build Status][travis-badge]][travis] [![Gem Version][gem-badge]][gem] [![Code Climate][codeclimate-badge]][codeclimate]
|
3
2
|
|
4
3
|
A Rails Engine to preview plain text and html email in your browser. Compatible with Rails 3 and 4.
|
5
4
|
|
@@ -12,13 +11,12 @@ List:
|
|
12
11
|
REP can use the application styles and comes with [a bootstrap 3 theme][rep-show-default-screenshot] by default (default markup for [twbs/bootstrap](twbs/bootstrap) 3).
|
13
12
|
*These screenshots are from [Zuigo](http://zuigo.com/), a platform to organize & discover events; using REP default markup and app styles*
|
14
13
|
|
15
|
-
How to
|
16
|
-
-----
|
14
|
+
## How to
|
17
15
|
|
18
16
|
Add to Gemfile
|
19
17
|
|
20
18
|
```ruby
|
21
|
-
gem 'rails_email_preview', '~> 0.2.
|
19
|
+
gem 'rails_email_preview', '~> 0.2.21'
|
22
20
|
```
|
23
21
|
|
24
22
|
REP handles setup for you:
|
@@ -61,8 +59,7 @@ end
|
|
61
59
|
```
|
62
60
|
|
63
61
|
|
64
|
-
Routing
|
65
|
-
-------
|
62
|
+
## Routing
|
66
63
|
|
67
64
|
You can access REP urls like this:
|
68
65
|
|
@@ -75,8 +72,7 @@ rails_email_preview.rep_emails_url
|
|
75
72
|
rails_email_preview.rep_email_url('user_mailer-welcome')
|
76
73
|
```
|
77
74
|
|
78
|
-
Send Emails
|
79
|
-
-------------------
|
75
|
+
## Send Emails
|
80
76
|
|
81
77
|
You can send emails via REP. This is especially useful when testing with limited clients (Blackberry, Outlook, etc.).
|
82
78
|
This will use the environment's mailer settings, but the handler will `perform_deliveries`.
|
@@ -86,8 +82,7 @@ Uncomment this line in the initializer to disable sending test emails:
|
|
86
82
|
config.enable_send_email = false
|
87
83
|
```
|
88
84
|
|
89
|
-
Email editing
|
90
|
-
-------------
|
85
|
+
## Email editing
|
91
86
|
|
92
87
|
You can use [comfortable_mexican_sofa](https://github.com/comfy/comfortable-mexican-sofa) for storing and editing emails.
|
93
88
|
REP comes with an integration for it -- see [CMS Guide](https://github.com/glebm/rails_email_preview/wiki/Edit-Emails-with-Comfortable-Mexican-Sofa).
|
@@ -95,16 +90,14 @@ REP comes with an integration for it -- see [CMS Guide](https://github.com/glebm
|
|
95
90
|
[](https://github.com/glebm/rails_email_preview/wiki/Edit-Emails-with-Comfortable-Mexican-Sofa)
|
96
91
|
|
97
92
|
|
98
|
-
Premailer
|
99
|
-
---------------------
|
93
|
+
## Premailer
|
100
94
|
|
101
95
|
[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.
|
102
96
|
|
103
97
|
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).
|
104
98
|
Simply uncomment the relevant options in [the initializer](https://github.com/glebm/rails_email_preview/blob/master/config/initializers/rails_email_preview.rb). *initializer is generated during `rails g rails_email_preview:install`*
|
105
99
|
|
106
|
-
I18n
|
107
|
-
-------------
|
100
|
+
## I18n
|
108
101
|
|
109
102
|
REP expects emails to use current `I18n.locale`:
|
110
103
|
|
@@ -136,8 +129,7 @@ You can set the language in `config.to_prepare` section of the initializer, defa
|
|
136
129
|
RailsEmailPreview.locale = :de
|
137
130
|
```
|
138
131
|
|
139
|
-
Views
|
140
|
-
---------------------
|
132
|
+
## Views
|
141
133
|
|
142
134
|
You can render all REP views inside your app layout (this will need styling to look nice if you don't use bootstrap):
|
143
135
|
|
@@ -174,8 +166,7 @@ You can `//= require 'rails_email_preview/layout'` REP-specific styles (`@import
|
|
174
166
|
You can also override any individual view by placing a file with the same path in your project's `app/views`,
|
175
167
|
e.g. `app/views/rails_email_preview/emails/index.html.slim`. *PRs accepted* if you need hooks.
|
176
168
|
|
177
|
-
Authentication & authorization
|
178
|
-
------------------------------
|
169
|
+
## Authentication & authorization
|
179
170
|
|
180
171
|
You can specify the parent controller for REP controller, and it will inherit all before filters.
|
181
172
|
Note that this must be placed before any other references to REP application controller in the initializer (and before `layout=` call):
|
@@ -207,5 +198,11 @@ This project rocks and uses MIT-LICENSE.
|
|
207
198
|
[rep-show-default-screenshot]: https://raw.github.com/glebm/rails_email_preview/master/doc/img/rep-show-default.png "Show Email Screenshot (default styles)"
|
208
199
|
|
209
200
|
|
210
|
-
[
|
211
|
-
|
201
|
+
[travis]: http://travis-ci.org/glebm/rails_email_preview
|
202
|
+
[travis-badge]: http://img.shields.io/travis/glebm/rails_email_preview.svg
|
203
|
+
[gem]: https://rubygems.org/gems/rails_email_preview
|
204
|
+
[gem-badge]: http://img.shields.io/gem/v/rails_email_preview.svg
|
205
|
+
[codeclimate]: https://codeclimate.com/github/glebm/rails_email_preview
|
206
|
+
[codeclimate-badge]: http://img.shields.io/codeclimate/github/glebm/rails_email_preview.svg
|
207
|
+
[coveralls]: https://coveralls.io/r/glebm/rails_email_preview
|
208
|
+
[coveralls-badge]: http://img.shields.io/coveralls/glebm/rails_email_preview.svg
|
@@ -30,6 +30,12 @@ class RailsEmailPreview::EmailsController < ::RailsEmailPreview::ApplicationCont
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def show_attachment
|
34
|
+
@mail = @preview.preview_mail
|
35
|
+
attachment = @mail.attachments.find { |a| a.filename == "#{params[:filename]}.#{request.format.symbol}" }
|
36
|
+
send_data attachment.body.raw_source
|
37
|
+
end
|
38
|
+
|
33
39
|
def test_deliver
|
34
40
|
redirect_url = rails_email_preview.rep_email_url(params.slice(:preview_id, :email_locale))
|
35
41
|
if (address = params[:recipient_email]).blank? || address !~ /@/
|
@@ -61,7 +67,7 @@ class RailsEmailPreview::EmailsController < ::RailsEmailPreview::ApplicationCont
|
|
61
67
|
def mail_body(preview, part_type, edit_links = (part_type == 'text/html'))
|
62
68
|
RequestStore.store[:rep_edit_links] = true if edit_links
|
63
69
|
mail = preview.preview_mail(true)
|
64
|
-
|
70
|
+
|
65
71
|
return "<pre id='raw_message'>#{html_escape(mail.to_s)}</pre>".html_safe if part_type == 'raw'
|
66
72
|
|
67
73
|
body_part = if mail.multipart?
|
@@ -69,10 +75,18 @@ class RailsEmailPreview::EmailsController < ::RailsEmailPreview::ApplicationCont
|
|
69
75
|
else
|
70
76
|
mail
|
71
77
|
end
|
78
|
+
|
72
79
|
if body_part.content_type =~ /plain/
|
73
80
|
"<pre id='message_body'>#{html_escape(body_part.body.to_s)}</pre>".html_safe
|
74
81
|
else
|
75
|
-
body_part.body.to_s
|
82
|
+
body_content = body_part.body.to_s
|
83
|
+
|
84
|
+
mail.attachments.each do |attachment|
|
85
|
+
web_url = rails_email_preview.rep_raw_email_attachment_url(params[:preview_id], attachment.filename)
|
86
|
+
body_content.gsub!(attachment.url, web_url)
|
87
|
+
end
|
88
|
+
|
89
|
+
body_content.html_safe
|
76
90
|
end
|
77
91
|
end
|
78
92
|
|
@@ -24,15 +24,23 @@ module RailsEmailPreview::EmailsHelper
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def attachment_links
|
28
|
+
@mail.attachments.map do |attachment|
|
29
|
+
url = rails_email_preview.rep_raw_email_attachment_path(params[:preview_id], attachment.filename)
|
30
|
+
link_to(attachment.filename, url)
|
31
|
+
end.join('').html_safe
|
32
|
+
end
|
33
|
+
|
27
34
|
def headers_name_value
|
28
35
|
I18n.with_locale @email_locale do
|
29
36
|
{
|
30
|
-
'Subject'
|
31
|
-
'From'
|
32
|
-
'Reply to'
|
33
|
-
'To'
|
34
|
-
'CC'
|
35
|
-
'BCC'
|
37
|
+
'Subject' => @mail.subject || '(no subject)',
|
38
|
+
'From' => @mail.from,
|
39
|
+
'Reply to' => @mail.reply_to,
|
40
|
+
'To' => @mail.to,
|
41
|
+
'CC' => @mail.cc,
|
42
|
+
'BCC' => @mail.bcc,
|
43
|
+
'Attachments' => attachment_links
|
36
44
|
}.delete_if { |k, v| v.blank? }
|
37
45
|
end
|
38
46
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
-# When rendering inside rails_email_preview hide nav, and hide irrelevant things from the form
|
2
2
|
ruby:
|
3
|
-
|
4
|
-
|
3
|
+
adapter = ::RailsEmailPreview::Integrations::ComfortableMexicanSofa
|
4
|
+
snippet = @snippet || (adapter.cms_snippet_class === @record && @record)
|
5
|
+
if snippet && (p = adapter.rep_email_params_from_snippet(snippet))
|
5
6
|
show_url = rails_email_preview.rep_raw_email_url(p.merge part_type: 'text/html')
|
6
7
|
end
|
7
8
|
customize_form = show_url.present? || snippet && !snippet.persisted?
|
data/config/i18n-tasks.yml
CHANGED
data/config/locales/de.yml
CHANGED
@@ -1,34 +1,41 @@
|
|
1
|
+
---
|
1
2
|
de:
|
2
3
|
rep:
|
3
4
|
base:
|
4
5
|
email:
|
5
|
-
one:
|
6
|
+
one: 1 E-Mail
|
6
7
|
other: "%{count} E-Mails"
|
7
8
|
mailer:
|
8
|
-
one:
|
9
|
+
one: 1 Mailer
|
9
10
|
other: "%{count} Mailer"
|
10
|
-
in:
|
11
|
-
loading:
|
11
|
+
in: in
|
12
|
+
loading: Lade...
|
12
13
|
test_deliver:
|
13
|
-
no_delivery_method:
|
14
|
-
|
15
|
-
|
14
|
+
no_delivery_method: Bitte setze 'config.action_mailer.delivery_method' um E-Mails
|
15
|
+
in der „%{environment}“ Umgebung zu senden.
|
16
|
+
provide_email: An welche Adresse senden?
|
17
|
+
sent_notice: Senden an %{address} mit %{delivery_method}
|
16
18
|
layouts:
|
17
19
|
rails_email_preview:
|
18
20
|
application:
|
19
|
-
head_title:
|
21
|
+
head_title: E-Mails - REP
|
20
22
|
rails_email_preview:
|
21
23
|
emails:
|
22
24
|
index:
|
23
|
-
list_title:
|
25
|
+
list_title: Anwendungs E-Mails
|
24
26
|
show:
|
25
|
-
breadcrumb_list:
|
27
|
+
breadcrumb_list: E-Mails
|
26
28
|
send_form:
|
27
|
-
send_are_you_sure:
|
28
|
-
|
29
|
-
|
29
|
+
send_are_you_sure: Diese Aktion wird diese E-Mail wirklich versenden. Bist
|
30
|
+
du sicher?
|
31
|
+
send_btn: Senden an
|
32
|
+
send_recipient_placeholder: E-Mails
|
30
33
|
integrations:
|
31
34
|
cms:
|
32
35
|
customize_cms_for_rails_email_preview:
|
33
|
-
edit_email:
|
34
|
-
view_link:
|
36
|
+
edit_email: E-Mail bearbeiten
|
37
|
+
view_link: Anzeigen
|
38
|
+
errors:
|
39
|
+
site_missing: Bitte erstellen Sie eine CMS-Website für %{locale} zuerst. Bei
|
40
|
+
der Verwendung von mehreren Gebietsschemas sollte der Standort gespiegelt
|
41
|
+
werden.
|
data/config/locales/en.yml
CHANGED
@@ -1,34 +1,39 @@
|
|
1
|
+
---
|
1
2
|
en:
|
2
3
|
rep:
|
3
4
|
base:
|
4
5
|
email:
|
5
|
-
one:
|
6
|
+
one: 1 email
|
6
7
|
other: "%{count} emails"
|
7
8
|
mailer:
|
8
|
-
one:
|
9
|
+
one: 1 mailer
|
9
10
|
other: "%{count} mailers"
|
10
|
-
in:
|
11
|
-
loading:
|
11
|
+
in: in
|
12
|
+
loading: Loading...
|
12
13
|
test_deliver:
|
13
|
-
no_delivery_method:
|
14
|
-
|
15
|
-
|
14
|
+
no_delivery_method: Please set 'config.action_mailer.delivery_method' to send
|
15
|
+
emails in '%{environment}' environment
|
16
|
+
provide_email: Send to which address?
|
17
|
+
sent_notice: Sent to %{address} via %{delivery_method}
|
16
18
|
layouts:
|
17
19
|
rails_email_preview:
|
18
20
|
application:
|
19
|
-
head_title:
|
21
|
+
head_title: Emails - REP
|
20
22
|
rails_email_preview:
|
21
23
|
emails:
|
22
24
|
index:
|
23
|
-
list_title:
|
25
|
+
list_title: Application Emails
|
24
26
|
show:
|
25
|
-
breadcrumb_list:
|
27
|
+
breadcrumb_list: Emails
|
26
28
|
send_form:
|
27
|
-
send_are_you_sure:
|
28
|
-
send_btn:
|
29
|
-
send_recipient_placeholder:
|
29
|
+
send_are_you_sure: This will actually send this email. Are you sure?
|
30
|
+
send_btn: Send to
|
31
|
+
send_recipient_placeholder: Email
|
30
32
|
integrations:
|
31
33
|
cms:
|
34
|
+
errors:
|
35
|
+
site_missing: Please create a CMS site for %{locale} first. When using multiple
|
36
|
+
locales the site should be Mirrored.
|
32
37
|
customize_cms_for_rails_email_preview:
|
33
|
-
edit_email:
|
34
|
-
view_link:
|
38
|
+
edit_email: Editing email
|
39
|
+
view_link: View
|
data/config/routes.rb
CHANGED
@@ -2,6 +2,7 @@ RailsEmailPreview::Engine.routes.draw do
|
|
2
2
|
get '/' => 'emails#index', as: :rep_emails
|
3
3
|
|
4
4
|
get 'raw/:preview_id' => 'emails#show_body', as: :rep_raw_email
|
5
|
+
get 'raw/:preview_id/:filename' => 'emails#show_attachment', as: :rep_raw_email_attachment
|
5
6
|
get ':preview_id' => 'emails#show', as: :rep_email
|
6
7
|
post 'test_deliver/:preview_id' => 'emails#test_deliver', as: :rep_test_deliver
|
7
8
|
|
@@ -5,21 +5,26 @@
|
|
5
5
|
module RailsEmailPreview
|
6
6
|
module Integrations
|
7
7
|
module ComfortableMexicanSofa
|
8
|
-
#
|
8
|
+
# @return [String] CMS identifier for the current email
|
9
9
|
# ModerationMailer#approve -> "moderation_mailer-approve"
|
10
10
|
def cms_email_id
|
11
11
|
mailer = respond_to?(:controller) ? controller : self
|
12
12
|
"#{mailer.class.name.underscore}-#{action_name}"
|
13
13
|
end
|
14
14
|
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
15
|
+
# @param [Hash] interpolation subject interpolation values
|
16
|
+
# @return [String] Snippet title interpolated with passed variables
|
17
|
+
#
|
18
|
+
# For a snippet with title "Welcome, %{name}!"
|
19
|
+
# cms_email_subject(name: "Alice") #=> "Welcome, Alice!"
|
18
20
|
def cms_email_subject(interpolation = {})
|
19
21
|
snippet_id = "email-#{cms_email_id}"
|
20
|
-
return '(no subject)' unless
|
22
|
+
return '(no subject)' unless cms_snippet_class.where(identifier: snippet_id).exists?
|
21
23
|
[I18n.locale, I18n.default_locale].compact.each do |locale|
|
22
|
-
site =
|
24
|
+
site = cms_site_class.find_by_locale(locale.to_s)
|
25
|
+
unless site
|
26
|
+
raise "rails_email_preview: #{t 'integrations.cms.errors.site_missing', locale: locale}"
|
27
|
+
end
|
23
28
|
snippet = site.snippets.find_by_identifier(snippet_id)
|
24
29
|
next unless snippet.try(:content).present?
|
25
30
|
|
@@ -41,72 +46,109 @@ module RailsEmailPreview
|
|
41
46
|
RequestStore.store[:rep_edit_links]
|
42
47
|
end
|
43
48
|
|
44
|
-
def
|
45
|
-
|
46
|
-
#
|
47
|
-
:
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def cms_email_edit_link(site, default_site, snippet_id)
|
50
|
+
snippet = site.snippets.find_by_identifier(snippet_id) || cms_snippet_class.new(
|
51
|
+
label: "#{snippet_id.sub('-', ' / ').humanize}",
|
52
|
+
identifier: snippet_id,
|
53
|
+
site: site
|
54
|
+
)
|
55
|
+
p = {site_id: site.id}
|
56
|
+
edit_path = if snippet.persisted?
|
57
|
+
p[:id] = snippet.id
|
58
|
+
if snippet.content.blank? && default_site && (default_snippet = default_site.snippets.find_by_identifier(snippet_id))
|
59
|
+
p[:snippet] = {
|
60
|
+
content: default_snippet.content
|
61
|
+
}
|
62
|
+
p[:snippet][:label] = default_snippet.label unless snippet.label.present?
|
63
|
+
end
|
64
|
+
send :"edit_#{cms_admin_site_snippet_route}_path", p
|
65
|
+
else
|
66
|
+
p[:snippet] = {
|
67
|
+
label: snippet.label,
|
68
|
+
identifier: snippet.identifier,
|
69
|
+
category_ids: [site.categories.find_by_label('email').try(:id)]
|
70
|
+
}
|
71
|
+
send :"new_#{cms_admin_site_snippet_route}_path", p
|
72
|
+
end
|
73
|
+
<<-HTML.strip.html_safe
|
74
|
+
<table class='rep-edit-link'><tr><td>
|
75
|
+
#{cms_edit_email_snippet_link(edit_path)}
|
76
|
+
</td></tr></table>
|
77
|
+
HTML
|
51
78
|
end
|
52
79
|
|
53
|
-
#
|
54
|
-
#
|
80
|
+
# @return [String] Snippet content, passed through Kramdown.
|
81
|
+
# Also renders an "✎ Edit" link inside the email when called from preview
|
55
82
|
def cms_email_snippet(snippet_id = self.cms_email_id)
|
56
|
-
snippet_id
|
57
|
-
site
|
58
|
-
|
59
|
-
|
83
|
+
snippet_id = "email-#{snippet_id}"
|
84
|
+
site = cms_site_class.find_by_locale(I18n.locale.to_s)
|
85
|
+
default_site = cms_site_class.find_by_locale(I18n.default_locale.to_s)
|
86
|
+
|
87
|
+
if cms_snippet_class.where(identifier: snippet_id).exists?
|
88
|
+
# Prefill from default locale if no content
|
60
89
|
content = send(cms_snippet_render_method, snippet_id, site)
|
61
|
-
|
62
|
-
default_site = Cms::Site.find_by_locale(I18n.default_locale.to_s)
|
63
|
-
fallback_content = send(cms_snippet_render_method, snippet_id, default_site).presence
|
64
|
-
end
|
65
|
-
result = (content || fallback_content).to_s
|
90
|
+
result = (content.presence || send(cms_snippet_render_method, snippet_id, default_site)).to_s
|
66
91
|
else
|
67
92
|
result = ''
|
68
93
|
end
|
69
94
|
|
70
|
-
# If rendering in preview from admin, add edit/create
|
95
|
+
# If rendering in preview from admin, add edit/create link
|
71
96
|
if cms_email_edit_link?
|
72
|
-
|
73
|
-
|
74
|
-
route_name = respond_to?(:new_cms_admin_site_snippet_path) ? :cms_admin_site_snippet : :admin_cms_site_snippet
|
75
|
-
|
76
|
-
|
77
|
-
cms_path = if snippet
|
78
|
-
unless content
|
79
|
-
fallback_snippet = default_site.snippets.find_by_identifier(snippet_id)
|
80
|
-
prefill_from_default = {label: fallback_snippet.label, content: fallback_snippet.content}
|
81
|
-
end
|
82
|
-
send :"edit_#{route_name}_path", site_id: site.id, id: snippet.id, snippet: prefill_from_default || nil
|
83
|
-
else
|
84
|
-
send :"new_#{route_name}_path", site_id: site.id,
|
85
|
-
snippet: {
|
86
|
-
label: "#{snippet_id.sub('-', ' / ').humanize}",
|
87
|
-
identifier: snippet_id,
|
88
|
-
category_ids: [site.categories.find_by_label('email').try(:id)]
|
89
|
-
}
|
90
|
-
end
|
91
|
-
|
92
|
-
result = safe_join ["<table class='rep-edit-link'><tr><td>".html_safe, cms_edit_email_snippet_link(cms_path),
|
93
|
-
"</td></tr></table>".html_safe, "\n\n", result]
|
97
|
+
result = safe_join [cms_email_edit_link(site, default_site, snippet_id), result], "\n\n"
|
94
98
|
end
|
95
99
|
result
|
96
100
|
end
|
97
101
|
|
98
102
|
def cms_edit_email_snippet_link(path)
|
99
|
-
link_to(RailsEmailPreview.edit_link_text, path, style: RailsEmailPreview.edit_link_style.html_safe
|
103
|
+
link_to(RailsEmailPreview.edit_link_text, path, style: RailsEmailPreview.edit_link_style.html_safe)
|
100
104
|
end
|
101
105
|
|
102
106
|
def self.rep_email_params_from_snippet(snippet)
|
103
107
|
id_prefix = 'email-'
|
104
108
|
return unless snippet && snippet.identifier && snippet.identifier.starts_with?(id_prefix)
|
105
109
|
mailer_cl, act = snippet.identifier[id_prefix.length..-1].split('-')
|
106
|
-
act
|
107
|
-
|
108
|
-
|
110
|
+
{preview_id: "#{mailer_cl}_preview-#{act}",
|
111
|
+
email_locale: snippet.site.locale}
|
112
|
+
end
|
113
|
+
|
114
|
+
module CmsVersionsCompatibility
|
115
|
+
def cms_admin_site_snippet_route
|
116
|
+
if respond_to?(:new_comfy_admin_cms_site_snippet_path)
|
117
|
+
# cms >= 1.11
|
118
|
+
:comfy_admin_cms_site_snippet
|
119
|
+
else
|
120
|
+
:admin_cms_site_snippet
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def cms_snippet_class
|
125
|
+
if defined?(::Comfy::Cms::Snippet)
|
126
|
+
# cms >= 1.12
|
127
|
+
::Comfy::Cms::Snippet
|
128
|
+
else
|
129
|
+
::Cms::Snippet
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def cms_site_class
|
134
|
+
if defined?(::Comfy::Cms::Site)
|
135
|
+
# cms >= 1.12
|
136
|
+
::Comfy::Cms::Site
|
137
|
+
else
|
138
|
+
::Cms::Site
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
def cms_snippet_render_method
|
143
|
+
[
|
144
|
+
# cms >= 1.11
|
145
|
+
:cms_snippet_render,
|
146
|
+
:cms_snippet_content
|
147
|
+
].detect { |m| respond_to? m }
|
148
|
+
end
|
109
149
|
end
|
150
|
+
extend CmsVersionsCompatibility
|
151
|
+
include CmsVersionsCompatibility
|
110
152
|
end
|
111
153
|
end
|
112
154
|
end
|
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.21
|
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-
|
11
|
+
date: 2014-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -86,42 +86,42 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.5.2
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.5.2
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: capybara
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 2.3.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 2.3.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 3.0.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 3.0.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rspec-rails
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|