sunabamail 0.1.0 → 0.1.1
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/.github/workflows/main.yml +0 -1
- data/CHANGELOG.md +5 -0
- data/app/controllers/sunabamail/application_controller.rb +0 -2
- data/app/controllers/sunabamail/messages/application_controller.rb +1 -1
- data/app/controllers/sunabamail/messages/attachments_controller.rb +1 -1
- data/app/controllers/sunabamail/messages/htmls_controller.rb +1 -1
- data/app/controllers/sunabamail/messages/sources_controller.rb +3 -3
- data/app/controllers/sunabamail/messages/texts_controller.rb +3 -3
- data/app/controllers/sunabamail/messages_controller.rb +1 -1
- data/app/models/sunabamail/mail.rb +49 -0
- data/app/views/sunabamail/messages/_message.html.erb +4 -7
- data/lib/sunabamail/version.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86fa2cbd66cd2b674fc60d64b7f357924a398da46e3173d1a676b1738162692b
|
|
4
|
+
data.tar.gz: e2f9a4c6068f887976d9829a559e2e82e5297b122574423fb009bc51e22afb3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97ba1d5662b8233af2c239e5e499a9ba5f288f31de768815f7a010d0b650ca8b4b5191a72cd90b4d18ebbdbf8eaeaaf38137f130cc77201031f548217def5bf1
|
|
7
|
+
data.tar.gz: 579a729a89976eef5c1a8f2852bcd1562442592b536e5999c721316b6fa643747e0c023c4d5b71b7565ca4e94f765c472e0b8524c0ff60f77ee3f2fdfed87674
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
class Sunabamail::Messages::HtmlsController < Sunabamail::Messages::ApplicationController
|
|
2
2
|
def show
|
|
3
|
-
html = @message.mail.
|
|
3
|
+
html = @message.mail.html_body
|
|
4
4
|
doc = Nokogiri::HTML.fragment(html)
|
|
5
5
|
doc.css("a").each do |a|
|
|
6
6
|
a["target"] = "_blank"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class Sunabamail::Messages::SourcesController < Sunabamail::Messages::ApplicationController
|
|
2
2
|
def show
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
html = @message.mail.html_body
|
|
4
|
+
|
|
5
|
+
send_data html, type: "text/plain", disposition: "inline"
|
|
6
6
|
end
|
|
7
7
|
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
class Sunabamail::Messages::TextsController < Sunabamail::Messages::ApplicationController
|
|
2
2
|
def show
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
text = @message.mail.text_body
|
|
4
|
+
|
|
5
|
+
send_data text, type: "text/plain", disposition: "inline"
|
|
6
6
|
end
|
|
7
7
|
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
class Sunabamail::Mail
|
|
2
|
+
def initialize(raw)
|
|
3
|
+
@mail_message = Mail::Message.new(raw.encoded)
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def has_text?
|
|
7
|
+
return true if text_part.present?
|
|
8
|
+
|
|
9
|
+
"text/plain" == content_type
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def has_html?
|
|
13
|
+
return true if html_part.present?
|
|
14
|
+
|
|
15
|
+
"text/html" == content_type
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def text_body
|
|
19
|
+
if multipart?
|
|
20
|
+
part = text_part
|
|
21
|
+
body = part.body
|
|
22
|
+
body.to_s.force_encoding(part.charset)
|
|
23
|
+
elsif "text/plain" == content_type
|
|
24
|
+
body.to_s.force_encoding(mail_message.charset)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def html_body
|
|
29
|
+
if multipart?
|
|
30
|
+
part = html_part
|
|
31
|
+
body = part.body
|
|
32
|
+
body.to_s.force_encoding(part.charset)
|
|
33
|
+
elsif "text/html" == content_type
|
|
34
|
+
body.to_s.force_encoding(mail_message.charset)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def attachments = mail_message.attachments
|
|
39
|
+
|
|
40
|
+
private
|
|
41
|
+
|
|
42
|
+
attr_reader :mail_message
|
|
43
|
+
|
|
44
|
+
delegate :content_type, :multipart?, :html_part, :text_part, to: :mail_message, private: true
|
|
45
|
+
|
|
46
|
+
def content_type
|
|
47
|
+
mail_message.content_type.to_s.chomp.downcase
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -48,23 +48,20 @@
|
|
|
48
48
|
</div>
|
|
49
49
|
<% end %>
|
|
50
50
|
|
|
51
|
-
<% has_html = mail.html_part.present? %>
|
|
52
|
-
<% has_text = mail.text_part.present? %>
|
|
53
|
-
|
|
54
51
|
<div class="message-views-tabs-container">
|
|
55
52
|
<div class="message-views-tabs">
|
|
56
|
-
<% if has_html %>
|
|
53
|
+
<% if mail.has_html? %>
|
|
57
54
|
<button class="message-view-tab" data-mail-view-handle data-mail-view-target="html">Html</button>
|
|
58
55
|
<button class="message-view-tab" data-mail-view-handle data-mail-view-target="source">Html Source</button>
|
|
59
56
|
<% end %>
|
|
60
|
-
<% if has_text %>
|
|
57
|
+
<% if mail.has_text? %>
|
|
61
58
|
<button class="message-view-tab" data-mail-view-handle data-mail-view-target="text">Text</button>
|
|
62
59
|
<% end %>
|
|
63
60
|
<button class="message-view-tab" data-mail-view-handle data-mail-view-target="raw">Raw</button>
|
|
64
61
|
</div>
|
|
65
62
|
</div>
|
|
66
63
|
|
|
67
|
-
<% if has_html %>
|
|
64
|
+
<% if mail.has_html? %>
|
|
68
65
|
<div class="message-view-item" data-mail-view="html">
|
|
69
66
|
<%= tag.iframe sealmess: "sealmess", data: { src: message_html_path(object) } %>
|
|
70
67
|
</div>
|
|
@@ -72,7 +69,7 @@
|
|
|
72
69
|
<%= tag.iframe sealmess: "sealmess", data: { src: message_source_path(object) } %>
|
|
73
70
|
</div>
|
|
74
71
|
<% end %>
|
|
75
|
-
<% if has_text %>
|
|
72
|
+
<% if mail.has_text? %>
|
|
76
73
|
<div class="message-view-item" data-mail-view="text">
|
|
77
74
|
<%= tag.iframe sealmess: "sealmess", data: { src: message_text_path(object) } %>
|
|
78
75
|
</div>
|
data/lib/sunabamail/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sunabamail
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- hamajyotan
|
|
@@ -15,42 +15,42 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '7.
|
|
18
|
+
version: '7.1'
|
|
19
19
|
type: :runtime
|
|
20
20
|
prerelease: false
|
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
22
22
|
requirements:
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
|
-
version: '7.
|
|
25
|
+
version: '7.1'
|
|
26
26
|
- !ruby/object:Gem::Dependency
|
|
27
27
|
name: activerecord
|
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
|
29
29
|
requirements:
|
|
30
30
|
- - ">="
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '7.
|
|
32
|
+
version: '7.1'
|
|
33
33
|
type: :runtime
|
|
34
34
|
prerelease: false
|
|
35
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '7.
|
|
39
|
+
version: '7.1'
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: railties
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
|
-
version: '7.
|
|
46
|
+
version: '7.1'
|
|
47
47
|
type: :runtime
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
51
|
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: '7.
|
|
53
|
+
version: '7.1'
|
|
54
54
|
description: Provides a custom Action Mailer delivery method that stores outgoing
|
|
55
55
|
emails in the database instead of sending them. Stored emails can be viewed through
|
|
56
56
|
a dedicated interface, making it useful for development and staging environments.
|
|
@@ -75,6 +75,7 @@ files:
|
|
|
75
75
|
- app/controllers/sunabamail/messages/sources_controller.rb
|
|
76
76
|
- app/controllers/sunabamail/messages/texts_controller.rb
|
|
77
77
|
- app/controllers/sunabamail/messages_controller.rb
|
|
78
|
+
- app/models/sunabamail/mail.rb
|
|
78
79
|
- app/models/sunabamail/message.rb
|
|
79
80
|
- app/models/sunabamail/message_raw.rb
|
|
80
81
|
- app/models/sunabamail/record.rb
|
|
@@ -114,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
114
115
|
- !ruby/object:Gem::Version
|
|
115
116
|
version: '0'
|
|
116
117
|
requirements: []
|
|
117
|
-
rubygems_version: 4.0.
|
|
118
|
+
rubygems_version: 4.0.5
|
|
118
119
|
specification_version: 4
|
|
119
120
|
summary: A drop-in Action Mailer delivery method that stores emails in the database
|
|
120
121
|
instead of sending them.
|