rails_email_preview 0.0.4 → 0.0.5
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/README.md +49 -58
- data/app/views/rails_email_preview/emails/show.html.haml +2 -7
- data/config/routes.rb +3 -3
- data/lib/rails_email_preview/version.rb +1 -1
- metadata +38 -28
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 84132ea530a47db404000e82a07251cd51706955
|
4
|
+
data.tar.gz: d0aef7d543f2138ddcf82f7a86e4cf538eb4f5b5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ba0961461268dd1f986431b84799d185cfb4431c5d10e7881e2c682d4c5dd7447237ad2d090f3dd30289f1cb3b4d5b2da78839bdc677738368c8281011a04fe5
|
7
|
+
data.tar.gz: 014c0c7c244ff70acf5de3059ddcf39963948297409221cd12fed4ed258db7bef604f94f819223d1d42884580abd7f876945e0ff0c9953669e06ef5322705d04
|
data/README.md
CHANGED
@@ -1,19 +1,15 @@
|
|
1
|
-
|
1
|
+
Rails Email Preview
|
2
2
|
================================
|
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
|
-
However, implemented as a Rails engine, with layouts and multiple mailers support.
|
8
|
-
|
9
|
-
Compatible with Rails version >= 3 only.
|
10
|
-
|
11
|
-
Usage
|
6
|
+
How to
|
12
7
|
-----
|
13
8
|
|
14
|
-
|
9
|
+
You will need to provide data for preview of each email:
|
15
10
|
|
16
|
-
|
11
|
+
# Say you have this mailer
|
12
|
+
class UserMailer < ActionMailer::Base
|
17
13
|
def invitation(inviter, invitee)
|
18
14
|
# ...
|
19
15
|
end
|
@@ -21,75 +17,70 @@ Since most emails do something interesting with database data, you'll need to wr
|
|
21
17
|
def welcome(user)
|
22
18
|
# ...
|
23
19
|
end
|
20
|
+
end
|
24
21
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
22
|
+
# Define a Preview class with the same mail action names, but with no arguments
|
23
|
+
# mkdir -p app/mailer_previews/; touch app/mailer_previews/user_mailer_preview.rb
|
24
|
+
class UserMailerPreview
|
25
|
+
# preview methods should return Mail objects, e.g.:
|
26
|
+
def invitation
|
27
|
+
UserMailer.invitation mock_user('Alice'), mock_user('Bob')
|
28
|
+
end
|
29
|
+
|
30
|
+
def welcome
|
31
|
+
UserMailer.welcome mock_user
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def mock_user(name = 'Bill Gates')
|
36
|
+
User.new(name: name, email: "user@test.com#{rand 100}").tap { |u| u.define_singleton_method(:id) { 123 + rand(100) } }
|
40
37
|
end
|
41
38
|
end
|
42
39
|
|
43
|
-
The methods must return a Mail object.
|
44
40
|
|
45
|
-
|
41
|
+
Routing
|
42
|
+
-------
|
43
|
+
|
44
|
+
mount RailsEmailPreview::Engine, at: 'email_preview' # rails_email_preview.root_url #=> '/email_preview'
|
45
|
+
|
46
46
|
|
47
|
-
|
47
|
+
Configuration
|
48
|
+
-------
|
49
|
+
|
50
|
+
# touch config/initializers/rails_email_preview.rb
|
48
51
|
|
49
52
|
require 'rails_email_preview'
|
50
53
|
RailsEmailPreview.setup do |config|
|
51
|
-
config.preview_classes = [
|
54
|
+
config.preview_classes = [ UserMailerPreview ]
|
52
55
|
end
|
53
56
|
|
54
|
-
#
|
55
|
-
# Rails.application.config.to_prepare do
|
56
|
-
# RailsEmailPreview::ApplicationController.layout "application"
|
57
|
-
# end
|
58
|
-
# Note that if you do use it with your main_app layout, all the main_app URLs must be generated explicitly
|
59
|
-
# E.g. you would need to change links like login_url to main_app.login_url
|
60
|
-
|
61
|
-
|
62
|
-
Routing is very simple
|
57
|
+
# To render previews within layout other than the default one. NB: that layout must reference application urls via `main_app`, e.g. `main_app.login_url` (due to how isolated engines are in rails):
|
63
58
|
|
64
|
-
|
65
|
-
|
66
|
-
if Rails.env.development?
|
67
|
-
mount RailsEmailPreview::Engine, :at => 'email_preview' # You can choose any URL here
|
59
|
+
Rails.application.config.to_prepare do
|
60
|
+
RailsEmailPreview::ApplicationController.layout 'admin'
|
68
61
|
end
|
69
62
|
|
70
|
-
To get the url of RailsEmailPreview in your main app you can call rails_email_preview.root_url
|
71
|
-
|
72
63
|
|
73
64
|
Premailer integration
|
74
65
|
---------------------
|
75
66
|
|
76
|
-
[Premailer](https://github.com/alexdunae/premailer)
|
67
|
+
[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.
|
77
68
|
|
78
|
-
|
79
|
-
can be done like so:
|
69
|
+
To integrate Premailer with rails you can use either [actionmailer_inline_css](https://github.com/ndbroadbent/actionmailer_inline_css) or [premailer-rails](https://github.com/fphilipe/premailer-rails).
|
80
70
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
71
|
+
For [actionmailer_inline_css](https://github.com/ndbroadbent/actionmailer_inline_css), add to `RailsEmailPreview.setup`:
|
72
|
+
|
73
|
+
config.before_render { |message| ActionMailer::InlineCssHook.delivering_email(message) }
|
74
|
+
|
75
|
+
For [premailer-rails](https://github.com/fphilipe/premailer-rails), add to `RailsEmailPreview.setup`:
|
76
|
+
|
77
|
+
config.before_render { |message| Premailer::Rails::Hook.delivering_email(message) }
|
86
78
|
|
87
|
-
Interface
|
88
|
-
---------
|
89
79
|
|
90
|
-
|
91
|
-
|
80
|
+
Customizing views
|
81
|
+
---------------------
|
92
82
|
|
93
|
-
|
83
|
+
You can ovveride any `rails_email_preview` view by placing a file with the same path as in the gem in your project's `app/views`.
|
84
|
+
You can also extend the `RailsEmailPreview::EmailsController` for further customization.
|
94
85
|
|
95
|
-
This project rocks and uses MIT-LICENSE.
|
86
|
+
This project rocks and uses MIT-LICENSE.
|
@@ -4,7 +4,7 @@
|
|
4
4
|
html_url = if @mail.multipart? || @mail.content_type =~ %r(text/html)
|
5
5
|
rails_email_preview.email_url(params.merge(:part_type => 'text/html'))
|
6
6
|
end
|
7
|
-
plain_url = if @mail.multipart? || @mail.content_type =~ %r(text/plain)
|
7
|
+
plain_url = if @mail.multipart? || @mail.content_type =~ %r(text/plain) || Object.const_defined?('PremailerRails')
|
8
8
|
rails_email_preview.email_url(params.merge(:part_type => 'text/plain'))
|
9
9
|
end
|
10
10
|
|
@@ -33,11 +33,6 @@
|
|
33
33
|
%dd= @mail.to
|
34
34
|
|
35
35
|
%iframe#src-iframe{:src => rails_email_preview.raw_email_url(params.slice(:mail_class, :mail_action, :part_type)),
|
36
|
-
:width => "100%", :height => "800", :onload => '
|
36
|
+
:width => "100%", :height => "800", :onload => "document.getElementById('src-iframe').style.display = 'block';document.getElementById('loading').style.display = 'none'", :style => "display:none"}
|
37
37
|
%pre#loading Loading...
|
38
38
|
|
39
|
-
:javascript
|
40
|
-
window.emailLoaded = function () {
|
41
|
-
document.getElementById('src-iframe').style.display = 'block';
|
42
|
-
document.getElementById('loading').style.display = 'none';
|
43
|
-
};
|
data/config/routes.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
RailsEmailPreview::Engine.routes.draw do
|
2
2
|
root :to => 'emails#index'
|
3
|
-
|
3
|
+
get 'raw/:mail_class/:mail_action',
|
4
4
|
:as => :raw_email,
|
5
5
|
:to => 'emails#show_raw',
|
6
6
|
:mail_class => %r([\w/]+)
|
7
|
-
|
7
|
+
get ':mail_class/:mail_action',
|
8
8
|
:as => :email,
|
9
9
|
:to => 'emails#show',
|
10
10
|
:mail_class => %r([\w/]+)
|
11
|
-
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,72 +1,83 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_email_preview
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.5
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Gleb Mazovetskiy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-06-05 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.2'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.2'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rails
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '3.2'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.2'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: haml
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - '>='
|
42
46
|
- !ruby/object:Gem::Version
|
43
47
|
version: '0'
|
44
48
|
type: :runtime
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: sass
|
49
|
-
requirement:
|
50
|
-
none: false
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
type: :runtime
|
56
63
|
prerelease: false
|
57
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
58
69
|
description: Insert RailsEmailPreview description.
|
59
70
|
email: glex.spb@gmail.com
|
60
71
|
executables: []
|
61
72
|
extensions: []
|
62
73
|
extra_rdoc_files: []
|
63
74
|
files:
|
75
|
+
- app/assets/stylesheets/rails_email_preview/application.css.sass
|
64
76
|
- app/controllers/rails_email_preview/application_controller.rb
|
65
77
|
- app/controllers/rails_email_preview/emails_controller.rb
|
66
|
-
- app/
|
78
|
+
- app/views/layouts/rails_email_preview/application.html.haml
|
67
79
|
- app/views/rails_email_preview/emails/index.html.haml
|
68
80
|
- app/views/rails_email_preview/emails/show.html.haml
|
69
|
-
- app/views/layouts/rails_email_preview/application.html.haml
|
70
81
|
- lib/rails_email_preview/engine.rb
|
71
82
|
- lib/rails_email_preview/version.rb
|
72
83
|
- lib/rails_email_preview.rb
|
@@ -77,26 +88,25 @@ files:
|
|
77
88
|
- README.md
|
78
89
|
homepage:
|
79
90
|
licenses: []
|
91
|
+
metadata: {}
|
80
92
|
post_install_message:
|
81
93
|
rdoc_options: []
|
82
94
|
require_paths:
|
83
95
|
- lib
|
84
96
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
97
|
requirements:
|
87
|
-
- -
|
98
|
+
- - '>='
|
88
99
|
- !ruby/object:Gem::Version
|
89
100
|
version: '0'
|
90
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
102
|
requirements:
|
93
|
-
- -
|
103
|
+
- - '>='
|
94
104
|
- !ruby/object:Gem::Version
|
95
105
|
version: '0'
|
96
106
|
requirements: []
|
97
107
|
rubyforge_project:
|
98
|
-
rubygems_version:
|
108
|
+
rubygems_version: 2.0.3
|
99
109
|
signing_key:
|
100
|
-
specification_version:
|
101
|
-
summary: Visual Email Preview for Rails >= 3, implemented as a Rails Engine. v0.0.
|
110
|
+
specification_version: 4
|
111
|
+
summary: Visual Email Preview for Rails >= 3, implemented as a Rails Engine. v0.0.5
|
102
112
|
test_files: []
|