rails_email_preview 0.2.11 → 0.2.12

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: 1d58be6aaa4a03a2f9d35a845740d8c3d6858dcc
4
- data.tar.gz: 069597aebef68a33e6ca6dc71d51f7a589023d35
3
+ metadata.gz: 528049f3b44f95cb5ce989849643ea8cd8dd4420
4
+ data.tar.gz: 9706cd13d2749ccc82a80cd8b43864867a6d6598
5
5
  SHA512:
6
- metadata.gz: d2aa70c01c5e03699d7c14a5566a0fe378bec24b6a8114bcde0431a973bf4447fee6c3cee8d4f152e5638b987b4a81d1af1c1b4a03b776f9277151d83381bbef
7
- data.tar.gz: 565177dd762effc6e9ce78ff5e09d3663b035aa488890c7cd88c0cfe65f770987816e8a91bc1f272c15de6c0c82c3c91322edce7d225f9ac7f7a7c6fd093f698
6
+ metadata.gz: cce764481f48980482629a5e84feb9f13c5b95472f2a65f2b06a028a67754fa6d302c6fb276fce1e10b69e79deca1a0e72cfcff50dbd2fd0b4ac0d5ed04d4415
7
+ data.tar.gz: 1699e0d59af2b6af7a67d4bfc2197ce93a7c206307e5459c1ab28ec776fb5a83b7da1f79df8146a97279373cc4b2f31a47e47adf0f888c5470ea9a793725650b
data/README.md CHANGED
@@ -17,42 +17,48 @@ How to
17
17
 
18
18
  Add to Gemfile
19
19
 
20
- gem 'rails_email_preview', '~> 0.2.10'
20
+ ```ruby
21
+ gem 'rails_email_preview', '~> 0.2.12'
22
+ ```
21
23
 
22
24
  REP handles setup for you:
23
25
 
24
- # adds initializer and route:
25
- rails g rails_email_preview:install
26
+ ```ruby
27
+ # adds initializer and route:
28
+ rails g rails_email_preview:install
26
29
 
27
- # generates preview classes and method stubs in app/mailer_previews/:
28
- rails g rails_email_preview:update_previews
30
+ # generates preview classes and method stubs in app/mailer_previews/:
31
+ rails g rails_email_preview:update_previews
32
+ ```
29
33
 
30
34
  This last generator will add a stub for each of your emails, then you populate the stubs with mock data:
31
35
 
32
- # app/mailer_previews/user_mailer_preview.rb:
33
- class UserMailerPreview
34
- # preview methods should return Mail objects, e.g.:
35
- def invitation
36
- UserMailer.invitation mock_user('Alice'), mock_user('Bob')
37
- end
38
-
39
- def welcome
40
- UserMailer.welcome mock_user
41
- end
42
-
43
- private
44
- # You can put all your mock helpers in a module
45
- # or you can use your factories / fabricators, just make sure you are not creating anythin
46
- def mock_user(name = 'Bill Gates')
47
- fake_id User.new(name: name, email: "user#{rand 100}@test.com")
48
- end
49
-
50
- def fake_id(obj)
51
- # overrides the method on just this object
52
- obj.define_singleton_method(:id) { 123 + rand(100) }
53
- obj
54
- end
55
- end
36
+ ```ruby
37
+ # app/mailer_previews/user_mailer_preview.rb:
38
+ class UserMailerPreview
39
+ # preview methods should return Mail objects, e.g.:
40
+ def invitation
41
+ UserMailer.invitation mock_user('Alice'), mock_user('Bob')
42
+ end
43
+
44
+ def welcome
45
+ UserMailer.welcome mock_user
46
+ end
47
+
48
+ private
49
+ # You can put all your mock helpers in a module
50
+ # or you can use your factories / fabricators, just make sure you are not creating anythin
51
+ def mock_user(name = 'Bill Gates')
52
+ fake_id User.new(name: name, email: "user#{rand 100}@test.com")
53
+ end
54
+
55
+ def fake_id(obj)
56
+ # overrides the method on just this object
57
+ obj.define_singleton_method(:id) { 123 + rand(100) }
58
+ obj
59
+ end
60
+ end
61
+ ```
56
62
 
57
63
 
58
64
  Routing
@@ -60,12 +66,14 @@ Routing
60
66
 
61
67
  You can access REP urls like this:
62
68
 
63
- # engine root:
64
- rails_email_preview.rep_root_url
65
- # list of emails (same as root):
66
- rails_email_preview.rep_emails_url
67
- # email show:
68
- rails_email_preview.rep_email_url(mail_class: "user_mailer", mail_action: "welcome")
69
+ ```ruby
70
+ # engine root:
71
+ rails_email_preview.rep_root_url
72
+ # list of emails (same as root):
73
+ rails_email_preview.rep_emails_url
74
+ # email show:
75
+ rails_email_preview.rep_email_url(mail_class: "user_mailer", mail_action: "welcome")
76
+ ```
69
77
 
70
78
  Send Emails
71
79
  -------------------
@@ -74,7 +82,9 @@ You can send emails via REP. This is especially useful when testing with limited
74
82
  This will use the environment's mailer settings, but the handler will `perform_deliveries`.
75
83
  Uncomment this line in the initializer to disable sending test emails:
76
84
 
77
- config.enable_send_email = false
85
+ ```ruby
86
+ config.enable_send_email = false
87
+ ```
78
88
 
79
89
  Email editing
80
90
  -------------
@@ -97,16 +107,20 @@ I18n
97
107
  -------------
98
108
 
99
109
  REP expects emails to use current `I18n.locale`:
100
-
101
- # current locale
102
- AccountMailer.some_notification.deliver
103
- # different locale
104
- I18n.with_locale('es') { InviteMailer.send_invites.deliver }
105
-
110
+
111
+ ```ruby
112
+ # current locale
113
+ AccountMailer.some_notification.deliver
114
+ # different locale
115
+ I18n.with_locale('es') { InviteMailer.send_invites.deliver }
116
+
117
+ ```
106
118
  When linking to REP pages you can pass `email_locale` to set the locale for rendering:
107
119
 
108
- # will render email in Spanish:
109
- rails_email_preview.root_url(email_locale: 'es')
120
+ ```ruby
121
+ # will render email in Spanish:
122
+ rails_email_preview.root_url(email_locale: 'es')
123
+ ```
110
124
 
111
125
 
112
126
  If you are using `Resque::Mailer` or `Devise::Async`, you can automatically add I18n.locale information when the mail job is scheduled
@@ -114,32 +128,40 @@ If you are using `Resque::Mailer` or `Devise::Async`, you can automatically add
114
128
 
115
129
  REP displays too many locales? Make sure to set `config.i18n.available_locales`, since it defaults to *all* locales in Rails.
116
130
 
131
+ REP's own UI is fully localized, available locales are: en, de.
132
+
117
133
  Views
118
134
  ---------------------
119
135
 
120
136
  You can render all REP views inside your app layout (this will need styling to look nice if you don't use bootstrap):
121
137
 
122
- Rails.application.config.to_prepare do
123
- # Use admin layout with REP (this will also make app routes accessible within REP):
124
- RailsEmailPreview.layout = 'admin'
125
- end
138
+ ```ruby
139
+ Rails.application.config.to_prepare do
140
+ # Use admin layout with REP (this will also make app routes accessible within REP):
141
+ RailsEmailPreview.layout = 'admin'
142
+ end
143
+ ```
126
144
 
127
145
  REP allows you to customize some of the element classes via `RailsEmailPreview.style`:
128
146
 
129
- {
130
- btn_default_class: 'btn btn-default',
131
- btn_active_class: 'btn btn-primary active',
132
- btn_group_class: 'btn-group',
133
- list_group_class: 'list-group',
134
- list_group_item_class: 'list-group-item',
135
- panel_class: 'panel',
136
- row_class: 'row',
137
- column_class: 'col-%{n}'
138
- }
147
+ ```ruby
148
+ {
149
+ btn_default_class: 'btn btn-default',
150
+ btn_active_class: 'btn btn-primary active',
151
+ btn_group_class: 'btn-group',
152
+ list_group_class: 'list-group',
153
+ list_group_item_class: 'list-group-item',
154
+ panel_class: 'panel',
155
+ row_class: 'row',
156
+ column_class: 'col-%{n}'
157
+ }
158
+ ```
139
159
 
140
160
  E.g., to change column class from `col-` to `column-` everywhere where REP uses columns:
141
161
 
142
- RailsEmailPreview.style[:column_class] = 'column-%{n}'
162
+ ```ruby
163
+ RailsEmailPreview.style[:column_class] = 'column-%{n}'
164
+ ```
143
165
 
144
166
  You can `//= require 'rails_email_preview/layout'` REP-specific styles (`@import 'rails_email_preview/layout'` for SASS).
145
167
 
@@ -152,20 +174,24 @@ Authentication & authorization
152
174
  You can specify the parent controller for REP controller, and it will inherit all before filters.
153
175
  Note that this must be placed before any other references to REP application controller in the initializer (and before `layout=` call):
154
176
 
155
- RailsEmailPreview.parent_controller = 'Admin::ApplicationController' # default: '::ApplicationController'
177
+ ```ruby
178
+ RailsEmailPreview.parent_controller = 'Admin::ApplicationController' # default: '::ApplicationController'
179
+ ```
156
180
 
157
181
  Alternatively, to have custom rules just for REP you can:
158
182
 
159
- Rails.application.config.to_prepare do
160
- RailsEmailPreview::ApplicationController.module_eval do
161
- before_filter :check_rep_permissions
162
-
163
- private
164
- def check_rep_permissions
165
- render status: 403 unless current_user && can_manage_emails?(current_user)
166
- end
167
- end
168
- end
183
+ ```ruby
184
+ Rails.application.config.to_prepare do
185
+ RailsEmailPreview::ApplicationController.module_eval do
186
+ before_filter :check_rep_permissions
187
+
188
+ private
189
+ def check_rep_permissions
190
+ render status: 403 unless current_user && can_manage_emails?(current_user)
191
+ end
192
+ end
193
+ end
194
+ ```
169
195
 
170
196
 
171
197
  This project rocks and uses MIT-LICENSE.
@@ -13,8 +13,8 @@ ruby:
13
13
  $('.left-column,.right-column').hide();
14
14
  $('.center-column').css('margin', 0);
15
15
  $('.page-header h2').html(
16
- "Editing email" +
17
- " <a class='btn btn-primary' href='#{show_url}'>#{t 'rep.view_link'}</a>"
16
+ "#{t '.edit_email'}" +
17
+ " <a class='btn btn-primary' href='#{show_url}'>#{t '.view_link'}</a>"
18
18
  )
19
19
 
20
20
  // Snippet form:
@@ -2,7 +2,7 @@ doctype html
2
2
  = "\n"
3
3
  html
4
4
  head
5
- title = t('rep.head_title')
5
+ title = t('.head_title')
6
6
  = stylesheet_link_tag 'rails_email_preview/application'
7
7
  = javascript_include_tag 'rails_email_preview/application'
8
8
  = yield(:head)
@@ -1,18 +1,30 @@
1
1
  javascript:
2
- function iFrameLoad(id){
3
- var resize = function(id) {
4
- var el = document.getElementById(id),
5
- w = el.parentNode.clientWidth,
6
- h = el.contentWindow.document.body.scrollHeight;
7
- el.height = (h) + "px";
8
- el.width = (w) + "px";
2
+ (function(doc){
3
+ var rep = window.rep = window['rep'] || {
4
+ resizeIframe: function(id) {
5
+ var el = doc.getElementById(id),
6
+ w = el.parentNode.clientWidth,
7
+ h = el.contentWindow.document.body.scrollHeight;
8
+ el.height = (h) + "px";
9
+ el.width = (w) + "px";
10
+ },
11
+ iframeLoad: function(id){
12
+ document.getElementById('loading-el').style.display = 'none';
13
+ setTimeout(function() { rep.resizeIframe(id); rep.loaded = true; });
14
+ },
15
+ resizeAttached: false
9
16
  };
10
- document.getElementById('loading-el').style.display = 'none';
11
- setTimeout(function() { resize(id) });
12
- }
17
+ rep.loaded = false;
18
+ if (!rep.resizeAttached) {
19
+ window.addEventListener('resize', function() {
20
+ if (rep.loaded) rep.resizeIframe('src-iframe');
21
+ });
22
+ rep.resizeAttached = true
23
+ }
24
+ })(document)
13
25
 
14
26
  pre#loading-el.lead
15
27
  i.icon-spinner.icon-spin
16
- | Loading...
28
+ | #{t 'rep.base.loading'}
17
29
  iframe#src-iframe[src=rails_email_preview.rep_raw_email_url(params.slice(:mail_class, :mail_action, :part_type).merge(email_locale: @email_locale))
18
- width="100%" height=1 onLoad="iFrameLoad('src-iframe')" style="border:none;padding:0;margin:0"]
30
+ width="100%" height=1 onLoad="rep.iframeLoad('src-iframe')" style="border:none;padding:0;margin:0"]
@@ -2,5 +2,5 @@
2
2
  = form_tag rails_email_preview.rep_test_deliver_url, method: :post do
3
3
  = hidden_field_tag :email_locale, @email_locale
4
4
  .input-group
5
- span.input-group-btn: button.btn.btn-danger type='submit' data-confirm=t('rep.send_are_you_sure') #{t('rep.send_btn')}
6
- = text_field_tag :recipient_email, '', class: 'form-control', placeholder: t('rep.send_recipient_placeholder')
5
+ span.input-group-btn: button.btn.btn-danger type='submit' data-confirm=t('.send_are_you_sure') #{t('.send_btn')}
6
+ = text_field_tag :recipient_email, '', class: 'form-control', placeholder: t('.send_recipient_placeholder')
@@ -1,5 +1,5 @@
1
1
  h1
2
- | #{t 'rep.list_title'}
2
+ | #{t '.list_title'}
3
3
 
4
4
  - previews_group = proc do |m|
5
5
  - capture do
@@ -19,6 +19,6 @@ div class=rep_row_class
19
19
  hr
20
20
 
21
21
  p.text-center.text-small.text-info
22
- | #{total_emails} emails in #{@preview_class_names.length} mailers
22
+ | #{t 'rep.base.email', count: total_emails} #{t 'rep.base.in'} #{t 'rep.base.mailer', count: @preview_class_names.length }
23
23
  br
24
24
  a href="https://github.com/glebm/rails_email_preview" target='_blank' REP #{RailsEmailPreview::VERSION}
@@ -2,7 +2,7 @@
2
2
  div class=rep_row_class
3
3
  .pull-left
4
4
  ul.breadcrumb
5
- li: a href=rails_email_preview.rep_emails_url(email_locale: @email_locale) #{t 'rep.breadcrumb_list'}
5
+ li: a href=rails_email_preview.rep_emails_url(email_locale: @email_locale) #{t '.breadcrumb_list'}
6
6
  li.active: a href=(request.url) = current_email_name
7
7
 
8
8
  div class=rep_style[:panel_class]
@@ -0,0 +1,33 @@
1
+ de:
2
+ rep:
3
+ base:
4
+ email:
5
+ one: "1 E-Mail"
6
+ other: "%{count} E-Mails"
7
+ mailer:
8
+ one: "1 Mailer"
9
+ other: "%{count} Mailer"
10
+ in: "in"
11
+ loading: "Lade..."
12
+ test_deliver:
13
+ no_delivery_method: "Bitte setze 'config.action_mailer.delivery_method' um E-Mails in der „%{environment}“ Umgebung zu senden."
14
+ provide_email: "An welche Adresse senden?"
15
+ sent_notice: "Senden an %{address} mit %{delivery_method}"
16
+ layouts:
17
+ rails_email_preview:
18
+ application:
19
+ head_title: "E-Mails - REP"
20
+ rails_email_preview:
21
+ emails:
22
+ index:
23
+ list_title: "Anwendungs E-Mails"
24
+ show:
25
+ breadcrumb_list: "E-Mails"
26
+ send_form:
27
+ send_are_you_sure: "Diese Aktion wird diese E-Mail wirklich versenden. Bist du sicher?"
28
+ send_btn: "Senden an"
29
+ send_recipient_placeholder: "E-Mails"
30
+ integrations:
31
+ cms:
32
+ edit_email: "E-Mail bearbeiten"
33
+ view_link: "Anzeigen"
@@ -0,0 +1,33 @@
1
+ en:
2
+ rep:
3
+ base:
4
+ email:
5
+ one: "1 email"
6
+ other: "%{count} emails"
7
+ mailer:
8
+ one: "1 mailer"
9
+ other: "%{count} mailers"
10
+ in: "in"
11
+ loading: "Loading..."
12
+ test_deliver:
13
+ no_delivery_method: "Please set 'config.action_mailer.delivery_method' to send emails in '%{environment}' environment"
14
+ provide_email: "Send to which address?"
15
+ sent_notice: "Sent to %{address} via %{delivery_method}"
16
+ layouts:
17
+ rails_email_preview:
18
+ application:
19
+ head_title: "Emails - REP"
20
+ rails_email_preview:
21
+ emails:
22
+ index:
23
+ list_title: "Application Emails"
24
+ show:
25
+ breadcrumb_list: "Emails"
26
+ send_form:
27
+ send_are_you_sure: "This will actually send this email. Are you sure?"
28
+ send_btn: "Send to"
29
+ send_recipient_placeholder: "Email"
30
+ integrations:
31
+ cms:
32
+ edit_email: "Editing email"
33
+ view_link: "View"
@@ -1,3 +1,3 @@
1
1
  module RailsEmailPreview
2
- VERSION = '0.2.11'
2
+ VERSION = '0.2.12'
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.11
4
+ version: 0.2.12
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-08-29 00:00:00.000000000 Z
11
+ date: 2013-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -170,7 +170,8 @@ files:
170
170
  - lib/rails_email_preview/version.rb
171
171
  - lib/rails_email_preview.rb
172
172
  - config/initializers/rails_email_preview.rb
173
- - config/locales/rep.en.yml
173
+ - config/locales/de.yml
174
+ - config/locales/en.yml
174
175
  - config/routes.rb
175
176
  - MIT-LICENSE
176
177
  - Rakefile
@@ -1,14 +0,0 @@
1
- en:
2
- rep:
3
- test_deliver:
4
- no_delivery_method: Please set "config.action_mailer.delivery_method" to send emails in "%{environment}" environment
5
- provide_email: Send to which address?
6
- sent_notice: "Sent to %{address} via %{delivery_method}"
7
- list_title: Application Emails
8
- breadcrumb_list: Emails
9
- send_recipient_placeholder: Email
10
- send_btn: Send to
11
- send_are_you_sure: This will actually send this email. Are you sure?
12
- view_link: View
13
- head_title: Emails - REP
14
-