rails_email_preview 0.1.2 → 0.1.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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2327030739ba9db8a54b1ebb9dbe8b9ec2a08d1
|
4
|
+
data.tar.gz: 02f026c42ab14c959abd425df25333f4eda089ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa93f32d0dfaaaf849f237e528bbb639ad5c2061d857c991bc5a6e24dff04c18ec7efde75c052efeac910c4a400c16b6a72089c5f8596f597d0159fea93a1e5d
|
7
|
+
data.tar.gz: 6292757e5522d27c7e8431849da37cd44747a8de074b3ca72dfc1d4863124b078e495a683d638ff8bba0f8387f8091f03e84adfcff5efbf409e9a179fb56c1df
|
data/README.md
CHANGED
@@ -3,9 +3,9 @@ Rails Email Preview
|
|
3
3
|
|
4
4
|
A Rails Engine to preview plain text and html email in your browser. Compatible with Rails 3 and 4.
|
5
5
|
|
6
|
-

|
7
6
|

|
8
|
-
|
7
|
+

|
8
|
+
*(styles are from the application)*
|
9
9
|
|
10
10
|
How to
|
11
11
|
-----
|
@@ -40,23 +40,30 @@ You will need to provide data for preview of each email:
|
|
40
40
|
User.new(name: name, email: "user@test.com#{rand 100}").tap { |u| u.define_singleton_method(:id) { 123 + rand(100) } }
|
41
41
|
end
|
42
42
|
end
|
43
|
+
|
44
|
+
# Let REP know about UserMailerPreview:
|
45
|
+
# touch config/initializers/rails_email_preview.rb
|
46
|
+
RailsEmailPreview.setup do |config|
|
47
|
+
config.preview_classes = [ UserMailerPreview ]
|
48
|
+
end
|
43
49
|
|
44
50
|
|
45
51
|
Routing
|
46
52
|
-------
|
47
53
|
|
48
|
-
mount RailsEmailPreview::Engine, at: '
|
54
|
+
mount RailsEmailPreview::Engine, at: 'emails'
|
55
|
+
|
56
|
+
# You can access REP urls like this:
|
57
|
+
rails_email_preview.root_url #=> '/emails'
|
58
|
+
|
59
|
+
Email editing
|
60
|
+
-------------
|
49
61
|
|
62
|
+
You can use [comfortable_mexican_sofa](https://github.com/comfy/comfortable-mexican-sofa) for storing and editing emails.
|
63
|
+
REP comes with a CMS integration, see [ComfortableMexicanSofa integration guide](https://github.com/glebm/rails_email_preview/wiki/Edit-Emails-with-Comfortable-Mexican-Sofa).
|
50
64
|
|
51
|
-
|
52
|
-
-------
|
53
|
-
|
54
|
-
# touch config/initializers/rails_email_preview.rb
|
65
|
+

|
55
66
|
|
56
|
-
require 'rails_email_preview'
|
57
|
-
RailsEmailPreview.setup do |config|
|
58
|
-
config.preview_classes = [ UserMailerPreview ]
|
59
|
-
end
|
60
67
|
|
61
68
|
Premailer integration
|
62
69
|
---------------------
|
@@ -73,18 +80,11 @@ For [premailer-rails](https://github.com/fphilipe/premailer-rails), add to `Rail
|
|
73
80
|
|
74
81
|
config.before_render { |message| Premailer::Rails::Hook.delivering_email(message) }
|
75
82
|
|
76
|
-
Email editing
|
77
|
-
-------------
|
78
|
-
|
79
|
-
You can use [comfortable_mexican_sofa](https://github.com/comfy/comfortable-mexican-sofa) for storing and editing emails.
|
80
|
-
REP comes with a CMS integration, see [ComfortableMexicanSofa integration guide](https://github.com/glebm/rails_email_preview/wiki/Edit-Emails-with-Comfortable-Mexican-Sofa).
|
81
|
-
|
82
|
-

|
83
83
|
|
84
84
|
I18n
|
85
85
|
-------------
|
86
86
|
|
87
|
-
|
87
|
+
REP expects emails to use current `I18n.locale`:
|
88
88
|
|
89
89
|
# current locale
|
90
90
|
AccountMailer.some_notification.deliver
|
@@ -7,12 +7,12 @@ javascript:
|
|
7
7
|
$('.center-column').css('margin', 0);
|
8
8
|
|
9
9
|
// Snippet form:
|
10
|
-
//
|
10
|
+
// Hide identifier and categories
|
11
11
|
$('[name="snippet[identifier]"]').closest('.control-group').hide();
|
12
12
|
$('label[for="snippet_"]').closest('.control-group').hide();
|
13
|
-
//
|
13
|
+
// Label to Subject
|
14
14
|
$('[name="snippet[label]"]').closest('.control-group').find('.control-label').text("Subject");
|
15
|
-
//
|
15
|
+
// Content to Body
|
16
16
|
$('[name="snippet[content]"]').closest('.control-group').find('.control-label').text("Body");
|
17
17
|
}
|
18
18
|
});
|
@@ -25,12 +25,13 @@ module RailsEmailPreview
|
|
25
25
|
title = snippet.label.to_s
|
26
26
|
interpolation = interpolation.stringify_keys
|
27
27
|
# set all missing values to ''
|
28
|
-
title.scan(/%{([^}]+)}/) { |
|
28
|
+
title.scan(/%{([^}]+)}/) { |m| interpolation[m[0]] ||= ''}
|
29
29
|
# remove all missing keys
|
30
|
-
subject = title % interpolation.delete_if { |k, v| title !~ /%{#{k}}/ }
|
30
|
+
subject = title % interpolation.symbolize_keys.delete_if { |k, v| title !~ /%{#{k}}/ }
|
31
31
|
|
32
32
|
return subject if subject.present?
|
33
33
|
end
|
34
|
+
'(no subject)'
|
34
35
|
end
|
35
36
|
|
36
37
|
# Will return snippet content, passing through Kramdown
|
@@ -44,7 +45,7 @@ module RailsEmailPreview
|
|
44
45
|
default_site = Cms::Site.find_by_locale(I18n.default_locale)
|
45
46
|
fallback_content = cms_snippet_content(snippet_id, default_site).presence
|
46
47
|
end
|
47
|
-
result = content || fallback_content
|
48
|
+
result = (content || fallback_content).to_s
|
48
49
|
|
49
50
|
# If rendering in preview from admin, add edit/create lnk
|
50
51
|
if caller.grep(/emails_controller/).present?
|
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.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Mazovetskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|