rails_email_preview 0.2.25 → 0.2.26

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: 7c6956392e26974e226939cbce3cdedcbfbc4b7d
4
- data.tar.gz: 6591321d5cc54aeedcf4cfc85546b51a5d2b981c
3
+ metadata.gz: f86b81c3f482a9dd5c94b239ca17d84f2f696580
4
+ data.tar.gz: c25d3d93bcc0bd66e0707154de88fc8349ca8fa1
5
5
  SHA512:
6
- metadata.gz: 816b1dcf2f151e63452cd4b066117be76ce03fd3bc4d932528fdbb640eb562ca248f7ecaa4ace978329694ea4f7df10de355a8a1ed3f6fb4d78c351152084288
7
- data.tar.gz: 9dfe3aee7e8708a8b8fc1ec8e5a93bf02af73f931464e359304e34fc61acc376a9f7a0ba9d4e125706d1b47604914a6357e51ee4fadbd2bcca271b2a09a402cc
6
+ metadata.gz: 6b27657005e0fcd5c93bb7d6752815c42aa719f6025248772eab87e2d53b0789f1eb054d63108478f95740e66c7a4770906b2c722b400414555890dfea00290d
7
+ data.tar.gz: bd0d7e1a79ae9c5c90c07011f2a43fa0b3d76e6701ba1452111405c26f97f7906064f2591a299d25bbfec557be49cbbeb075e496185112fd322208a6b6054051
data/README.md CHANGED
@@ -16,7 +16,7 @@ REP can use your application styles, markup is compatible with [bootstrap 3][rep
16
16
  Add [![Gem Version][gem-badge]][gem] to Gemfile:
17
17
 
18
18
  ```ruby
19
- gem 'rails_email_preview', '~> 0.2.25'
19
+ gem 'rails_email_preview', '~> 0.2.26'
20
20
  ```
21
21
 
22
22
  Add an initializer and the routes:
@@ -103,7 +103,7 @@ module RailsEmailPreview
103
103
  else
104
104
  mail
105
105
  end
106
- return "<pre id='error'>#{html_escape(t('rep.errors.email_missing_format'))}</pre>" if !body_part
106
+ return "<pre id='error'>#{html_escape(t('rep.errors.email_missing_format', locale: @ui_locale))}</pre>" if !body_part
107
107
  if body_part.content_type =~ /plain/
108
108
  "<pre id='message_body'>#{html_escape(body_part.body.to_s)}</pre>".html_safe
109
109
  else
@@ -122,18 +122,20 @@ module RailsEmailPreview
122
122
  I18n.with_locale @email_locale, &block
123
123
  end
124
124
 
125
+ # Email content locale
125
126
  def set_email_preview_locale
126
127
  @email_locale = (params[:email_locale] || RailsEmailPreview.default_email_locale || I18n.default_locale).to_s
127
128
  end
128
129
 
130
+ # UI locale
129
131
  def set_locale
130
- config_locale = RailsEmailPreview.locale
131
- if !I18n.available_locales.map(&:to_s).include?(config_locale.to_s)
132
- config_locale = :en
132
+ @ui_locale = RailsEmailPreview.locale
133
+ if !I18n.available_locales.map(&:to_s).include?(@ui_locale.to_s)
134
+ @ui_locale = :en
133
135
  end
134
136
  begin
135
137
  locale_was = I18n.locale
136
- I18n.locale = config_locale
138
+ I18n.locale = @ui_locale
137
139
  yield if block_given?
138
140
  ensure
139
141
  I18n.locale = locale_was
@@ -7,8 +7,9 @@ module RailsEmailPreview
7
7
  end
8
8
 
9
9
  def columns(&block)
10
+ return to_enum(:columns) unless block_given?
10
11
  split_in_halves(groups) { |_k, v| v.length }.each do |column_groups|
11
- block.call(column_groups)
12
+ block.yield(column_groups)
12
13
  end
13
14
  end
14
15
 
@@ -23,9 +24,9 @@ module RailsEmailPreview
23
24
  def split_in_halves(xs, &weight)
24
25
  xs = xs.to_a
25
26
  ws = xs.map(&weight)
26
- col_w = ws.sum / 2
27
+ col_w = (ws.sum + 1) / 2
27
28
  cur_w = 0
28
- mid = ws.find_index { |w| (cur_w += w) >= col_w + w }
29
+ mid = ws.find_index { |w| (cur_w += w) >= col_w + w } || [ws.length - 1, 0].max
29
30
  [xs.first(mid), xs.from(mid)]
30
31
  end
31
32
 
@@ -20,8 +20,9 @@ javascript:
20
20
  }
21
21
 
22
22
  function getBodyHeight(body) {
23
- // browser compat
24
- return Math.max(body.scrollHeight, body.offsetHeight, body.clientHeight);
23
+ // firefox sometimes returns the wrong value for all of these and needs a bit of extra height
24
+ return (/Firefox/.test(navigator.userAgent) ? 50 : 0) +
25
+ Math.max(body.scrollHeight, body.offsetHeight, body.clientHeight);
25
26
  }
26
27
 
27
28
  function fetchHeaders() {
@@ -62,11 +63,11 @@ javascript:
62
63
  // Only show progress bar after some time to avoid flashing
63
64
  setTimeout(function() {
64
65
  doc.getElementById('email-progress-bar').style.display = 'block';
65
- }, 200);
66
+ }, 350);
66
67
  })(document);
67
68
 
68
69
 
69
- div style='min-height: 400px; position: relative'
70
+ div style='min-height: 450px; position: relative'
70
71
  #email-progress-bar.progress style='display: none; position: absolute; z-index: -1; width: 100%; text-align: center'
71
72
  .progress-bar.progress-bar-striped.active style='width:100%'
72
73
  = t 'rep.base.loading'
@@ -1,3 +1,3 @@
1
1
  module RailsEmailPreview
2
- VERSION = '0.2.25'
2
+ VERSION = '0.2.26'
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.2.25
4
+ version: 0.2.26
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-22 00:00:00.000000000 Z
11
+ date: 2014-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails