gravity_mailbox 0.1.0 → 0.2.0

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
  SHA256:
3
- metadata.gz: 72867c424724e7388ae25f6eb519d509cfaf7bc6deb90de35eaa766bd6350e40
4
- data.tar.gz: 4d0a7c8ca000e49aed8a878e5bcc402896ae61a97981acf71fcbdbac29d59bad
3
+ metadata.gz: ff342147e916a7f207acf163e0dfb44e66fcc2619a5d5e585bcb4c4bbc3153b6
4
+ data.tar.gz: 2b522879f42bf910804e405a9097f9a277e442b7b8c9e0d6154f19597c8aae1c
5
5
  SHA512:
6
- metadata.gz: 7b24028b7fc05777f0e727f0f4677c990226c255d705caba4a5bcf108e41ae969628faa0545e2f05c6feaab23452691bf016bab6903eff102463e2e7c5a7be53
7
- data.tar.gz: 8824afef7b5bf9618186afc88371da4d3b3d275bed3d574795aa667745f3ae7fd9bd71d18deee7b86860991e370357f627f5963b5d8e969803296ab951a0801e
6
+ metadata.gz: b903157b42b0a571d79d2a046f59a045543ab5722d70d00969829cbe7ffb17ed16644aed83619b5eb8ebed8b689e7aef70a12c12d027e0e1bb83632aea2aa2af
7
+ data.tar.gz: b5b4e508a4cfdf3500f034b06ea6896434c1968c04cae5560b2cda5d5b04369698e3d386c828730424cfac02ab530a226f3b866b333a9ae35233e88a68b8cc14
@@ -1,4 +1,4 @@
1
- name: Ruby
1
+ name: Build
2
2
 
3
3
  on: [push,pull_request]
4
4
 
data/CHANGELOG.md CHANGED
@@ -1,7 +1,12 @@
1
- # Change log
1
+ # Changelog
2
2
 
3
3
  ## main (unreleased)
4
4
 
5
+ ## v0.2.0 (2022-12-15)
6
+
7
+ * New look ([#7](https://github.com/petalmd/gravity_mailbox/pull/7))
8
+ * Download eml file ([#7](https://github.com/petalmd/gravity_mailbox/pull/7))
9
+
5
10
  ## v0.1.0 (2022-11-15)
6
11
 
7
- * Initial release
12
+ * Initial release
data/Gemfile.lock CHANGED
@@ -1,45 +1,47 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gravity_mailbox (0.1.0)
4
+ gravity_mailbox (0.2.0)
5
5
  actionmailer (>= 5.2)
6
6
  railties (>= 5.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionmailer (6.0.5.1)
12
- actionpack (= 6.0.5.1)
13
- actionview (= 6.0.5.1)
14
- activejob (= 6.0.5.1)
11
+ actionmailer (6.1.7)
12
+ actionpack (= 6.1.7)
13
+ actionview (= 6.1.7)
14
+ activejob (= 6.1.7)
15
+ activesupport (= 6.1.7)
15
16
  mail (~> 2.5, >= 2.5.4)
16
17
  rails-dom-testing (~> 2.0)
17
- actionpack (6.0.5.1)
18
- actionview (= 6.0.5.1)
19
- activesupport (= 6.0.5.1)
20
- rack (~> 2.0, >= 2.0.8)
18
+ actionpack (6.1.7)
19
+ actionview (= 6.1.7)
20
+ activesupport (= 6.1.7)
21
+ rack (~> 2.0, >= 2.0.9)
21
22
  rack-test (>= 0.6.3)
22
23
  rails-dom-testing (~> 2.0)
23
24
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
24
- actionview (6.0.5.1)
25
- activesupport (= 6.0.5.1)
25
+ actionview (6.1.7)
26
+ activesupport (= 6.1.7)
26
27
  builder (~> 3.1)
27
28
  erubi (~> 1.4)
28
29
  rails-dom-testing (~> 2.0)
29
30
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
30
- activejob (6.0.5.1)
31
- activesupport (= 6.0.5.1)
31
+ activejob (6.1.7)
32
+ activesupport (= 6.1.7)
32
33
  globalid (>= 0.3.6)
33
- activesupport (6.0.5.1)
34
+ activesupport (6.1.7)
34
35
  concurrent-ruby (~> 1.0, >= 1.0.2)
35
- i18n (>= 0.7, < 2)
36
- minitest (~> 5.1)
37
- tzinfo (~> 1.1)
38
- zeitwerk (~> 2.2, >= 2.2.2)
36
+ i18n (>= 1.6, < 2)
37
+ minitest (>= 5.1)
38
+ tzinfo (~> 2.0)
39
+ zeitwerk (~> 2.3)
39
40
  ast (2.4.2)
40
41
  builder (3.2.4)
41
42
  concurrent-ruby (1.1.10)
42
43
  crass (1.0.6)
44
+ date (3.3.1)
43
45
  diff-lcs (1.5.0)
44
46
  erubi (1.11.0)
45
47
  globalid (1.0.0)
@@ -47,36 +49,50 @@ GEM
47
49
  i18n (1.12.0)
48
50
  concurrent-ruby (~> 1.0)
49
51
  json (2.6.2)
50
- loofah (2.19.0)
52
+ loofah (2.19.1)
51
53
  crass (~> 1.0.2)
52
54
  nokogiri (>= 1.5.9)
53
- mail (2.7.1)
55
+ mail (2.8.0)
54
56
  mini_mime (>= 0.1.1)
57
+ net-imap
58
+ net-pop
59
+ net-smtp
55
60
  method_source (1.0.0)
56
61
  mini_mime (1.1.2)
57
62
  mini_portile2 (2.8.0)
58
63
  minitest (5.16.3)
59
- nokogiri (1.13.9)
64
+ net-imap (0.3.2)
65
+ date
66
+ net-protocol
67
+ net-pop (0.1.2)
68
+ net-protocol
69
+ net-protocol (0.2.1)
70
+ timeout
71
+ net-smtp (0.3.3)
72
+ net-protocol
73
+ nokogiri (1.13.10)
60
74
  mini_portile2 (~> 2.8.0)
61
75
  racc (~> 1.4)
76
+ nokogiri (1.13.10-x86_64-linux)
77
+ racc (~> 1.4)
62
78
  parallel (1.22.1)
63
79
  parser (3.1.2.1)
64
80
  ast (~> 2.4.1)
65
- racc (1.6.0)
81
+ racc (1.6.1)
66
82
  rack (2.2.4)
67
83
  rack-test (2.0.2)
68
84
  rack (>= 1.3)
69
85
  rails-dom-testing (2.0.3)
70
86
  activesupport (>= 4.2.0)
71
87
  nokogiri (>= 1.6)
72
- rails-html-sanitizer (1.4.3)
73
- loofah (~> 2.3)
74
- railties (6.0.5.1)
75
- actionpack (= 6.0.5.1)
76
- activesupport (= 6.0.5.1)
88
+ rails-html-sanitizer (1.4.4)
89
+ loofah (~> 2.19, >= 2.19.1)
90
+ railties (6.1.7)
91
+ actionpack (= 6.1.7)
92
+ activesupport (= 6.1.7)
77
93
  method_source
78
- rake (>= 0.8.7)
79
- thor (>= 0.20.3, < 2.0)
94
+ rake (>= 12.2)
95
+ thor (~> 1.0)
80
96
  rainbow (3.1.1)
81
97
  rake (13.0.6)
82
98
  regexp_parser (2.6.0)
@@ -108,14 +124,15 @@ GEM
108
124
  parser (>= 3.1.1.0)
109
125
  ruby-progressbar (1.11.0)
110
126
  thor (1.2.1)
111
- thread_safe (0.3.6)
112
- tzinfo (1.2.10)
113
- thread_safe (~> 0.1)
127
+ timeout (0.3.1)
128
+ tzinfo (2.0.5)
129
+ concurrent-ruby (~> 1.0)
114
130
  unicode-display_width (2.3.0)
115
131
  zeitwerk (2.6.6)
116
132
 
117
133
  PLATFORMS
118
134
  -darwin-21
135
+ x86_64-linux
119
136
 
120
137
  DEPENDENCIES
121
138
  gravity_mailbox!
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ [![Gem Version](https://badge.fury.io/rb/gravity_mailbox.svg)](https://badge.fury.io/rb/gravity_mailbox)
2
+ [![Ruby](https://github.com/petalmd/gravity_mailbox/actions/workflows/main.yml/badge.svg)](https://github.com/petalmd/gravity_mailbox/actions/workflows/main.yml)
3
+
1
4
  # GravityMailbox
2
5
 
3
6
  Development tools that aim to make it simple to visualize mail sent by your Rails app directly through your Rails app.
@@ -31,7 +34,7 @@ config.action_mailer.perform_deliveries = true
31
34
  * Send mails
32
35
  * Go to http://localhost:3000/gravity_mailbox to see the mails.
33
36
 
34
- <img width="520" alt="image" src="https://user-images.githubusercontent.com/7858787/201705867-74888ae2-fa6d-4678-a911-134ae5527100.png">
37
+ <img width="520" alt="image" src="https://user-images.githubusercontent.com/7858787/206336575-e1455a43-154d-4632-bc80-ecb849e2e224.png">
35
38
 
36
39
  ## Development
37
40
 
@@ -8,8 +8,9 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ['Jean-Francis Bastien']
9
9
  spec.email = ['jfbastien@petalmd.com']
10
10
 
11
- spec.summary = 'Write a short summary, because RubyGems requires one.'
12
- spec.description = 'Write a longer description or delete this line.'
11
+ spec.summary = 'Visualize mail sent by your Rails app directly through your Rails app.'
12
+ spec.description = 'Development tools that aim to make it simple to visualize mail ' \
13
+ 'sent by your Rails app directly through your Rails app.'
13
14
  spec.homepage = 'https://github.com/petalmd/gravity_mailbox'
14
15
  spec.license = 'MIT'
15
16
  spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
@@ -16,6 +16,16 @@ module GravityMailbox
16
16
  render plain: email_body
17
17
  end
18
18
 
19
+ def download_eml
20
+ @mail = RailsCacheDeliveryMethod.mail(params[:id])
21
+ send_data @mail.to_s, filename: "#{@mail.subject}.eml"
22
+ end
23
+
24
+ def delete
25
+ RailsCacheDeliveryMethod.delete(params[:id])
26
+ redirect_to '/gravity_mailbox'
27
+ end
28
+
19
29
  def delete_all
20
30
  RailsCacheDeliveryMethod.delete_all
21
31
  redirect_to '/gravity_mailbox'
@@ -24,6 +24,17 @@ module GravityMailbox
24
24
  end.sort_by(&:date).reverse
25
25
  end
26
26
 
27
+ def self.mail(id)
28
+ Mail.new(Rails.cache.read("#{KEY_PREFIX}#{id}"))
29
+ end
30
+
31
+ def self.delete(id)
32
+ Rails.cache.delete("#{KEY_PREFIX}#{id}")
33
+ actual_list = mail_keys
34
+ actual_list.delete("#{KEY_PREFIX}#{id}")
35
+ Rails.cache.write(MAILS_LIST_KEY, actual_list)
36
+ end
37
+
27
38
  def self.delete_all
28
39
  Rails.cache.delete_matched("#{KEY_PREFIX}*")
29
40
  end
@@ -17,6 +17,8 @@ module GravityMailbox
17
17
  app.routes.prepend do
18
18
  get '/gravity_mailbox' => 'gravity_mailbox/mailbox#index', internal: true
19
19
  post '/gravity_mailbox/delete_all' => 'gravity_mailbox/mailbox#delete_all', internal: true
20
+ get '/gravity_mailbox/download_eml' => 'gravity_mailbox/mailbox#download_eml', internal: true
21
+ post '/gravity_mailbox/delete' => 'gravity_mailbox/mailbox#delete', internal: true
20
22
  end
21
23
  end
22
24
  end
@@ -1,5 +1,51 @@
1
- <div class="box <%= mail.message_id == params[:id] ? 'has-background-success-light' : '' %>">
2
- <strong>Subject: </strong><%= link_to mail.subject, "?id=#{mail.message_id}" %> <br>
3
- <strong>To: </strong><%= mail.to.join(', ') %><br>
4
- <strong>Date: </strong><%= I18n.l(mail.date, format: :long) %><br>
5
- </div>
1
+
2
+ <div class="p-4 mail-list-item <%= mail.message_id == params[:id] ? 'selected-mail' : '' %>" data-mail-id="<%= mail.message_id %>">
3
+ <div class="level" style="margin-bottom: 12px">
4
+ <div class="level-left" style="width: 80%">
5
+ <span class="has-text-weight-semibold mail-subject"><%= mail.subject %></span>
6
+ </div>
7
+ <div class="level-right">
8
+ <div class="dropdown is-right">
9
+ <div class="dropdown-trigger" style="width: 24px; height: 24px;">
10
+ <span class="icon">
11
+ <ion-icon name="ellipsis-vertical-outline"></ion-icon>
12
+ </span>
13
+ </div>
14
+ <div class="dropdown-menu" id="dropdown-menu" role="menu">
15
+ <div class="dropdown-content">
16
+ <div class="dropdown-item">
17
+ <%= link_to "/gravity_mailbox/download_eml?id=#{mail.message_id}", class: ['link-button'] do %>
18
+ <span class="icon-text">
19
+ <span class="icon has-text-centered">
20
+ <ion-icon name="download-outline"></ion-icon>
21
+ </span>
22
+ <span>Download .eml</span>
23
+ </span>
24
+ <% end %>
25
+ </div>
26
+
27
+ <div class="dropdown-item">
28
+ <%= button_to "/gravity_mailbox/delete?id=#{mail.message_id}", class: ['link-button'], method: :post do %>
29
+ <span class="icon-text">
30
+ <span class="icon has-text-centered">
31
+ <ion-icon name="trash-outline"></ion-icon>
32
+ </span>
33
+ <span>Delete</span>
34
+ </span>
35
+ <% end %>
36
+ </div>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ </div>
42
+
43
+ <% mail.to.each do |email_to| %>
44
+ <%= content_tag(:p, email_to, class: ['has-text-weight-light'], style: "font-size: 0.85rem") %>
45
+ <% end %>
46
+ <div class="has-text-right">
47
+ <span class="is-size-7" title="<%= I18n.l(mail.date, format: :long) %>">
48
+ <%= time_ago_in_words(mail.date) %>
49
+ </span>
50
+ </div>
51
+ </div>
@@ -7,20 +7,105 @@
7
7
  border: 0;
8
8
  width: 100%;
9
9
  }
10
+
11
+ .mail-list-column {
12
+ height: 100vh;
13
+ overflow: scroll;
14
+ min-width: 20em;
15
+ }
16
+
17
+ .link-button {
18
+ background: none!important;
19
+ border: none;
20
+ padding: 0!important;
21
+ font-family: arial, sans-serif;
22
+ color: #000;
23
+ cursor: pointer;
24
+ }
25
+
26
+ .selected-mail {
27
+ background-color: #ffffff!important;
28
+ }
29
+
30
+ .mail-list-item {
31
+ background-color: hsl(206deg 27% 96%);
32
+ }
10
33
  <% end %>
11
34
 
12
35
  <div class="columns mb-0 mt-0">
13
- <div class="column is-one-quarter" style="max-height: 100vh; overflow: scroll">
14
- <div class="section" style="padding: 1em;">
15
- <%= button_to 'Delete all', '/gravity_mailbox/delete_all', class: ['button', 'is-danger'], method: :post %>
36
+ <div class="column is-one-quarter pt-0 pr-0 mail-list-column">
37
+ <div class="navbar has-background-info">
38
+ <div class="navbar-brand">
39
+ <h1 class="navbar-item title is-6 has-text-white">GravityMailbox</h1>
40
+ </div>
41
+ <div class="navbar-menu">
42
+ <div class="navbar-end">
43
+ <div class="navbar-item">
44
+ <div class="dropdown is-right" id="toolbar-dropdown">
45
+ <div class="dropdown-trigger" style="width: 24px; height: 24px;">
46
+ <span class="icon has-text-white has-text-centered" aria-controls="dropdown-menu">
47
+ <ion-icon size="large" name="menu-outline"></ion-icon>
48
+ </span>
49
+ </div>
50
+ <div class="dropdown-menu" id="dropdown-menu" role="menu">
51
+ <div class="dropdown-content">
52
+ <div class="dropdown-item">
53
+ <%= button_to '/gravity_mailbox/delete_all', class: ['link-button'], method: :post do %>
54
+ <span class="icon-text">
55
+ <span class="icon has-text-centered">
56
+ <ion-icon name="trash-outline"></ion-icon>
57
+ </span>
58
+ <span>Delete all</span>
59
+ </span>
60
+ <% end %>
61
+ </div>
62
+ </div>
63
+ </div>
64
+ </div>
65
+ </div>
66
+ </div>
67
+ </div>
16
68
  </div>
17
- <% @mails.each do |mail| %>
18
- <%= render partial: 'mail', locals: { mail: mail } %>
19
- <% end %>
69
+
70
+ <% @mails.each_with_index do |mail, index| %>
71
+ <%= render partial: 'mail', locals: { mail: mail, index: index } %>
72
+ <% end %>
20
73
  </div>
21
- <div class="column pb-0 pt-0">
22
- <% if @mail %>
23
- <iframe seamless name="messageBody" src="?part=true&id=<%= params[:id] %>"></iframe>
24
- <% end %>
74
+ <div class="column pb-0 pt-0 pl-0">
75
+ <iframe id="iframe-mail-container" seamless name="messageBody" src="<%= params[:id] ? "?part=true&id=#{params[:id]}" : '' %>"></iframe>
25
76
  </div>
26
77
  </div>
78
+
79
+ <script>
80
+ function closeAllOtherDropdown(e) {
81
+ document.querySelectorAll(".dropdown").forEach((dropdown) => {
82
+ dropdown.classList.remove('is-active');
83
+ })
84
+ }
85
+
86
+ // Click on mail and change iframe src
87
+ let mailItems = document.querySelectorAll(".mail-list-item")
88
+ mailItems.forEach(mailItem => {
89
+ mailItem.addEventListener("click", () => {
90
+ document.querySelector("#iframe-mail-container").src = "/gravity_mailbox?part=true&id=" + mailItem.dataset.mailId
91
+ mailItems.forEach(mailItem => mailItem.classList.remove("selected-mail"))
92
+ mailItem.classList.add("selected-mail")
93
+ })
94
+ })
95
+
96
+ // Close all dropdowns if the user clicks outside of them
97
+ document.addEventListener("click", (e) => {
98
+ document.querySelectorAll(".dropdown").forEach((dropdown) => {
99
+ dropdown.classList.remove("is-active")
100
+ })
101
+ });
102
+
103
+ // Each mail menu dropdown
104
+ document.querySelectorAll('.dropdown-trigger').forEach((dropdown) => {
105
+ dropdown.addEventListener('click', function (e) {
106
+ closeAllOtherDropdown(e)
107
+ e.target.closest(".dropdown").classList.toggle('is-active');
108
+ e.stopPropagation();
109
+ })
110
+ })
111
+ </script>
@@ -10,5 +10,7 @@
10
10
  </head>
11
11
  <body>
12
12
  <%= yield %>
13
+ <script type="module" src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.esm.js"></script>
14
+ <script nomodule src="https://unpkg.com/ionicons@5.5.2/dist/ionicons/ionicons.js"></script>
13
15
  </body>
14
16
  </html>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GravityMailbox
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gravity_mailbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean-Francis Bastien
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-15 00:00:00.000000000 Z
11
+ date: 2022-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionmailer
@@ -38,7 +38,8 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '5.2'
41
- description: Write a longer description or delete this line.
41
+ description: Development tools that aim to make it simple to visualize mail sent by
42
+ your Rails app directly through your Rails app.
42
43
  email:
43
44
  - jfbastien@petalmd.com
44
45
  executables: []
@@ -92,5 +93,5 @@ requirements: []
92
93
  rubygems_version: 3.0.3
93
94
  signing_key:
94
95
  specification_version: 4
95
- summary: Write a short summary, because RubyGems requires one.
96
+ summary: Visualize mail sent by your Rails app directly through your Rails app.
96
97
  test_files: []