draft_box 0.0.3 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1dc9cf8a9519b398b986ab18e390772663f053ce25c6869eda6a6b7fbbeb72be
4
- data.tar.gz: 80243f6424c99fc312cb7d497b46d1b5dfa3b571683f0693901ae76b86ad49ef
3
+ metadata.gz: a778ef43eef09aecc617ba3b15d394f8069c67f7e2f43a2820755b0fb41b784e
4
+ data.tar.gz: 7f88cf7adbc1f19e4e8f73639e3d883317da6cb2e5f34248a93fb770004ed3d6
5
5
  SHA512:
6
- metadata.gz: 3ebf36e1a8da2d791fae17a97d38d98eb5550cee8c82fbc1f0d32c65f431777d675d81e08ee91fffc19f31c46f4571f5cade5d75ac04e63c0719c64c0dbb7a62
7
- data.tar.gz: e6d50e905acef3486de12c3e4c33bbab26fcd5bb91dcafc49ed16d42fb3a9e177270e4b1db8b1b3e86a8a98431b7a48678b15e819752501b9747afe160fd429d
6
+ metadata.gz: b1d7bdbf517abb97fa9aaca66fc155453b67f50a8715c64ba1cb04a09e822814d828c32eb909892ec3ab931d45ec40e3f27c2034fc65905f9362d74d03e52b99
7
+ data.tar.gz: 8a78ce5701a95373ac46da4937d2abd64c2e77d7cbc6dfed331671700f7ec6cd5f5d8cc46afaff764b88c82d2fdb54cf6081980188424a07ef1e3a1735afa228
@@ -0,0 +1,5 @@
1
+ module DraftBox
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception, unless: -> { Rails.configuration.try(:api_only) }
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ module DraftBox
2
+ class AttachmentsController < ApplicationController
3
+ def show
4
+ @email = DraftBox::Email.find(params[:email_id])
5
+ @attachment = @email.attachments.find(params[:id])
6
+
7
+ send_data @attachment.data, filename: @attachment.filename, type: @attachment.content_type
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,31 @@
1
+ unless Rails.respond_to?(:autoloaders) && Rails.autoloaders.zeitwerk_enabled?
2
+ require_dependency 'draft_box/application_controller'
3
+ end
4
+
5
+ module DraftBox
6
+ class EmailsController < ApplicationController
7
+ before_action :set_emails, only: [:index, :show]
8
+
9
+ def index; end
10
+
11
+ def show
12
+ @email = DraftBox::Email.find(params[:id])
13
+ end
14
+
15
+ def destroy
16
+ DraftBox::Email.find(params[:id]).destroy!
17
+ redirect_to draft_box.emails_path
18
+ end
19
+
20
+ def destroy_all
21
+ DraftBox::Email.destroy_all
22
+ redirect_to draft_box.emails_path
23
+ end
24
+
25
+ private
26
+
27
+ def set_emails
28
+ @emails = DraftBox::Email.includes(:attachments).order(created_at: :desc)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ module DraftBox
2
+ class Attachment < ApplicationRecord
3
+ self.table_name = 'draft_box_attachments'
4
+
5
+ belongs_to :email, class_name: 'DraftBox::Email', foreign_key: :draft_box_email_id
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ module DraftBox
2
+ class Email < ApplicationRecord
3
+ self.table_name = 'draft_box_emails'
4
+
5
+ has_many :attachments, class_name: 'DraftBox::Attachment', dependent: :destroy, foreign_key: :draft_box_email_id
6
+
7
+ if connection.class.to_s.match?(/mysql/i)
8
+ serialize :recipients, coder: JSON
9
+ serialize :carbon_copies, coder: JSON
10
+ serialize :blind_copies, coder: JSON
11
+ end
12
+ end
13
+ end
14
+
@@ -0,0 +1,23 @@
1
+ <div style="width: 300px; height: 100vh; overflow-y: auto; border-right: 1px solid #ddd; padding: 20px; background: #f5f5f5;">
2
+ <% if emails.any? %>
3
+ <%= button_to "Delete All", draft_box.emails_path, method: :delete,
4
+ style: "background: #dc3545; color: white; border: none; padding: 8px 15px; border-radius: 3px; cursor: pointer; width: 100%; margin-bottom: 15px;" %>
5
+ <ul style="list-style: none; padding: 0; margin: 0;">
6
+ <% emails.each do |email| %>
7
+ <li style="padding: 15px; border-bottom: 1px solid #ddd; display: flex; justify-content: space-between; align-items: flex-start;">
8
+ <%= link_to draft_box.email_path(email), style: "text-decoration: none; color: inherit; flex: 1;" do %>
9
+ <div style="font-weight: bold; margin-bottom: 5px;"><%= email.subject %></div>
10
+ <div style="color: #666; font-size: 0.9em;">
11
+ To: <%= email.recipients.join(", ") %><br>
12
+ <%= email.created_at.strftime("%B %d, %Y %H:%M") %>
13
+ </div>
14
+ <% end %>
15
+ <%= button_to "Delete", draft_box.email_path(email), method: :delete,
16
+ style: "background: #dc3545; color: white; border: none; padding: 5px 10px; border-radius: 3px; cursor: pointer;" %>
17
+ </li>
18
+ <% end %>
19
+ </ul>
20
+ <% else %>
21
+ <p style="color: #666; text-align: center;">No emails found</p>
22
+ <% end %>
23
+ </div>
@@ -0,0 +1,10 @@
1
+ <div style="display: flex; height: 100vh;">
2
+ <%= render "draft_box/emails/sidebar", emails: @emails %>
3
+
4
+ <div style="flex: 1; padding: 20px; display: flex; align-items: center; justify-content: center;">
5
+ <div style="text-align: center; color: #666;">
6
+ <h3>Select an email from the sidebar to view details</h3>
7
+ <p>Click on any email in the list to see its full content</p>
8
+ </div>
9
+ </div>
10
+ </div>
@@ -0,0 +1,49 @@
1
+ <div style="display: flex; height: 100vh;">
2
+ <%= render "draft_box/emails/sidebar", emails: @emails %>
3
+
4
+ <div style="flex: 1; padding: 20px;">
5
+ <div style="max-width: 800px; margin: 0 auto;">
6
+ <h2 style="margin-bottom: 20px;"><%= @email.subject %></h2>
7
+
8
+ <div style="background: #f5f5f5; padding: 15px; border-radius: 5px; margin-bottom: 20px;">
9
+ <div style="margin-bottom: 10px;">
10
+ <strong>From:</strong> <%= @email.from %>
11
+ </div>
12
+ <div style="margin-bottom: 10px;">
13
+ <strong>To:</strong> <%= @email.recipients.join(", ") %>
14
+ </div>
15
+ <% if Array.wrap(@email.carbon_copies).any? %>
16
+ <div style="margin-bottom: 10px;">
17
+ <strong>CC:</strong> <%= Array.wrap(@email.carbon_copies).join(", ") %>
18
+ </div>
19
+ <% end %>
20
+ <% if Array.wrap(@email.blind_copies).any? %>
21
+ <div style="margin-bottom: 10px;">
22
+ <strong>BCC:</strong> <%= Array.wrap(@email.blind_copies).join(", ") %>
23
+ </div>
24
+ <% end %>
25
+ <div>
26
+ <strong>Date:</strong> <%= @email.created_at.strftime("%B %d, %Y %H:%M") %>
27
+ </div>
28
+ </div>
29
+
30
+ <% if @email.attachments.any? %>
31
+ <div style="background: #f5f5f5; padding: 15px; border-radius: 5px; margin-bottom: 20px;">
32
+ <strong>Attachments:</strong>
33
+ <ul style="list-style: none; padding: 0; margin: 10px 0 0 0;">
34
+ <% @email.attachments.each do |attachment| %>
35
+ <li style="margin-bottom: 5px;">
36
+ <%= link_to attachment.filename, draft_box.attachment_path(@email, attachment),
37
+ style: "color: #0066cc; text-decoration: none;" %>
38
+ </li>
39
+ <% end %>
40
+ </ul>
41
+ </div>
42
+ <% end %>
43
+
44
+ <div style="background: white; padding: 20px; border: 1px solid #ddd; border-radius: 5px;">
45
+ <%= @email.body.html_safe %>
46
+ </div>
47
+ </div>
48
+ </div>
49
+ </div>
data/config/routes.rb ADDED
@@ -0,0 +1,7 @@
1
+ DraftBox::Engine.routes.draw do
2
+ get '/', to: 'emails#index', as: :emails
3
+ get '/:id', to: 'emails#show', as: :email
4
+ delete '/', to: 'emails#destroy_all', as: :destroy_all
5
+ delete '/:id', to: 'emails#destroy', as: :destroy
6
+ get '/:email_id/attachments/:id', to: 'attachments#show', as: :attachment
7
+ end
@@ -3,7 +3,7 @@ module DraftBox
3
3
  module_function
