email_preview 1.0.0 → 1.0.1

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.
data/CONTRIBUTORS.txt ADDED
@@ -0,0 +1,4 @@
1
+ Ryan Sonnek - Original Author
2
+
3
+ Complete list of contributors:
4
+ https://github.com/wireframe/email_preview/contributors
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Ryan Sonnek
1
+ Copyright (c) 2011 Ryan Sonnek
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # email_preview
2
+
3
+ preview emails within your web browser
4
+
5
+ ## Features
6
+ * preview HTML emails from within your web browser
7
+ * emails are reloaded with each view so you can tweak/save/refresh for instant verification
8
+ * convenient form to send any email preview directly to your *real* inbox
9
+ * only exposes routes in development mode to prevent leaking into production mode
10
+
11
+ ## Installation
12
+
13
+ gem 'email_preview'
14
+
15
+ ## Usage
16
+
17
+
18
+ ```ruby
19
+ # config/initializers/email_preview.rb
20
+ EmailPreview.register 'simple example email' do
21
+ Mail.new do
22
+ to 'tom@example.com'
23
+ from 'me@foo.com'
24
+ body 'check this out'
25
+ end
26
+ end
27
+
28
+ EmailPreview.register 'multipart email (html + text)' do
29
+ Mail.new do
30
+ from 'mikel@test.lindsaar.net'
31
+ to 'you@test.lindsaar.net'
32
+ subject 'This is a test email'
33
+
34
+ text_part do
35
+ body 'This is plain text'
36
+ end
37
+ html_part do
38
+ content_type 'text/html; charset=UTF-8'
39
+ body '<h1>This is HTML</h1>'
40
+ end
41
+ end
42
+ end
43
+
44
+ EmailPreview.register 'Rails ActionMailer User activation email' do
45
+ u = User.new :email => 'foo@example.com'
46
+ UserMailer.activation(u)
47
+ end
48
+ ```
49
+
50
+ browse the list of registered emails and preview them in your browser at:
51
+ http://localhost:3000/email_preview
52
+
53
+ by default the email_preview feature is only available in development mode. to turn on globally use:
54
+
55
+ ```ruby
56
+ # config/initializers/email_preview.rb
57
+ EmailPreview.allowed_environments << 'production'
58
+ ```
59
+
60
+ ## Contributing
61
+
62
+ * Fork the project
63
+ * Fix the issue
64
+ * Add unit tests
65
+ * Submit pull request on github
66
+
67
+ See CONTRIBUTORS.txt for list of project contributors
68
+
69
+ ## Copyright
70
+
71
+ Copyright (c) 2010 Ryan Sonnek. See LICENSE for details.
@@ -11,9 +11,9 @@ class EmailPreviewController < ApplicationController
11
11
  end
12
12
  def preview
13
13
  @part = if request.format == 'html'
14
- @parts.detect {|p| p.content_type.include?('text/html') }
14
+ @parts.detect {|p| p.content_type && p.content_type.include?('text/html') }
15
15
  else
16
- @parts.detect {|p| p.content_type.include?('text/plain') }
16
+ @parts.detect {|p| p.content_type && p.content_type.include?('text/plain') }
17
17
  end
18
18
  @part ||= @parts.first
19
19
  render :text => @part.body.to_s
@@ -26,7 +26,7 @@
26
26
  }
27
27
  .deliver_form input {
28
28
  width: 250px;
29
- }
29
+ }
30
30
  </style>
31
31
  <%= form_tag deliver_email_preview_path(params[:id]), :class => 'deliver_form' do %>
32
32
  <%= text_field_tag :to, '', :placeholder => 'Send this email to me@yourcompany.com' %>
@@ -43,7 +43,11 @@
43
43
  </div>
44
44
 
45
45
  <h2>Content</h2>
46
+ <ul>
46
47
  <% @parts.each do |part| %>
47
- <% render_format = part.content_type.include?('text/html') ? 'html' : 'txt' %>
48
- <%= link_to "View #{render_format} output", preview_email_preview_path(params[:id], :format => render_format), :target => 'preview' %>
48
+ <% render_format = (part.content_type && part.content_type.include?('text/html')) ? 'html' : 'txt' %>
49
+ <li>
50
+ <%= link_to "View #{render_format} output", preview_email_preview_path(params[:id], :format => render_format), :target => 'preview' %>
51
+ </li>
49
52
  <% end %>
53
+ </ul>
@@ -1,3 +1,3 @@
1
1
  module EmailPreview
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: email_preview
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ryan Sonnek
@@ -59,9 +59,10 @@ extra_rdoc_files: []
59
59
  files:
60
60
  - .document
61
61
  - .gitignore
62
+ - CONTRIBUTORS.txt
62
63
  - Gemfile
63
64
  - LICENSE
64
- - README.rdoc
65
+ - README.md
65
66
  - Rakefile
66
67
  - app/controllers/email_preview_controller.rb
67
68
  - app/views/email_preview/details.html.erb
data/README.rdoc DELETED
@@ -1,65 +0,0 @@
1
- = email_preview
2
-
3
- preview emails within your web browser
4
-
5
- = Features
6
- * preview HTML emails from within your web browser
7
- * emails are reloaded with each view so you can tweak/save/refresh for instant verification
8
- * convenient form to send any email preview directly to your *real* inbox
9
- * only exposes routes in development mode to prevent leaking into production mode
10
-
11
- = Installation
12
-
13
- gem 'email_preview'
14
-
15
- = Usage
16
-
17
- config/initializers/email_preview.rb
18
- EmailPreview.register 'simple example email' do
19
- Mail.new do
20
- to 'tom@example.com'
21
- from 'me@foo.com'
22
- body 'check this out'
23
- end
24
- end
25
-
26
- EmailPreview.register 'multipart email (html + text)' do
27
- Mail.new do
28
- from 'mikel@test.lindsaar.net'
29
- to 'you@test.lindsaar.net'
30
- subject 'This is a test email'
31
-
32
- text_part do
33
- body 'This is plain text'
34
- end
35
- html_part do
36
- content_type 'text/html; charset=UTF-8'
37
- body '<h1>This is HTML</h1>'
38
- end
39
- end
40
- end
41
-
42
- EmailPreview.register 'user activation email' do
43
- u = User.new :email => 'foo@example.com'
44
- UserNotifier.activation
45
- end
46
-
47
- by default, email_preview is only available in development mode. to turn on globally use:
48
- EmailPreview.allowed_environments << 'production'
49
-
50
- browse the list of registered emails and preview them in your browser at:
51
- http://localhost:3000/email_preview
52
-
53
- == Note on Patches/Pull Requests
54
-
55
- * Fork the project.
56
- * Make your feature addition or bug fix.
57
- * Add tests for it. This is important so I don't break it in a
58
- future version unintentionally.
59
- * Commit, do not mess with rakefile, version, or history.
60
- (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
61
- * Send me a pull request. Bonus points for topic branches.
62
-
63
- == Copyright
64
-
65
- Copyright (c) 2010 Ryan Sonnek. See LICENSE for details.