effective_email_templates 0.5.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +22 -36
  4. data/app/controllers/admin/email_templates_controller.rb +25 -16
  5. data/app/datatables/effective_email_templates_datatable.rb +18 -16
  6. data/app/mailers/effective/email_templates_mailer.rb +22 -0
  7. data/app/models/effective/email_template.rb +66 -34
  8. data/app/views/admin/email_templates/_actions.html.haml +5 -2
  9. data/app/views/admin/email_templates/_form.html.haml +16 -9
  10. data/app/views/admin/email_templates/index.html.haml +1 -1
  11. data/app/views/layouts/effective_email_templates_mailer_layout.html.haml +7 -0
  12. data/config/effective_email_templates.rb +16 -25
  13. data/config/routes.rb +6 -8
  14. data/db/migrate/01_create_effective_email_templates.rb.erb +14 -8
  15. data/lib/effective_email_templates.rb +18 -14
  16. data/lib/effective_email_templates/engine.rb +1 -1
  17. data/lib/effective_email_templates/importer.rb +55 -0
  18. data/lib/effective_email_templates/version.rb +1 -1
  19. data/lib/generators/effective_email_templates/install_generator.rb +1 -1
  20. data/lib/tasks/effective_email_templates_tasks.rake +19 -0
  21. metadata +30 -142
  22. data/Rakefile +0 -23
  23. data/app/assets/javascripts/effective_email_templates.js +0 -1
  24. data/app/assets/stylesheets/effective_email_templates.css.scss +0 -1
  25. data/app/helpers/effective_email_templates_helper.rb +0 -19
  26. data/app/mailers/effective/email_template_mailer.rb +0 -14
  27. data/app/models/effective/datatables/email_templates.rb +0 -24
  28. data/app/views/effective/email_template_mailer/templated_email.html.haml +0 -1
  29. data/lib/effective/liquid_mailer.rb +0 -15
  30. data/lib/effective_email_templates/email_view_template.rb +0 -39
  31. data/lib/effective_email_templates/liquid_resolver.rb +0 -46
  32. data/lib/effective_email_templates/template_importer.rb +0 -51
  33. data/lib/tasks/effective_email_templates/import_default_views.rake +0 -19
  34. data/spec/controllers/admin/email_templates_controller_spec.rb +0 -60
  35. data/spec/dummy/README.rdoc +0 -28
  36. data/spec/dummy/Rakefile +0 -6
  37. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  38. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  39. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  40. data/spec/dummy/app/controllers/welcome_controller.rb +0 -4
  41. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  42. data/spec/dummy/app/mailers/liquid_resolved_mailer.rb +0 -9
  43. data/spec/dummy/app/mailers/user_liquid_mailer.rb +0 -10
  44. data/spec/dummy/app/models/user.rb +0 -15
  45. data/spec/dummy/app/views/layouts/application.html.erb +0 -17
  46. data/spec/dummy/app/views/user_liquid/after_create_user.liquid +0 -7
  47. data/spec/dummy/app/views/welcome/index.html.haml +0 -1
  48. data/spec/dummy/bin/bundle +0 -3
  49. data/spec/dummy/bin/rails +0 -4
  50. data/spec/dummy/bin/rake +0 -4
  51. data/spec/dummy/config.ru +0 -4
  52. data/spec/dummy/config/application.rb +0 -26
  53. data/spec/dummy/config/boot.rb +0 -5
  54. data/spec/dummy/config/database.yml +0 -25
  55. data/spec/dummy/config/environment.rb +0 -5
  56. data/spec/dummy/config/environments/development.rb +0 -37
  57. data/spec/dummy/config/environments/production.rb +0 -78
  58. data/spec/dummy/config/environments/test.rb +0 -40
  59. data/spec/dummy/config/initializers/assets.rb +0 -8
  60. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  61. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  62. data/spec/dummy/config/initializers/devise.rb +0 -259
  63. data/spec/dummy/config/initializers/effective_email_templates.rb +0 -51
  64. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  65. data/spec/dummy/config/initializers/inflections.rb +0 -16
  66. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  67. data/spec/dummy/config/initializers/session_store.rb +0 -3
  68. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  69. data/spec/dummy/config/locales/devise.en.yml +0 -60
  70. data/spec/dummy/config/locales/en.yml +0 -23
  71. data/spec/dummy/config/routes.rb +0 -57
  72. data/spec/dummy/config/secrets.yml +0 -22
  73. data/spec/dummy/db/migrate/20141126222940_devise_create_users.rb +0 -42
  74. data/spec/dummy/db/migrate/20141126222941_create_effective_email_templates.rb +0 -20
  75. data/spec/dummy/db/schema.rb +0 -46
  76. data/spec/dummy/public/404.html +0 -67
  77. data/spec/dummy/public/422.html +0 -67
  78. data/spec/dummy/public/500.html +0 -66
  79. data/spec/dummy/public/favicon.ico +0 -0
  80. data/spec/effective_email_templates_spec.rb +0 -35
  81. data/spec/factories/email_template.rb +0 -12
  82. data/spec/factories/user.rb +0 -16
  83. data/spec/factory_spec.rb +0 -10
  84. data/spec/lib/effective_email_templates/template_importer_spec.rb +0 -73
  85. data/spec/mailers/liquid_resolved_mailer_spec.rb +0 -38
  86. data/spec/models/email_template_spec.rb +0 -61
  87. data/spec/models/user_spec.rb +0 -10
  88. data/spec/sanity_spec.rb +0 -7
  89. data/spec/spec_helper.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cef9ef57f3bc842cb86ab338ae4d43ec936c7741e840188989879d108051ff2
4
- data.tar.gz: d8875996f534e85e634571e5627416bd545dfa38bada3ef158df4da6c96eb5f0
3
+ metadata.gz: a7ceefc31750874cc34b906a00ce64e80ee805bdf247cb69ec33d080e3625e28
4
+ data.tar.gz: ba54f4fc199b22bb8aed8b01d60f7b71ddfec735b6be56fc37d1cee9853f9a3f
5
5
  SHA512:
6
- metadata.gz: 9ed5a81a0e2a8ee3b081ad57ba27e8535d50b9a37369b96ce26aac1dff4b6190e6dfa2fbb05754e59dbd1fe6b79b721d9dfd5af55603245460bc3f0477ac38b0
7
- data.tar.gz: afe612e4d1db10d7ba4a671668273c940ea3b0fe9eb4f47d2dff60386996b9255db7db1befa5edc0fb4bb7111b624ad471e465db50a0eb48394f878dfcafa54d
6
+ metadata.gz: e24eb4a7e1fa925844d45de25fab8a7bb9b6b3f4fc631c13ba4418a43e9bb304b6be6e1e7eb16c5396d097d8cb5ac910040464af9e1a7bb2aba5122b40f92c61
7
+ data.tar.gz: fc6b6f48a42448af82136497ab39ec26a28c9ef60e1db3ef45b42dac8c7c0d7d0d093005e40f6b246e5e671a63a275e8f32ccce34520a6281fd4ff80c821768e
@@ -1,4 +1,4 @@
1
- Copyright 2014 Code and Effect Inc.
1
+ Copyright 2020 Code and Effect Inc.
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 CHANGED
@@ -1,20 +1,17 @@
1
1
 
2
2
  # Effective Email Templates
3
3
 
4
- **This gem is no longer actively maintained**
4
+ Create email templates that an admin can edit and then send.
5
5
 
6
- Create email templates that an admin or any user can safely edit (you're protected from SQL injection and other nastiness).
7
- Effective Email Templates relies on [Liquid templates](http://liquidmarkup.org/) built by Shopify to profide this safety.
6
+ Rails 3.2.x and higher
8
7
 
9
- Rails 3.2.x and Rails 4 Support
8
+ ## effective_email_templates 1.0
10
9
 
11
- ## Bootstrap3
10
+ This is the 1.0 series of effective_email_templates.
12
11
 
13
- This is the `bootstrap3` branch of effective_email_templates which supports Twitter Bootstrap 3.
12
+ This requires Twitter Bootstrap 4.
14
13
 
15
- All published effective_email_templates 0.x gems will support Twitter Bootstrap 3 and SimpleForm.
16
-
17
- For Bootstrap 4 please see the master branch and/or effective_email_templates 1.x gems.
14
+ Please check out [Effective Email Templates 0.x](https://github.com/code-and-effect/effective_email_templates/tree/bootstrap3) for more information using this gem with Bootstrap 3.
18
15
 
19
16
 
20
17
  ## Getting Started
@@ -22,7 +19,7 @@ For Bootstrap 4 please see the master branch and/or effective_email_templates 1.
22
19
  Add to your Gemfile:
23
20
 
24
21
  ```ruby
25
- gem 'effective_email_templates', :git => 'https://github.com/code-and-effect/effective_email_templates'
22
+ gem 'effective_email_templates'
26
23
  ```
27
24
 
28
25
  Run the bundle command to install it:
@@ -47,10 +44,11 @@ Then migrate the database:
47
44
  rake db:migrate
48
45
  ```
49
46
 
47
+ ## Create Email Templates
50
48
 
51
- ## Creating Email Templates
49
+ `link_to 'Email Templates', effective_email_templates.admin_email_templates_path`
52
50
 
53
- This is very similar to creating other emails in Rails.
51
+ To create your first post, visit `/admin/email_templates` and click `New Email Template`.
54
52
 
55
53
  1. Create a new mailer object (i.e. `/app/mailers/template_mailer.rb`)
56
54
  - Mailer objects need to inherit from `Effective::LiquidMailer`
@@ -119,15 +117,15 @@ mail.deliver
119
117
 
120
118
  ## Authorization
121
119
 
122
- All authorization checks are handled via the config.authorization_method found in the config/initializers/ file.
120
+ All authorization checks are handled via the config.authorization_method found in the `app/config/initializers/effective_email_templates.rb` file.
123
121
 
124
- It is intended for flow through to CanCan or Pundit, but that is not required.
122
+ It is intended for flow through to CanCan or Pundit, but neither of those gems are required.
125
123
 
126
124
  This method is called by all controller actions with the appropriate action and resource
127
125
 
128
126
  Action will be one of [:index, :show, :new, :create, :edit, :update, :destroy]
129
127
 
130
- Resource will the appropriate Effective::Something ActiveRecord object or class
128
+ Resource will the appropriate Effective::EmailTemplate object or class
131
129
 
132
130
  The authorization method is defined in the initializer file:
133
131
 
@@ -173,32 +171,20 @@ end
173
171
  To allow a user to see the admin area, using CanCan:
174
172
 
175
173
  ```ruby
174
+ can :manage, Effective::EmailTemplate
176
175
  can :admin, :effective_email_templates
177
176
  ```
178
177
 
179
-
180
178
  ## License
181
179
 
182
- MIT License. Copyright Code and Effect Inc. http://www.codeandeffect.com
183
-
184
- You are not granted rights or licenses to the trademarks of Code and Effect
185
-
186
- ## TODO
180
+ MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
187
181
 
188
- - minimize gem dependencies
189
- - remove unused non-admin routes and config option
190
- - Add an admin alert if there are mailer methods that do not have associated email templates
191
- - Show admin what the available arguments are for each template
192
- - remove `caller` usage from Effective::LiquidMailer (or remove requirement for Ruby 2.0+)
193
- - add `EffectiveEmailTemplates::present?` to check if a template model is present
194
- - notify the app but don't raise an error if template is not present when an email is sent
195
- - configurable default from address
196
- - configurable prefix for subject line
197
- - use autoload rather than require
198
- - research panoramic gem's usage of the Resolver class and improve our Resolver usage
199
- - enable multipart emails
200
- - enable file attachments
201
- - import factories/fixtures in install task
202
182
 
203
- ## Testing
183
+ ## Contributing
204
184
 
185
+ 1. Fork it
186
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
187
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
188
+ 4. Push to the branch (`git push origin my-new-feature`)
189
+ 5. Bonus points for test coverage
190
+ 6. Create new Pull Request
@@ -1,16 +1,11 @@
1
1
  module Admin
2
2
  class EmailTemplatesController < ApplicationController
3
- before_action :authenticate_user! # This is devise, ensure we're logged in.
3
+ before_action :authenticate_user! if respond_to?(:authenticate_user!)
4
4
 
5
5
  layout (EffectiveEmailTemplates.layout.kind_of?(Hash) ? EffectiveEmailTemplates.layout[:admin_email_templates] : EffectiveEmailTemplates.layout)
6
6
 
7
7
  def index
8
- if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
9
- @datatable = Effective::Datatables::EmailTemplates.new()
10
- else
11
- @datatable = EffectiveEmailTemplatesDatatable.new(self)
12
- end
13
-
8
+ @datatable = EffectiveEmailTemplatesDatatable.new
14
9
  @page_title = 'Email Templates'
15
10
 
16
11
  authorize_effective_email_templates!
@@ -30,10 +25,10 @@ module Admin
30
25
  authorize_effective_email_templates!
31
26
 
32
27
  if @email_template.save
33
- flash[:success] = "Email template created successfully"
28
+ flash[:success] = 'Successfully created email template'
34
29
  redirect_to effective_email_templates.admin_email_templates_path
35
30
  else
36
- flash.now[:error] = "Could not create email template"
31
+ flash.now[:danger] = 'Unable to create email template'
37
32
  render :new
38
33
  end
39
34
  end
@@ -52,23 +47,37 @@ module Admin
52
47
  authorize_effective_email_templates!
53
48
 
54
49
  if @email_template.update(email_template_params)
55
- flash[:success] = "Email template updated successfully"
50
+ flash[:success] = 'Successfully updated email template'
56
51
  redirect_to effective_email_templates.admin_email_templates_path
57
52
  else
58
- flash.now[:error] = "Could not update email template"
53
+ flash.now[:danger] = 'Unable to update email template'
59
54
  render :edit
60
55
  end
61
56
  end
62
57
 
63
- private
58
+ def destroy
59
+ @email_template = Effective::EmailTemplate.find(params[:id])
64
60
 
65
- def email_template_params
66
- params.require(:effective_email_template).permit([ :from, :cc, :bcc, :subject, :body ])
61
+ authorize_effective_email_templates!
62
+
63
+ if @email_template.destroy
64
+ flash[:success] = 'Successfully deleted email template'
65
+ else
66
+ flash[:danger] = 'Unable to delete email template'
67
+ end
68
+
69
+ redirect_to effective_email_templates.admin_email_templates_path
67
70
  end
68
71
 
72
+ private
73
+
69
74
  def authorize_effective_email_templates!
70
- EffectiveEmailTemplates.authorized?(self, :admin, :effective_email_templates)
71
- EffectiveEmailTemplates.authorized?(self, action_name.to_sym, @email_template || Effective::EmailTemplate)
75
+ EffectiveEmailTemplates.authorize!(self, :admin, :effective_email_templates)
76
+ EffectiveEmailTemplates.authorize!(self, action_name.to_sym, @email_template || Effective::EmailTemplate)
77
+ end
78
+
79
+ def email_template_params
80
+ params.require(:effective_email_template).permit(EffectiveEmailTemplates.permitted_params)
72
81
  end
73
82
 
74
83
  end
@@ -1,22 +1,24 @@
1
- unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
- class EffectiveEmailTemplatesDatatable < Effective::Datatable
3
- datatable do
4
- order :subject, :asc
1
+ class EffectiveEmailTemplatesDatatable < Effective::Datatable
2
+ datatable do
3
+ order :subject, :asc
4
+ length :all
5
5
 
6
- col :id, visible: false
7
- col :slug
8
- col :subject
9
- col :from
10
- col :cc, visible: false, label: 'CC'
11
- col :bcc, visible: false, label: 'BCC'
12
- col :body, visible: false
6
+ col :updated_at, visible: false
7
+ col :created_at, visible: false
8
+ col :id, visible: false
13
9
 
14
- actions_col partial: '/admin/email_templates/actions', partial_as: 'email_template'
15
- end
10
+ col :template_name, label: 'Name'
11
+ col :from
12
+ col :cc
13
+ col :bcc
14
+ col :subject
15
+ col :body
16
16
 
17
- collection do
18
- Effective::EmailTemplate.all
19
- end
17
+ actions_col partial: '/admin/email_templates/actions', partial_as: 'email_template'
18
+ end
19
+
20
+ collection do
21
+ Effective::EmailTemplate.all
20
22
  end
21
23
  end
22
24
 
@@ -0,0 +1,22 @@
1
+ module Effective
2
+ class EmailTemplatesMailer < ::ActionMailer::Base
3
+
4
+ def mail(headers = {}, &block)
5
+ email_template = Effective::EmailTemplate.where(template_name: action_name).first!
6
+
7
+ assigns = route_url_assigns(email_template).merge(@assigns || {})
8
+ rendered = email_template.render(assigns)
9
+
10
+ super(rendered.merge(headers))
11
+ end
12
+
13
+ private
14
+
15
+ def route_url_assigns(email_template)
16
+ email_template.template_variables.select { |name| name.ends_with?('_url') }.inject({}) do |h, name|
17
+ h[name] = public_send(name) if respond_to?(name); h
18
+ end
19
+ end
20
+
21
+ end
22
+ end
@@ -1,55 +1,87 @@
1
- require 'liquid'
2
- Liquid::Template.error_mode = :strict # Raises a SyntaxError when invalid syntax is used
3
-
4
1
  module Effective
5
2
  class EmailTemplate < ActiveRecord::Base
6
-
7
3
  self.table_name = EffectiveEmailTemplates.email_templates_table_name.to_s
8
4
 
9
- serialize :template, Liquid::Template
5
+ CONTENT_TYPES = ['text/plain', 'text/html']
10
6
 
11
- validate :slug_needs_to_have_simple_format
12
- validates :slug, presence: true, uniqueness: true
13
- validates :body, presence: true
14
- validates :subject, presence: true
15
- validates :from, presence: true
16
- validates :template, presence: true
7
+ serialize :template_body, Liquid::Template
8
+ serialize :template_subject, Liquid::Template
9
+ serialize :template_variables, Array
17
10
 
18
- before_validation :try_precompile
11
+ # Attributes
12
+ # subject :string
13
+ # from :string
14
+ # cc :string
15
+ # bcc :string
16
+ # body :text
17
+ # content_type :string
18
+ #
19
+ # template_name :string
20
+ # template_body :text
21
+ # template_subject :text
22
+ # template_variables :text
23
+ #
24
+ # timestamps
19
25
 
20
- def precompile
26
+ before_validation do
27
+ self.template_name ||= subject.to_s.parameterize
28
+ self.content_type ||= CONTENT_TYPES.first
29
+ end
30
+
31
+ before_validation(if: -> { body.present? }) do
21
32
  begin
22
- self.template = Liquid::Template.parse( body )
23
- rescue Liquid::SyntaxError => error
24
- errors.add :template, error.message
33
+ self.template_body = Liquid::Template.parse(body)
34
+ rescue Liquid::SyntaxError => e
35
+ errors.add(:body, e.message)
25
36
  end
26
37
  end
27
38
 
28
- def mail_options
29
- {
30
- from: from,
31
- subject: subject,
32
- cc: cc,
33
- bcc: bcc
34
- }.delete_if { |_, v| v.blank? }
39
+ before_validation(if: -> { subject.present? }) do
40
+ begin
41
+ self.template_subject = Liquid::Template.parse(subject)
42
+ rescue Liquid::SyntaxError => e
43
+ errors.add(:subject, e.message)
44
+ end
35
45
  end
36
46
 
37
- def render( *args )
38
- template.render( *args )
47
+ validates :subject, presence: true
48
+ validates :from, presence: true
49
+ validates :body, presence: true
50
+ validates :content_type, presence: true, inclusion: { in: CONTENT_TYPES }
51
+
52
+ validates :template_name, presence: true
53
+ validates :template_body, presence: true
54
+ validates :template_subject, presence: true
55
+
56
+ before_save do
57
+ self.template_variables = find_template_variables
39
58
  end
40
59
 
41
- private
60
+ def to_s
61
+ template_name.presence || 'New Email Template'
62
+ end
42
63
 
43
- def try_precompile
44
- precompile if body_changed?
64
+ def render(assigns = {})
65
+ {
66
+ from: from,
67
+ cc: cc.presence || false,
68
+ bcc: bcc.presence || false,
69
+ content_type: content_type,
70
+ subject: template_subject.render(assigns),
71
+ body: template_body.render(assigns)
72
+ }
45
73
  end
46
74
 
47
- def slug_needs_to_have_simple_format
48
- # convert slug to symbol
49
- # add error if symbol has non-simple format (i.e. `:"symbol with spaces"` vs `:symbol_with_underscores`)
50
- if /[@$"]/ =~ slug.to_sym.inspect || slug.match(/[A-Z]/)
51
- errors.add(:slug, 'must have a simple format with no spaces, capital letters, and most punctuation (good: "hello_world", bad: "hello, world")')
52
- end
75
+ private
76
+
77
+ def find_template_variables
78
+ [template_body.presence, template_subject.presence].compact.map do |template|
79
+ Liquid::ParseTreeVisitor.for(template.root).add_callback_for(Liquid::VariableLookup) do |node|
80
+ [node.name, *node.lookups].join('.')
81
+ end.visit
82
+ end.flatten.uniq.compact
53
83
  end
84
+
54
85
  end
86
+
55
87
  end
@@ -1,2 +1,5 @@
1
- %span{:style => 'white-space: nowrap;'}
2
- = link_to 'Edit', effective_email_templates.edit_admin_email_template_path(email_template)
1
+ = dropdown(variation: :dropleft) do
2
+ = dropdown_link_to 'Edit', effective_email_templates.edit_admin_email_template_path(email_template)
3
+
4
+ = dropdown_link_to "Delete #{email_template}", effective_email_templates.admin_email_template_path(email_template),
5
+ data: { method: :delete, confirm: "Really delete #{email_template}?" }
@@ -1,9 +1,16 @@
1
- = simple_form_for email_template, url: email_template_form_url(email_template) do |f|
2
- = f.input :subject
3
- = f.input :slug, disabled: true
4
- = f.input :from
5
- = f.input :cc
6
- = f.input :bcc
7
- = f.input :body, input_html: { rows: 10 }
8
-
9
- = f.button :submit
1
+ = effective_form_with(model: email_template, url: email_template.persisted? ? effective_email_templates.admin_email_template_path(email_template.id) : effective_email_templates.admin_email_templates_path) do |f|
2
+ - if f.object.persisted?
3
+ = f.static_field :template_name, label: 'Name'
4
+
5
+ = f.text_field :subject, hint: 'The subject of your email.'
6
+
7
+ = f.email_field :from, hint: 'Whom the email will be sent from.'
8
+
9
+ = f.text_field :cc
10
+ = f.text_field :bcc
11
+
12
+ = f.select :content_type, Effective::EmailTemplate::CONTENT_TYPES
13
+
14
+ = f.text_area :body, hint: 'The content of your email template'
15
+
16
+ = f.submit
@@ -1,3 +1,3 @@
1
1
  %h1.effective-admin-heading= @page_title
2
2
 
3
- = render_datatable(@datatable)
3
+ = render_datatable @datatable
@@ -0,0 +1,7 @@
1
+ !!!
2
+ %html{style: 'background: #fff;'}
3
+ %head
4
+ %meta{:content => 'text/html; charset=UTF-8', 'http-equiv' => 'Content-Type'}
5
+
6
+ %body{style: 'background: #fff;'}
7
+ = yield
@@ -1,31 +1,7 @@
1
1
  EffectiveEmailTemplates.setup do |config|
2
- # Database table name to store email_templates in. Default is :email_templates
2
+ # Configure Database Tables
3
3
  config.email_templates_table_name = :email_templates
4
4
 
5
- # SimpleForm Options
6
- # This Hash of options will be passed into any simple_form_for() calls
7
- config.simple_form_options = {}
8
-
9
- # config.simple_form_options = {
10
- # :html => {:class => 'form-horizontal'},
11
- # :wrapper => :horizontal_form,
12
- # :wrapper_mappings => {
13
- # :boolean => :horizontal_boolean,
14
- # :check_boxes => :horizontal_radio_and_checkboxes,
15
- # :radio_buttons => :horizontal_radio_and_checkboxes
16
- # }
17
- # }
18
-
19
- # Layout Settings
20
- # Configure the Layout per controller, or all at once
21
-
22
- # config.layout = 'application' # All EffectiveEmailTemplates controllers will use this layout
23
- config.layout = {
24
- :email_templates => 'application',
25
- :admin_email_templates => 'application'
26
- }
27
-
28
-
29
5
  # Authorization Method
30
6
  #
31
7
  # This method is called by all controller actions with the appropriate action and resource
@@ -47,5 +23,20 @@ EffectiveEmailTemplates.setup do |config|
47
23
  # config.authorization_method = false
48
24
  config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) } # CanCanCan
49
25
 
26
+ # Layout Settings
27
+ # Configure the Layout per controller, or all at once
28
+
29
+ # config.layout = 'application' # All EffectiveEmailTemplates controllers will use this layout
30
+ config.layout = {
31
+ email_templates: 'application',
32
+ admin_email_templates: 'admin'
33
+ }
34
+
35
+ # Mailer Settings
36
+ config.mailer = {
37
+ subject_prefix: '[example] ',
38
+ layout: 'effective_email_templates_mailer_layout',
39
+ deliver_method: nil # :deliver (rails < 4.2), :deliver_now (rails >= 4.2) or :deliver_later
40
+ }
50
41
 
51
42
  end