mail_view 1.0.2 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +75 -0
- data/init.rb +1 -0
- data/lib/mail_view/email.html.erb +11 -14
- data/lib/mail_view.rb +4 -4
- data/mail_view.gemspec +12 -0
- metadata +19 -4
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 37signals, LLC
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
MailView -- Visual email testing
|
2
|
+
================================
|
3
|
+
|
4
|
+
Preview plain text and html mail templates in your browser without redelivering it every time you make a change.
|
5
|
+
|
6
|
+
Install
|
7
|
+
-------
|
8
|
+
|
9
|
+
Add the gem to your `Gemfile`:
|
10
|
+
|
11
|
+
gem 'mail_view', :git => 'https://github.com/37signals/mail_view.git'
|
12
|
+
|
13
|
+
And run `bundle install`.
|
14
|
+
|
15
|
+
Usage
|
16
|
+
-----
|
17
|
+
|
18
|
+
Since most emails do something interesting with database data, you'll need to write some scenarios to load messages with fake data. Its similar to writing mailer unit tests but you see a visual representation of the output instead.
|
19
|
+
|
20
|
+
class Notifier < ActionMailer::Base
|
21
|
+
def invitation(inviter, invitee)
|
22
|
+
# ...
|
23
|
+
end
|
24
|
+
|
25
|
+
def welcome(user)
|
26
|
+
# ...
|
27
|
+
end
|
28
|
+
|
29
|
+
class Preview < MailView
|
30
|
+
# Pull data from existing fixtures
|
31
|
+
def invitation
|
32
|
+
account = Account.first
|
33
|
+
inviter, invitee = account.users[0, 2]
|
34
|
+
Notifier.invitation(inviter, invitee)
|
35
|
+
# ::Notifier.invitation(inviter, invitee) # May need to call with '::'
|
36
|
+
end
|
37
|
+
|
38
|
+
# Factory-like pattern
|
39
|
+
def welcome
|
40
|
+
user = User.create!
|
41
|
+
mail = Notifier.welcome(user)
|
42
|
+
user.destroy
|
43
|
+
mail
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Methods must return a [Mail][1] or [TMail][2] object. Using ActionMailer, call `Notifier.create_action_name(args)` to return a compatible TMail object. Now on ActionMailer 3.x, `Notifier.action_name(args)` will return a Mail object.
|
49
|
+
|
50
|
+
Routing
|
51
|
+
-------
|
52
|
+
|
53
|
+
A mini router middleware is bundled for Rails 2.x support.
|
54
|
+
|
55
|
+
# config/environments/development.rb
|
56
|
+
config.middleware.use MailView::Mapper, [Notifier::Preview]
|
57
|
+
|
58
|
+
For Rails³ you can map the app inline in your routes config.
|
59
|
+
|
60
|
+
# config/routes.rb
|
61
|
+
if Rails.env.development?
|
62
|
+
mount Notifier::Preview => 'mail_view'
|
63
|
+
end
|
64
|
+
|
65
|
+
Now just load up `http://localhost:3000/mail_view`.
|
66
|
+
|
67
|
+
Interface
|
68
|
+
---------
|
69
|
+
|
70
|
+
![Plain text view](http://img18.imageshack.us/img18/1066/plaintext.png)
|
71
|
+
![HTML view](http://img269.imageshack.us/img269/2944/htmlz.png)
|
72
|
+
|
73
|
+
|
74
|
+
[1]: http://github.com/mikel/mail
|
75
|
+
[2]: http://github.com/mikel/tmail
|
data/init.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'mail_view'
|
@@ -3,11 +3,7 @@
|
|
3
3
|
</head>
|
4
4
|
<style type="text/css">
|
5
5
|
#message_headers {
|
6
|
-
position: absolute;
|
7
|
-
top: 0px;
|
8
|
-
left: 0;
|
9
6
|
width: 100%;
|
10
|
-
height: 85px;
|
11
7
|
padding: 10px 0 0 0;
|
12
8
|
margin: 0;
|
13
9
|
background: #fff;
|
@@ -18,12 +14,13 @@
|
|
18
14
|
}
|
19
15
|
|
20
16
|
#message_headers dl {
|
21
|
-
|
17
|
+
float: left;
|
18
|
+
margin: 0 0 10px 0;
|
22
19
|
padding: 0;
|
23
20
|
}
|
24
21
|
|
25
22
|
#message_headers dt {
|
26
|
-
width:
|
23
|
+
width: 62px;
|
27
24
|
padding: 1px;
|
28
25
|
float: left;
|
29
26
|
text-align: right;
|
@@ -32,14 +29,13 @@
|
|
32
29
|
}
|
33
30
|
|
34
31
|
#message_headers dd {
|
35
|
-
margin-left:
|
32
|
+
margin-left: 72px;
|
36
33
|
padding: 1px;
|
37
34
|
}
|
38
35
|
|
39
36
|
#message_headers p.alternate {
|
40
|
-
|
41
|
-
|
42
|
-
right: 15px;
|
37
|
+
float: right;
|
38
|
+
margin: 0;
|
43
39
|
}
|
44
40
|
|
45
41
|
#message_headers p.alternate a {
|
@@ -50,16 +46,17 @@
|
|
50
46
|
padding: 10px;
|
51
47
|
white-space: pre-wrap;
|
52
48
|
}
|
53
|
-
|
54
|
-
body {
|
55
|
-
margin-top: 96px;
|
56
|
-
}
|
57
49
|
</style>
|
58
50
|
<div id="message_headers">
|
59
51
|
<dl>
|
60
52
|
<dt>From:</dt>
|
61
53
|
<dd><%= mail.from %></dd>
|
62
54
|
|
55
|
+
<% if mail.reply_to %>
|
56
|
+
<dt>Reply-To:</dt>
|
57
|
+
<dd><%= mail.reply_to %></dd>
|
58
|
+
<% end %>
|
59
|
+
|
63
60
|
<dt>Subject:</dt>
|
64
61
|
<dd><strong><%= mail.subject %></strong></dd>
|
65
62
|
|
data/lib/mail_view.rb
CHANGED
@@ -21,13 +21,13 @@ class MailView
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def call(env)
|
24
|
+
@rack_env = env
|
24
25
|
path_info = env["PATH_INFO"]
|
25
26
|
|
26
27
|
if path_info == "" || path_info == "/"
|
27
|
-
links = self.actions.
|
28
|
-
|
29
|
-
|
30
|
-
}
|
28
|
+
links = self.actions.map do |action|
|
29
|
+
[action, "#{env["SCRIPT_NAME"]}/#{action}"]
|
30
|
+
end
|
31
31
|
|
32
32
|
ok index_template.render(Object.new, :links => links)
|
33
33
|
elsif path_info =~ /([\w_]+)(\.\w+)?$/
|
data/mail_view.gemspec
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'mail_view'
|
3
|
+
s.version = '1.0.3'
|
4
|
+
s.author = 'Josh Peek'
|
5
|
+
s.email = 'josh@joshpeek.com'
|
6
|
+
s.summary = 'Visual email testing'
|
7
|
+
s.homepage = 'https://github.com/37signals/mail_view'
|
8
|
+
|
9
|
+
s.add_dependency 'tilt'
|
10
|
+
|
11
|
+
s.files = Dir["#{File.dirname(__FILE__)}/**/*"]
|
12
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail_view
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,18 +9,33 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
12
|
+
date: 2012-06-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: tilt
|
16
|
+
requirement: &70230748169120 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70230748169120
|
14
25
|
description:
|
15
26
|
email: josh@joshpeek.com
|
16
27
|
executables: []
|
17
28
|
extensions: []
|
18
29
|
extra_rdoc_files: []
|
19
30
|
files:
|
20
|
-
- ./
|
31
|
+
- ./init.rb
|
21
32
|
- ./lib/mail_view/email.html.erb
|
22
33
|
- ./lib/mail_view/index.html.erb
|
23
34
|
- ./lib/mail_view/mapper.rb
|
35
|
+
- ./lib/mail_view.rb
|
36
|
+
- ./LICENSE
|
37
|
+
- ./mail_view.gemspec
|
38
|
+
- ./README.md
|
24
39
|
- ./test/test_mail_view.rb
|
25
40
|
homepage: https://github.com/37signals/mail_view
|
26
41
|
licenses: []
|