rails_email_preview 0.0.8 → 0.0.9

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: 264f8217c8a8d10e2f72d6f32e6cfee539e1a572
4
- data.tar.gz: bb09d40b77cfe02fe218606c284431e41062f500
3
+ metadata.gz: 8bee2bfee317025f4b297f8982ae6322714d6854
4
+ data.tar.gz: dd9b7bc1aa56a14dce7a96a55ee348b92e4ad3d8
5
5
  SHA512:
6
- metadata.gz: 48c8116fa52466924fd4300a871763464bd3ba4358eb43d7703a8028fc1fc4f4e5ede21709c87dced53de8c4d6c9d7c9c102bf4d1f524d4021019689133a1b1d
7
- data.tar.gz: 5ef7135d0005aa9010b889c6b1cae3fcb34630ad75ca2f2b35f871e48c2d8bb9e1dbdd83cd25c14f289a308ade1288447755ad2a192272b53da2fb15a0969756
6
+ metadata.gz: 35e24aa93dbb5ea4884b55a2764234b7e155074f3016f3fb4563c3c479dea01a6b0b197362b2ff39c5a294922203e093d48050e9e40008212a21f4a5d641a359
7
+ data.tar.gz: 7206cf3f0c4fe7a629a88cb66a1709704b5f03d184f23bddf4bbc274cb3e15cf009fb39d4343489e7b906e912bb9ad79b2b0790feda7e4af6209a1be280e0060
@@ -1,20 +1,20 @@
1
1
  class RailsEmailPreview::EmailsController < RailsEmailPreview::ApplicationController
2
2
  include ERB::Util
3
- around_filter :set_locale_for_mail, only: :show_raw
4
3
  before_filter :load_preview_class, except: :index
4
+ around_filter :with_email_locale, only: [:show, :show_raw]
5
5
 
6
+ # list screen
6
7
  def index
7
8
  @preview_class_names = (RailsEmailPreview.preview_classes || []).map { |klass| klass.is_a?(String) ? klass : klass.name }
8
9
  end
9
10
 
11
+ # preview screen
10
12
  def show
11
- @email_locale = (params[:email_locale].presence || I18n.locale).to_s
12
- I18n.with_locale(@email_locale) do
13
- @part_type = params[:part_type] || 'text/html'
14
- @mail = @preview_class.new.send(params[:mail_action])
15
- end
13
+ @part_type = params[:part_type] || 'text/html'
14
+ @mail = @preview_class.new.send(params[:mail_action])
16
15
  end
17
16
 
17
+ # render actual email content
18
18
  def show_raw
19
19
  @mail = @preview_class.new.send(params[:mail_action])
20
20
  RailsEmailPreview.run_before_render(@mail)
@@ -31,18 +31,18 @@ class RailsEmailPreview::EmailsController < RailsEmailPreview::ApplicationContro
31
31
  body = "<pre id='message_body'>#{body}</body>"
32
32
  end
33
33
  end
34
-
35
- render :text => body, :layout => false
34
+ render text: body, layout: false
36
35
  end
37
36
 
38
- private
37
+ protected
39
38
 
40
- def set_locale_for_mail
41
- I18n.with_locale(params[:locale]) {
42
- yield if block_given?
43
- }
39
+ def with_email_locale(&block)
40
+ @email_locale = (params[:email_locale] || I18n.locale).to_s
41
+ I18n.with_locale @email_locale, &block
44
42
  end
45
43
 
44
+ private
45
+
46
46
  def load_preview_class
47
47
  @preview_class = (RailsEmailPreview.preview_classes || []).find { |pc|
48
48
  (pc.is_a?(String) ? pc : pc.name).underscore == params[:mail_class]
@@ -40,5 +40,5 @@ javascript:
40
40
  }
41
41
 
42
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: @email_locale))
43
+ iframe#src-iframe[src=rails_email_preview.raw_email_url(params.slice(:mail_class, :mail_action, :part_type).merge(email_locale: @email_locale))
44
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.8'
2
+ VERSION = '0.0.9'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_email_preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy