maily 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -6
- data/app/controllers/maily/emails_controller.rb +7 -11
- data/app/views/maily/emails/show.html.erb +3 -3
- data/lib/generators/maily/install_generator.rb +1 -1
- data/lib/maily/email.rb +11 -4
- data/lib/maily/version.rb +1 -1
- data/spec/email_spec.rb +11 -9
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 960fe837fad9d25f9a3c52b45de7540996568f19
|
4
|
+
data.tar.gz: 25f2c237274223154cef523015c4fcfca70a555c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174935bd4512c31ba40c7426c0520baee46d7ff100283f3d34b0b65a4e3392fc08a9969a6a152b4a0b03d7daf1de9d094da5763554f11edb584707b90fc84754
|
7
|
+
data.tar.gz: 75afed37aab5f3c374d2b78a731d7c40ec91302cd39d627e0d6636ea56d68d34c8c469d31957bc1e17382de848f4c2224f3618e03885367e633de80f011009ac
|
data/README.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
Maily is a Rails Engine to manage, test and navigate through all your email templates of your app, being able to preview them directly in your browser.
|
6
6
|
|
7
|
+
Maily automatically picks up all your emails and make them accessible from a kind of dashboard.
|
8
|
+
|
7
9
|
## Features:
|
8
10
|
|
9
11
|
* Mountable engine
|
@@ -11,9 +13,9 @@ Maily is a Rails Engine to manage, test and navigate through all your email temp
|
|
11
13
|
* Template edition (only in development)
|
12
14
|
* Email delivery
|
13
15
|
* Features configurables per environment
|
14
|
-
* Flexible authorization
|
16
|
+
* Flexible authorization system
|
15
17
|
* Minimalistic and clean interface
|
16
|
-
* Easy way (aka `hooks`) to define data for emails
|
18
|
+
* Easy way (aka `hooks`) to define and customize data for emails
|
17
19
|
* Generator to handle a comfortable installation
|
18
20
|
|
19
21
|

|
@@ -130,16 +132,16 @@ Basically, you have 2 ways to restrict the access to `Maily`.
|
|
130
132
|
|
131
133
|
### Custom base controller
|
132
134
|
|
133
|
-
By default `Maily` runs under `ActionController::Base`, but you are able to customize that parent controller (`Maily.base_controller` option) in order to achieve (using `before_action`) a kind of access control system. For example, set a different base controller:
|
135
|
+
By default `Maily` runs under `ActionController::Base`, but you are able to customize that parent controller (`Maily.base_controller` option) in order to achieve (using, for example, `before_action` blocks) a kind of access control system. For example, set a different base controller:
|
134
136
|
|
135
137
|
```ruby
|
136
|
-
Maily.base_controller = '::
|
138
|
+
Maily.base_controller = '::SuperAdminController'
|
137
139
|
```
|
138
140
|
|
139
|
-
And write your own authorization rules in
|
141
|
+
And then write your own authorization rules in this defined controller:
|
140
142
|
|
141
143
|
```ruby
|
142
|
-
class
|
144
|
+
class SuperAdminController < ActionController::Base
|
143
145
|
before_action :maily_authorized?
|
144
146
|
|
145
147
|
private
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Maily
|
2
|
-
class EmailsController < ApplicationController
|
2
|
+
class EmailsController < Maily::ApplicationController
|
3
3
|
before_action :allowed_action?, only: [:edit, :update, :deliver]
|
4
4
|
before_action :load_mailers, only: [:index, :show, :edit]
|
5
5
|
before_action :load_mailer_and_email, except: [:index]
|
@@ -9,15 +9,10 @@ module Maily
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def show
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
else
|
17
|
-
"#{@maily_email.required_arguments.size} arguments needed for #{@maily_email.name} email"
|
18
|
-
end
|
19
|
-
|
20
|
-
redirect_to(root_path, alert: alert)
|
12
|
+
valid, message = @maily_email.validate_arguments
|
13
|
+
|
14
|
+
unless valid
|
15
|
+
redirect_to(root_path, alert: message)
|
21
16
|
end
|
22
17
|
end
|
23
18
|
|
@@ -28,11 +23,12 @@ module Maily
|
|
28
23
|
@email.body
|
29
24
|
end
|
30
25
|
|
31
|
-
render
|
26
|
+
render html: content.raw_source, layout: false
|
32
27
|
end
|
33
28
|
|
34
29
|
def attachment
|
35
30
|
attachment = @email.attachments.find { |elem| elem.filename == params[:attachment] }
|
31
|
+
|
36
32
|
send_data attachment.body, filename: attachment.filename, type: attachment.content_type
|
37
33
|
end
|
38
34
|
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<em class="icon-maily-earth"></em>
|
19
19
|
Languages</li>
|
20
20
|
<% Maily.available_locales.each do |locale| %>
|
21
|
-
<li><%= link_to locale.upcase, url_for(params.merge(locale: locale)) %></li>
|
21
|
+
<li><%= link_to locale.upcase, url_for(params.to_unsafe_h.merge(locale: locale)) %></li>
|
22
22
|
<% end %>
|
23
23
|
</ul>
|
24
24
|
<% end %>
|
@@ -47,8 +47,8 @@
|
|
47
47
|
|
48
48
|
<% if @email.html_part && @email.text_part %>
|
49
49
|
<ul class="maily_format_mail">
|
50
|
-
<li><%= link_to 'HTML', url_for(params.merge(part: 'html')), class: part_class('html') %></li>
|
51
|
-
<li><%= link_to 'TEXT', url_for(params.merge(part: 'text')), class: part_class('text') %></li>
|
50
|
+
<li><%= link_to 'HTML', url_for(params.to_unsafe_h.merge(part: 'html')), class: part_class('html') %></li>
|
51
|
+
<li><%= link_to 'TEXT', url_for(params.to_unsafe_h.merge(part: 'text')), class: part_class('text') %></li>
|
52
52
|
</ul>
|
53
53
|
<% end %>
|
54
54
|
|
data/lib/maily/email.rb
CHANGED
@@ -19,18 +19,25 @@ module Maily
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def required_arguments
|
22
|
-
parameters.select{ |param| param.first == :req }.map(&:last)
|
22
|
+
parameters.select { |param| param.first == :req }.map(&:last)
|
23
23
|
end
|
24
24
|
|
25
25
|
def optional_arguments
|
26
|
-
parameters.select{ |param| param.first == :opt }.map(&:last)
|
26
|
+
parameters.select { |param| param.first == :opt }.map(&:last)
|
27
27
|
end
|
28
28
|
|
29
|
-
def
|
29
|
+
def validate_arguments
|
30
30
|
from = required_arguments.size
|
31
31
|
to = from + optional_arguments.size
|
32
|
+
passed_by_hook = arguments && arguments.size || 0
|
32
33
|
|
33
|
-
|
34
|
+
if passed_by_hook < from
|
35
|
+
[false, "#{name} email requires at least #{from} arguments, passed #{passed_by_hook}"]
|
36
|
+
elsif passed_by_hook > to
|
37
|
+
[false, "#{name} email requires at the most #{to} arguments, passed #{passed_by_hook}"]
|
38
|
+
else
|
39
|
+
[true, nil]
|
40
|
+
end
|
34
41
|
end
|
35
42
|
|
36
43
|
def register_hook(*args)
|
data/lib/maily/version.rb
CHANGED
data/spec/email_spec.rb
CHANGED
@@ -50,19 +50,21 @@ describe Maily::Email do
|
|
50
50
|
expect(email.description).to eq('description')
|
51
51
|
end
|
52
52
|
|
53
|
-
describe '
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
allow_any_instance_of(Maily::Email).to receive(:parameters).and_return([])
|
53
|
+
describe 'validate_arguments' do
|
54
|
+
it 'emails with no arguments required' do
|
55
|
+
email = mailer.find_email('welcome')
|
56
|
+
expect(email.validate_arguments).to eq [true, nil]
|
58
57
|
|
59
|
-
|
58
|
+
email.arguments = ["asd"]
|
59
|
+
expect(email.validate_arguments[1]).to eq("welcome email requires at the most 0 arguments, passed 1")
|
60
60
|
end
|
61
61
|
|
62
|
-
it '
|
63
|
-
|
62
|
+
it 'emails with arguments required' do
|
63
|
+
email = mailer.find_email('invitation')
|
64
|
+
expect(email.validate_arguments).to eq [true, nil]
|
64
65
|
|
65
|
-
|
66
|
+
email = mailer.find_email('recommendation')
|
67
|
+
expect(email.validate_arguments[1]).to eq("recommendation email requires at least 1 arguments, passed 0")
|
66
68
|
end
|
67
69
|
end
|
68
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: maily
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- markets
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
196
|
version: '0'
|
197
197
|
requirements: []
|
198
198
|
rubyforge_project:
|
199
|
-
rubygems_version: 2.5.
|
199
|
+
rubygems_version: 2.5.2
|
200
200
|
signing_key:
|
201
201
|
specification_version: 4
|
202
202
|
summary: Rails Engine to preview emails in the browser.
|