rails_email_preview 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17b4cb04e7e6af808f41a92896bb71fc50c16472
4
- data.tar.gz: 01314701475fdd3624e327fa81d0880226e2a3e1
3
+ metadata.gz: 210079aee23a1a64d8d99202882da2d987f0871c
4
+ data.tar.gz: dd6ef6cff8f2b403fb85988d47480dd19272caea
5
5
  SHA512:
6
- metadata.gz: 9984703040eece53801c17d586053e4f339a272eda8996b75b0e911ddc815346eacb54a61b9eb884a7f05dec4ed1fd392638852a44d33884a4ebfe3c43ff75ed
7
- data.tar.gz: f72c6a4ce355869bf84715392096184658eaf3d00c52e7d0bcbef9a67d1f6282bc9fce6dd1b714783e4d67a410cd29767d3051185fd46cdb1c6c8d5521bdac60
6
+ metadata.gz: 8b7ee3fd00a5d0e9d8e5e278c6b99420bb8392ed3e1f2dccf81f462cc54715a7c022a00498b845fe76b7ceb366ce4f9409a5b40dcef5a15da6e0b2461d00d045
7
+ data.tar.gz: a65c22c4684cf836bdc9c4f2dbaea3570373f6d26dfbe8d11cc2faec485849666d78edefc2f71acc4d420b3a6122885986b145282c27c164197b1ad70a2c4c49
data/README.md CHANGED
@@ -3,6 +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
+ ![screenshot](http://screencloud.net//img/screenshots/749d6c6a84b5d79b436ad627902944a8.png)
7
+ *Preview UI*
8
+
6
9
  How to
7
10
  -----
8
11
 
@@ -76,6 +79,23 @@ For [premailer-rails](https://github.com/fphilipe/premailer-rails), add to `Rail
76
79
 
77
80
  config.before_render { |message| Premailer::Rails::Hook.delivering_email(message) }
78
81
 
82
+ Email editing
83
+ -------------
84
+
85
+ You can use [comfortable_mexican_sofa](https://github.com/comfy/comfortable-mexican-sofa) for storing and editing emails.
86
+ [See ComfortableMexicanSofa integration guide](https://github.com/glebm/rails_email_preview/wiki/Comfortable-Mexican-Sofa-integration-for-email-editing).
87
+
88
+ This is what it looks like:
89
+
90
+ ![CMS integration screenshot](http://screencloud.net//img/screenshots/c3437edd8cdd52dbff58663a0b30d6ca.png)
91
+
92
+ I18n
93
+ -------------
94
+
95
+ Rails Email Preview sets `I18n.locale` for rendering an email.
96
+ This means your emails should use I18n.locale but not set it.
97
+ If you are using `Resque::Mailer` or `Devise::Async`, you will want to [inject I18n.locale into the job](https://gist.github.com/glebm/5725347).
98
+
79
99
 
80
100
  Customizing views
81
101
  ---------------------
@@ -1,6 +1,7 @@
1
1
  class RailsEmailPreview::EmailsController < RailsEmailPreview::ApplicationController
2
2
  include ERB::Util
3
- before_filter :load_preview_class, :except => :index
3
+ before_filter :load_preview_class, except: :index
4
+ before_filter :set_locale, except: :index
4
5
 
5
6
  def index
6
7
  @preview_class_names = (RailsEmailPreview.preview_classes || []).map { |klass| klass.is_a?(String) ? klass : klass.name }
@@ -31,6 +32,11 @@ class RailsEmailPreview::EmailsController < RailsEmailPreview::ApplicationContro
31
32
  end
32
33
 
33
34
  private
35
+
36
+ def set_locale
37
+ I18n.locale = params[:email_locale] || params[:locale] || I18n.default_locale
38
+ end
39
+
34
40
  def load_preview_class
35
41
  @preview_class = (RailsEmailPreview.preview_classes || []).find { |pc|
36
42
  (pc.is_a?(String) ? pc : pc.name).underscore == params[:mail_class]
@@ -38,4 +44,4 @@ class RailsEmailPreview::EmailsController < RailsEmailPreview::ApplicationContro
38
44
  @preview_class = @preview_class.constantize if @preview_class.is_a?(String)
39
45
  @part_type = params[:part_type] || 'text/html'
40
46
  end
41
- end
47
+ end
@@ -0,0 +1,9 @@
1
+ doctype html
2
+ = "\n"
3
+ html
4
+ head
5
+ title Email Preview
6
+ = stylesheet_link_tag 'rails_email_preview/application'
7
+ = yield(:head)
8
+ body
9
+ #content = yield
@@ -0,0 +1,10 @@
1
+ h1 Application emails
2
+ ul.list-unstyled
3
+ - @preview_class_names.each do |m|
4
+ li.col-lg-6.col-sm-6
5
+ h2= m.underscore.sub(/(_mailer)?_preview$/, '').humanize
6
+ ul.list-group
7
+ - m.constantize.instance_methods(false).map(&:to_s).each do |method|
8
+ li.list-group-item
9
+ a href=rails_email_preview.email_url(mail_class: m.to_s.underscore, mail_action: method.to_s)
10
+ = method.to_s.humanize
@@ -0,0 +1,44 @@
1
+ a.btn.btn-link href=rails_email_preview.root_url &laquo; Back to list
2
+
3
+ #message_headers
4
+ .pull-right
5
+ p.btn-group
6
+ - { 'text/html' => 'HTML', 'text/plain' => 'Text', 'raw' => 'Raw'}.each do |mime, label|
7
+ a.btn.btn-link href=rails_email_preview.email_url(params.merge(part_type: mime)) class=('active' if @part_type == mime) = label
8
+ br
9
+ p.btn-group
10
+ - I18n.available_locales.each do |locale|
11
+ a.btn.btn-link href=rails_email_preview.email_url(params.merge(part_type: @part_type, email_locale: locale)) class=('active' if I18n.locale.to_s == locale.to_s) = locale
12
+ dl
13
+ dt From:
14
+ dd= @mail.from * ', '
15
+
16
+ dt To:
17
+ dd= @mail.to * ', '
18
+
19
+ dt Subject:
20
+ dd
21
+ strong= @mail.subject
22
+
23
+ javascript:
24
+ function iFrameAutoResize(id){
25
+ document.getElementById('loading-el').style.display = 'none';
26
+ setTimeout(function(){
27
+ var newheight;
28
+ var newwidth;
29
+
30
+ if(document.getElementById){
31
+ newheight = document.getElementById(id).contentWindow.document.body.scrollHeight;
32
+
33
+ newwidth = $(document.getElementById(id).parentNode).innerWidth();
34
+ }
35
+
36
+ var el = document.getElementById(id);
37
+ el.height = (newheight) + "px";
38
+ el.width = (newwidth) + "px";
39
+ });
40
+ }
41
+
42
+ pre#loading-el.lead #{icon 'spinner', 'spin'} Loading...
43
+ iframe#src-iframe[src=rails_email_preview.raw_email_url(params.slice(:mail_class, :mail_action, :part_type).merge(locale: I18n.locale.to_s))
44
+ width="100%" height=1 onLoad="iFrameAutoResize('src-iframe')" style="border:none;padding:0;margin:0"]
@@ -1,3 +1,3 @@
1
1
  module RailsEmailPreview
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  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.0.6
4
+ version: 0.0.7
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-05 00:00:00.000000000 Z
11
+ date: 2013-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: haml
42
+ name: slim
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '>='
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
- description: Insert RailsEmailPreview description.
69
+ description: Preview emails in browser (rails engine)
70
70
  email: glex.spb@gmail.com
71
71
  executables: []
72
72
  extensions: []
@@ -75,9 +75,9 @@ files:
75
75
  - app/assets/stylesheets/rails_email_preview/application.css.sass
76
76
  - app/controllers/rails_email_preview/application_controller.rb
77
77
  - app/controllers/rails_email_preview/emails_controller.rb
78
- - app/views/layouts/rails_email_preview/application.html.haml
79
- - app/views/rails_email_preview/emails/index.html.haml
80
- - app/views/rails_email_preview/emails/show.html.haml
78
+ - app/views/layouts/rails_email_preview/application.html.slim
79
+ - app/views/rails_email_preview/emails/index.html.slim
80
+ - app/views/rails_email_preview/emails/show.html.slim
81
81
  - lib/rails_email_preview/engine.rb
82
82
  - lib/rails_email_preview/version.rb
83
83
  - lib/rails_email_preview.rb
@@ -108,5 +108,5 @@ rubyforge_project:
108
108
  rubygems_version: 2.0.3
109
109
  signing_key:
110
110
  specification_version: 4
111
- summary: Visual Email Preview for Rails >= 3, implemented as a Rails Engine. v0.0.6
111
+ summary: Preview emails in browser (rails engine)
112
112
  test_files: []
@@ -1,9 +0,0 @@
1
- !!! HTML
2
- %html
3
- %head
4
- %title Email Preview
5
- = stylesheet_link_tag 'rails_email_preview/application'
6
- = yield(:head)
7
- %body
8
- #content
9
- = yield
@@ -1,9 +0,0 @@
1
- %h1 Application Emails
2
- %ul
3
- - @preview_class_names.each do |m|
4
- %li
5
- %h2= m.underscore.humanize
6
- %ul
7
- - m.constantize.instance_methods(false).map(&:to_s).each do |method|
8
- %li
9
- %a{:href => rails_email_preview.email_url(:mail_class => m.underscore, :mail_action => method)}= method.humanize
@@ -1,38 +0,0 @@
1
- %a#back-to-all{:href => rails_email_preview.root_url} &laquo; Back to list
2
- :ruby
3
- raw_url = rails_email_preview.email_url(params.merge(:part_type => 'raw'))
4
- html_url = if @mail.multipart? || @mail.content_type =~ %r(text/html)
5
- rails_email_preview.email_url(params.merge(:part_type => 'text/html'))
6
- end
7
- plain_url = if @mail.multipart? || @mail.content_type =~ %r(text/plain) || defined?(Premailer::Rails)
8
- rails_email_preview.email_url(params.merge(:part_type => 'text/plain'))
9
- end
10
-
11
- #message_headers
12
- %p.alternate
13
- - if @part_type != 'raw'
14
- %a{:href => raw_url} View Original Message (raw)
15
- %br
16
- - if @part_type != 'text/html' && html_url
17
- %a{:href => html_url} View HTML version
18
- %br
19
- - if @part_type != 'text/plain' && plain_url
20
- %a{:href => plain_url} View plain text version
21
- %dl
22
- %dt From:
23
- %dd= @mail.from
24
-
25
- %dt Subject:
26
- %dd
27
- %strong= @mail.subject
28
-
29
- %dt Date:
30
- %dd= Time.now.strftime("%b %e, %Y %I:%M:%S %p %Z")
31
-
32
- %dt To:
33
- %dd= @mail.to
34
-
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 => "document.getElementById('src-iframe').style.display = 'block';document.getElementById('loading').style.display = 'none'", :style => "display:none"}
37
- %pre#loading Loading...
38
-