4
4
 
5
5
  def to_s
6
- '0.0.3'
6
+ '0.0.5'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: draft_box
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paweł Dąbrowski
@@ -17,6 +17,15 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
+ - app/controllers/draft_box/application_controller.rb
21
+ - app/controllers/draft_box/attachments_controller.rb
22
+ - app/controllers/draft_box/emails_controller.rb
23
+ - app/models/draft_box/attachment.rb
24
+ - app/models/draft_box/email.rb
25
+ - app/views/draft_box/emails/_sidebar.html.erb
26
+ - app/views/draft_box/emails/index.html.erb
27
+ - app/views/draft_box/emails/show.html.erb
28
+ - config/routes.rb
20
29
  - lib/draft_box.rb
21
30
  - lib/draft_box/delivery_method.rb
22
31
  - lib/draft_box/engine.rb
@@ -24,7 +33,7 @@ files:
24
33
  - lib/generators/draft_box/install_generator.rb
25
34
  - lib/generators/draft_box/templates/attachments_migration.rb
26
35
  - lib/generators/draft_box/templates/emails_migration.rb
27
- homepage:
36
+ homepage: https://github.com/paweldabrowski/draft_box
28
37
  licenses: []
29
38
  metadata: {}
30
39
  post_install_message:
@@ -42,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
42
51
  - !ruby/object:Gem::Version
43
52
  version: '0'
44
53
  requirements: []
45
- rubygems_version: 3.4.10
54
+ rubygems_version: 3.2.32
46
55
  signing_key:
47
56
  specification_version: 4
48
57
  summary: A web interface for browsing Ruby on Rails sent emails with support for distributed