nuntius 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/nuntius/application.css +0 -0
  3. data/app/helpers/nuntius/application_helper.rb +6 -6
  4. data/app/models/nuntius/list.rb +1 -1
  5. data/app/models/nuntius/subscriber.rb +1 -1
  6. data/app/tables/nuntius/application_table.rb +4 -0
  7. data/app/tables/nuntius/campaigns_table.rb +42 -0
  8. data/app/tables/nuntius/layouts_table.rb +34 -0
  9. data/app/tables/nuntius/lists_table.rb +31 -0
  10. data/app/tables/nuntius/locales_table.rb +28 -0
  11. data/app/tables/nuntius/messages_table.rb +60 -0
  12. data/app/tables/nuntius/subscribers_table.rb +66 -0
  13. data/app/tables/nuntius/templates_table.rb +58 -0
  14. data/app/views/nuntius/admin/campaigns/index.html.slim +1 -1
  15. data/app/views/nuntius/admin/layouts/edit.html.slim +3 -2
  16. data/app/views/nuntius/admin/layouts/index.html.slim +1 -1
  17. data/app/views/nuntius/admin/lists/edit.html.slim +3 -2
  18. data/app/views/nuntius/admin/lists/index.html.slim +1 -1
  19. data/app/views/nuntius/admin/locales/index.html.slim +1 -1
  20. data/app/views/nuntius/admin/messages/index.html.slim +1 -1
  21. data/app/views/nuntius/admin/templates/edit.html.slim +4 -3
  22. data/app/views/nuntius/admin/templates/index.html.slim +2 -2
  23. data/config/locales/en.yml +18 -3
  24. data/config/locales/nl.yml +120 -9
  25. data/lib/generators/nuntius/install_generator.rb +24 -0
  26. data/lib/generators/nuntius/tailwind_config_generator.rb +24 -0
  27. data/lib/generators/nuntius/templates/config/initializers/nuntius.rb +31 -0
  28. data/lib/nuntius/configuration.rb +18 -7
  29. data/lib/nuntius/version.rb +1 -1
  30. data/lib/tasks/nuntius_tasks.rake +9 -23
  31. metadata +42 -9
  32. data/app/tables/nuntius_campaigns_table.rb +0 -30
  33. data/app/tables/nuntius_layouts_table.rb +0 -24
  34. data/app/tables/nuntius_lists_table.rb +0 -19
  35. data/app/tables/nuntius_locales_table.rb +0 -18
  36. data/app/tables/nuntius_messages_table.rb +0 -36
  37. data/app/tables/nuntius_subscribers_table.rb +0 -20
  38. data/app/tables/nuntius_templates_table.rb +0 -37
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79443fa45e4f41933706a15077cd652aa9bbb323a217f608e594380a7c8c8759
4
- data.tar.gz: 84f7d913569bf6dff0f2ee2cecb9e61119972082adea8b944a52b726799265d1
3
+ metadata.gz: 45c8d99016b685aa17d9ed3e98f034819aa1f99e26417c46e1c63f9d3e8820e0
4
+ data.tar.gz: 8c436f17b211a62558e995f00602fcc58f567044d1d9be87bca2196b807be3d2
5
5
  SHA512:
6
- metadata.gz: fcb1f10966488947cbf7e6d7dcbaa53485f04174eab8abccfeef8cdec135838245775e6c0101068996f9189d13d11893718ee0545a5aa309695cce9718ffab45
7
- data.tar.gz: 8a2d19bc4fc4834ca57021da55f1dfdece9bc6dda9fd538b1b0bc37b9fc62e116cde27814f34ea9ea2fc75835dc2dd45ea3a3edc5d389aeb1cfde8be92d1f19c
6
+ metadata.gz: 60988a352c0b051f24ca087e6e78c0ce14822b46a19bce77518551a8fb2eb02dc1edbe1dcedc761fb0f8f6a76457875542c10fa52c0d6399445fa1dcf008ef87
7
+ data.tar.gz: 424c5204cc8f11d56c62e0518a90a06be373155824965ea386edceb461cbd19fb09c1e2e0ed6364c83ccdc7448a9f0c06965cd4374a3b3936667d3b156b9538e
File without changes
@@ -14,38 +14,38 @@ module Nuntius
14
14
  end
15
15
 
16
16
  def nuntius_templates_menu
17
- Satis::Menus::Builder.build(:templates) do |m|
17
+ Satis::Menus::Builder.build([:nuntius, :templates]) do |m|
18
18
  m.item :new, link: nuntius.new_admin_template_path
19
19
  end
20
20
  end
21
21
 
22
22
  def nuntius_layouts_menu
23
- Satis::Menus::Builder.build(:layouts) do |m|
23
+ Satis::Menus::Builder.build([:nuntius, :layouts]) do |m|
24
24
  m.item :new, link: nuntius.new_admin_layout_path
25
25
  end
26
26
  end
27
27
 
28
28
  def nuntius_locales_menu
29
- Satis::Menus::Builder.build(:locales) do |m|
29
+ Satis::Menus::Builder.build([:nuntius, :locales]) do |m|
30
30
  m.item :new, link: nuntius.new_admin_locale_path
31
31
  end
32
32
  end
33
33
 
34
34
  def nuntius_campaigns_menu
35
- Satis::Menus::Builder.build(:campaign) do |m|
35
+ Satis::Menus::Builder.build([:nuntius, :campaigns]) do |m|
36
36
  m.item :new, link: nuntius.new_admin_campaign_path
37
37
  m.item :lists, link: nuntius.admin_lists_path
38
38
  end
39
39
  end
40
40
 
41
41
  def nuntius_lists_menu
42
- Satis::Menus::Builder.build(:lists) do |m|
42
+ Satis::Menus::Builder.build([:nuntius, :lists]) do |m|
43
43
  m.item :new, link: nuntius.new_admin_list_path
44
44
  end
45
45
  end
46
46
 
47
47
  def nuntius_list_menu
48
- Satis::Menus::Builder.build(:lists) do |m|
48
+ Satis::Menus::Builder.build([:nuntius, :lists]) do |m|
49
49
  m.item :new_subscriber, link: nuntius.new_admin_list_subscriber_path(@list) if @list.persisted?
50
50
  end
51
51
  end
@@ -5,7 +5,7 @@ module Nuntius
5
5
  include Nuntius::Concerns::MetadataScoped
6
6
  include Nuntius::Concerns::Yamlify
7
7
 
8
- has_many :subscribers, counter_cache: :subscribers_count, dependent: :delete_all
8
+ has_many :subscribers, dependent: :delete_all
9
9
 
10
10
  validates :name, presence: true
11
11
  validates :slug, presence: true, uniqueness: true
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nuntius
4
4
  class Subscriber < ApplicationRecord
5
- belongs_to :list
5
+ belongs_to :list, counter_cache: :subscribers_count
6
6
  belongs_to :nuntiable, polymorphic: true, optional: true
7
7
 
8
8
  scope :subscribed, -> { where(unsubscribed_at: nil) }
@@ -0,0 +1,4 @@
1
+ module Nuntius
2
+ class ApplicationTable < Mensa::Base
3
+ end
4
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nuntius
4
+ class CampaignsTable < Nuntius::ApplicationTable
5
+ definition do
6
+ model Nuntius::Campaign
7
+
8
+ column(:name)
9
+ column(:metadata) do
10
+ render do
11
+ html do |template|
12
+ Nuntius.config.metadata_humanize(template.metadata)
13
+ end
14
+ end
15
+ end
16
+ column(:transport)
17
+ column(:state)
18
+
19
+ column(:list_name) do
20
+ attribute "nuntius_lists.name"
21
+ end
22
+
23
+ action :publish do
24
+ # FIXME: next unless campaign.can_publish?
25
+ show ->(campaign) { campaign.transport != "sms" && campaign.can_publish? }
26
+ link { |campaign| campaign.can_publish? ? nuntius.publish_admin_campaign_path(campaign) : nil }
27
+ icon "fa fa-paper-plane"
28
+ link_attributes data: {"turbo-confirm": "Are you sure you want to send out this campaign?", "turbo-method": :post}
29
+ end
30
+
31
+ order name: :asc
32
+
33
+ link { |campaign| nuntius.edit_admin_campaign_path(campaign) }
34
+ end
35
+
36
+ private
37
+
38
+ def scope
39
+ @scope = Nuntius::Campaign.visible.joins(:list)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nuntius
4
+ class LayoutsTable < Nuntius::ApplicationTable
5
+ definition do
6
+ model Nuntius::Layout
7
+
8
+ column(:name)
9
+ column(:metadata) do
10
+ render do
11
+ html do |template|
12
+ Nuntius.config.metadata_humanize(template.metadata)
13
+ end
14
+ end
15
+ end
16
+
17
+ action :delete do
18
+ link { |layout| nuntius.admin_layout_url(layout) }
19
+ icon "fa fa-trash"
20
+ link_attributes data: {"turbo-confirm": "Are you sure you want to delete the layout?", "turbo-method": :delete}
21
+ end
22
+
23
+ order name: :asc
24
+
25
+ link { |layout| nuntius.edit_admin_layout_path(layout) }
26
+ end
27
+
28
+ private
29
+
30
+ def scope
31
+ @scope = Nuntius::Layout.visible
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nuntius
4
+ class ListsTable < Nuntius::ApplicationTable
5
+ definition do
6
+ model Nuntius::List
7
+
8
+ column(:name)
9
+ column(:metadata) do
10
+ render do
11
+ html do |template|
12
+ Nuntius.config.metadata_humanize(template.metadata)
13
+ end
14
+ end
15
+ end
16
+ column(:subscribers_count) do
17
+ attribute "subscribers_count"
18
+ end
19
+
20
+ order name: :asc
21
+
22
+ link { |list| nuntius.edit_admin_list_path(list) }
23
+ end
24
+
25
+ private
26
+
27
+ def scope
28
+ @scope = Nuntius::List.visible
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nuntius
4
+ class LocalesTable < Nuntius::ApplicationTable
5
+ definition do
6
+ model Nuntius::Locale
7
+
8
+ column(:key)
9
+ column(:metadata) do
10
+ render do
11
+ html do |template|
12
+ Nuntius.config.metadata_humanize(template.metadata)
13
+ end
14
+ end
15
+ end
16
+
17
+ order key: :asc
18
+
19
+ link { |locale| nuntius.edit_admin_locale_path(locale) }
20
+ end
21
+
22
+ private
23
+
24
+ def scope
25
+ @scope = Nuntius::Locale.visible
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nuntius
4
+ class MessagesTable < Nuntius::ApplicationTable
5
+ definition do
6
+ model Nuntius::Message
7
+
8
+ column(:to)
9
+ column(:created_at)
10
+ column(:last_sent_at)
11
+ column(:campaign_id) do
12
+ render do
13
+ html do |message|
14
+ link_to message.campaign&.name, nuntius.edit_admin_campaign_path(message.campaign) if message.campaign
15
+ end
16
+ end
17
+ end
18
+ column(:template_id) do
19
+ render do
20
+ html do |message|
21
+ link_to message.template&.description, nuntius.edit_admin_template_path(message.template) if message.template
22
+ end
23
+ end
24
+ end
25
+ column :nuntiable_type do
26
+ internal true # Needed for related_object below
27
+ end
28
+ column :nuntiable_id do
29
+ internal true # Needed for related_object below
30
+ end
31
+ column(:object) do # do |message|
32
+ render do
33
+ html do |message|
34
+ if message.nuntiable
35
+ link_to "#{message.nuntiable} (#{message.nuntiable_type})", begin
36
+ url_for(message.nuntiable)
37
+ rescue
38
+ ""
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ column(:status)
45
+
46
+ order created_at: :desc
47
+
48
+ link { |message| nuntius.admin_message_path(message) }
49
+ end
50
+
51
+ private
52
+
53
+ def scope
54
+ @scope = Nuntius::Message.visible
55
+ @scope = @scope.where(nuntiable_id: params[:nuntiable_id], nuntiable_type: params[:nuntiable_type]) if params[:nuntiable_id]
56
+ @scope = @scope.where(template_id: params[:template_id]) if params[:template_id]
57
+ @scope
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nuntius
4
+ class SubscribersTable < Nuntius::ApplicationTable
5
+ definition do
6
+ model Nuntius::Subscriber
7
+
8
+ column(:list_id) do
9
+ internal true
10
+ filter
11
+ end
12
+
13
+ column :first_name do
14
+ internal true
15
+ end
16
+ column :last_name do
17
+ internal true
18
+ end
19
+ column :nuntiable_type do
20
+ internal true # Needed for related_object below
21
+ end
22
+ column :nuntiable_id do
23
+ internal true # Needed for related_object below
24
+ end
25
+ column(:name) do
26
+ render do
27
+ html do |subscriber|
28
+ subscriber.name
29
+ end
30
+ end
31
+ end
32
+ column(:email)
33
+ column(:phone_number)
34
+ column(:unsubscribed_at)
35
+ column(:tags) do
36
+ render do
37
+ html do |subscriber|
38
+ subscriber.tags&.join(",")
39
+ end
40
+ end
41
+ end
42
+
43
+ column(:object) do # do |message|
44
+ render do
45
+ html do |message|
46
+ if message.nuntiable
47
+ link_to "#{message.nuntiable} (#{message.nuntiable_type})", begin
48
+ url_for(message.nuntiable)
49
+ rescue
50
+ ""
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ link { |subscriber| nuntius.edit_admin_list_subscriber_path(subscriber, list_id: subscriber.list) }
58
+ end
59
+
60
+ private
61
+
62
+ def scope
63
+ @scope = Nuntius::Subscriber.all
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nuntius
4
+ class TemplatesTable < Nuntius::ApplicationTable
5
+ definition do
6
+ model Nuntius::Template
7
+
8
+ column(:description)
9
+ column(:enabled)
10
+ column(:klass)
11
+ column(:event)
12
+ column(:messages_count) do
13
+ attribute "(select count(id) from nuntius_messages where nuntius_messages.template_id = nuntius_templates.id)"
14
+ render do
15
+ html do |template|
16
+ link_to(template.messages_count, nuntius.admin_messages_path(template_id: template.id))
17
+ end
18
+ end
19
+ end
20
+
21
+ column(:metadata) do
22
+ render do
23
+ html do |template|
24
+ Nuntius.config.metadata_humanize(template.metadata)
25
+ end
26
+ end
27
+ end
28
+
29
+ column(:traffic_light) do # , sortable: false) do |template|
30
+ render do
31
+ html do |template|
32
+ color = Nuntius.config.flow_color(template.id)&.light_color || "green"
33
+ content_tag(:span, class: "traffic-signal-#{color.downcase}") do
34
+ content_tag(:i, nil, class: "fa fa-circle fa-xl")
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ action :delete do
41
+ link { |template| nuntius.admin_template_path(template) }
42
+ icon "fa fa-trash"
43
+ link_attributes data: {"turbo-confirm": "Are you sure you want to delete the template?", "turbo-method": :delete}
44
+ end
45
+
46
+ order description: :asc
47
+
48
+ link { |template| nuntius.edit_admin_template_path(template) }
49
+ end
50
+
51
+ private
52
+
53
+ def scope
54
+ @scope = Nuntius::Template.visible
55
+ # @scope = Nuntius::Template.visible.select("nuntius_templates.*, (select count(id) from nuntius_messages where nuntius_messages.template_id = nuntius_templates.id) as message_count")
56
+ end
57
+ end
58
+ end
@@ -1,2 +1,2 @@
1
1
  = sts.card :nuntius_admin_campaigns, icon: 'fad fa-megaphone', content_padding: false, menu: nuntius_campaigns_menu do |card|
2
- = card.table :nuntius_campaigns, custom_views: true
2
+ = sts.table :"nuntius/campaigns"
@@ -19,5 +19,6 @@
19
19
  - card.with_tab:media, padding: true
20
20
  = render partial: 'nuntius/admin/layouts/attachments/index', locals: { attachments: @layout.attachments, upload_url: nuntius.admin_layout_attachments_path(@layout) }
21
21
 
22
- - if @layout.templates.size.positive?
23
- = card.table :nuntius_templates, parameters: { layout_id: @layout.id }, custom_views: false, tab: :templates
22
+ - if @layout.templates.exists?
23
+ - card.with_tab :templates, padding: false
24
+ = sts.table :"nuntius/templates", filters: { layout_id: @layout.id }
@@ -1,2 +1,2 @@
1
1
  = sts.card :nuntius_admin_layouts, icon: 'fad fa-table-layout', content_padding: false, menu: nuntius_layouts_menu do |card|
2
- = card.table :nuntius_layouts, custom_views: true
2
+ = sts.table :"nuntius/layouts", custom_views: true
@@ -20,5 +20,6 @@
20
20
  .col-span-12
21
21
  = f.input :metadata_yaml, as: :editor, mode: 'application/yaml'
22
22
 
23
- - if @list.subscribers.present?
24
- = card.table :nuntius_subscribers, parameters: { list_id: @list.id }, custom_views: false, tab: :nuntius_subscribers
23
+ - if @list.subscribers.exists?
24
+ - card.with_tab :subscribers, padding: false
25
+ = sts.table :"nuntius/subscribers", filters: { list_id: @list.id }
@@ -1,2 +1,2 @@
1
1
  = sts.card :nuntius_admin_lists, icon: 'fad fa-address-book', content_padding: false, menu: nuntius_lists_menu do |card|
2
- = card.table :nuntius_lists, custom_views: true
2
+ = sts.table :"nuntius/lists"
@@ -1,2 +1,2 @@
1
1
  = sts.card :nuntius_admin_locales, icon: 'fad fa-language', content_padding: false, menu: nuntius_locales_menu do |card|
2
- = card.table :nuntius_locales, custom_views: true
2
+ = sts.table :nuntius_locales
@@ -1,2 +1,2 @@
1
1
  = sts.card :nuntius_admin_messages, icon: 'fad fa-envelope', content_padding: false do |card|
2
- = card.table :nuntius_messages, custom_views: true
2
+ = sts.table :"nuntius/messages"
@@ -7,7 +7,7 @@
7
7
  - card.with_action
8
8
  = f.submit
9
9
 
10
- - card.with_tab:edit, padding: true
10
+ - card.with_tab :edit, padding: true
11
11
  .grid.grid-cols-12.gap-4
12
12
  .col-span-1
13
13
  = f.input :enabled, as: :switch
@@ -75,5 +75,6 @@
75
75
  template data-toggle-target='toggleable' data-toggle-value='slack'
76
76
 
77
77
 
78
- - if @template.messages.size.positive?
79
- = card.table :nuntius_messages, parameters: { template_id: @template.id }, custom_views: false, tab: :nuntius_messages
78
+ - if @template.messages.exists?
79
+ - card.with_tab :messages, padding: false
80
+ = sts.table :"nuntius/messages", filters: { template_id: @template.id }
@@ -1,2 +1,2 @@
1
- = sts.card :nuntius_admin_templates, icon: 'fad fa-language', content_padding: false, menu: nuntius_templates_menu do |card|
2
- = card.table :nuntius_templates, custom_views: true
1
+ = sts.card :nuntius_admin_templates, icon: 'fad fa-file', content_padding: false, menu: nuntius_templates_menu do |card|
2
+ = sts.table :"nuntius/templates", custom_views: true
@@ -1,3 +1,18 @@
1
+ en:
2
+ menu:
3
+ nuntius:
4
+ templates:
5
+ new: New template
6
+ layouts:
7
+ new: New layout
8
+ locales:
9
+ new: New locale
10
+ campaigns:
11
+ new: New campaign
12
+ lists: Lists
13
+ lists:
14
+ new: New list
15
+ new_subscriber: New subscriber
1
16
  nuntius:
2
17
  flash:
3
18
  error: There were problems saving the %{model}
@@ -43,10 +58,10 @@
43
58
  edit:
44
59
  card:
45
60
  nuntius_admin_templates:
46
- title: Templates
61
+ title: Template
47
62
  tab:
48
63
  edit: Edit
49
- nuntius_messages: Messages
64
+ messages: Messages
50
65
  metadata: Metadata
51
66
  layouts:
52
67
  index:
@@ -100,7 +115,7 @@
100
115
  Nuntius lists: Lists
101
116
  edit:
102
117
  description: List description
103
- description_hint: Describe the list in detail for the subscibers, explain if they can unsubscribe, how often they will receive messages, etc.
118
+ description_hint: Describe the list in detail for the subscribers, explain if they can unsubscribe, how often they will receive messages, etc.
104
119
  card:
105
120
  nuntius_admin_lists:
106
121
  title: Lists
@@ -1,4 +1,18 @@
1
1
  nl:
2
+ menu:
3
+ nuntius:
4
+ templates:
5
+ new: Nieuwe template
6
+ layouts:
7
+ new: Nieuwe layout
8
+ locales:
9
+ new: Nieuwe locale
10
+ campaigns:
11
+ new: Nieuwe campagne
12
+ lists: Lijsten
13
+ lists:
14
+ new: Nieuwe lijst
15
+ new_subscriber: Nieuwe abonnee
2
16
  nuntius:
3
17
  flash:
4
18
  error: Er waren problem om %{model} op te slaan
@@ -11,12 +25,109 @@ nl:
11
25
  resend:
12
26
  resend_success: Bericht opnieuw verstuurd
13
27
  resend_error: Het is niet gelukt het bericht opnieuw te sturen
14
- breadcrumbs:
15
- nuntius: Nuntius
16
- dashboard: Dashboard
17
- admin:
18
- campaigns: Campagnes
19
- messages: Berichten
20
- layouts: Layouts
21
- lists: Lijsten
22
- templates: Templates
28
+ index:
29
+ card:
30
+ nuntius_admin_messages:
31
+ title: Berichten
32
+ tab:
33
+ Nuntius messages: Berichten
34
+ show:
35
+ message: Message
36
+ card:
37
+ nuntius_admin_messages:
38
+ tabs:
39
+ main:
40
+ tab:
41
+ preview: Preview
42
+ details: Details
43
+ info_item:
44
+ main:
45
+ status: Status
46
+ transport: Transport
47
+ provider: Provider
48
+ provider_id: Provider ID
49
+ request_id: Request ID
50
+ refreshes: Refreshes
51
+ last_sent_at: Last Sent At
52
+ created_at: Created At
53
+ templates:
54
+ index:
55
+ card:
56
+ nuntius_admin_templates:
57
+ title: Templates
58
+ tab:
59
+ Nuntius templates: Templates
60
+ edit:
61
+ card:
62
+ nuntius_admin_templates:
63
+ title: Template
64
+ tabs:
65
+ main:
66
+ tab:
67
+ edit: Bewerk
68
+ messages: Berichten
69
+ metadata: Metadata
70
+ layouts:
71
+ index:
72
+ card:
73
+ nuntius_admin_layouts:
74
+ title: Layouts
75
+ tab:
76
+ Nuntius layouts: Layouts
77
+ edit:
78
+ card:
79
+ nuntius_admin_layouts:
80
+ title: Layouts
81
+ tabs:
82
+ main:
83
+ tab:
84
+ edit: Edit
85
+ metadata: Metadata
86
+ media: Media
87
+
88
+ metadata: Metadata
89
+ locales:
90
+ index:
91
+ card:
92
+ nuntius_admin_locales:
93
+ title: Locales
94
+ tab:
95
+ Nuntius locales: Locales
96
+ edit:
97
+ card:
98
+ nuntius_admin_locales:
99
+ title: Locales
100
+ data: Data
101
+ metadata: Metadata
102
+ campaigns:
103
+ index:
104
+ card:
105
+ nuntius_admin_campaigns:
106
+ title: Campaigns
107
+ tab:
108
+ Nuntius campaigns: Campaigns
109
+ edit:
110
+ card:
111
+ nuntius_admin_campaigns:
112
+ title: Campaigns
113
+ lists:
114
+ subscribers:
115
+ edit:
116
+ subscribers: Subscribers
117
+ index:
118
+ card:
119
+ nuntius_admin_lists:
120
+ title: Lists
121
+ tab:
122
+ Nuntius lists: Lists
123
+ edit:
124
+ description: List description
125
+ description_hint: Describe the list in detail for the subscibers, explain if they can unsubscribe, how often they will receive messages, etc.
126
+ card:
127
+ nuntius_admin_lists:
128
+ title: Lists
129
+ tabs:
130
+ main:
131
+ tab:
132
+ edit: Edit
133
+ nuntius_subscribers: Subscribers
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nuntius
4
+ class InstallGenerator < Rails::Generators::Base
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ def create_initializer_file
8
+ template "config/initializers/nuntius.rb"
9
+ end
10
+
11
+ def add_route
12
+ return if Rails.application.routes.routes.detect { |route| route.app.app == Nuntius::Engine }
13
+ route %(mount Nuntius::Engine => "/nuntius")
14
+ end
15
+
16
+ def copy_migrations
17
+ rake "nuntius:install:migrations"
18
+ end
19
+
20
+ def tailwindcss_config
21
+ rake "nuntius:tailwindcss:config"
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require "rails/generators/base"
2
+
3
+ module Nuntius
4
+ module Generators
5
+ class TailwindConfigGenerator < Rails::Generators::Base
6
+ source_root File.expand_path("../templates", __dir__)
7
+ desc "Configures tailwind.config.js and application.tailwindcss.css"
8
+
9
+ def add_content_to_tailwind_config
10
+ inject_into_file "config/tailwind.config.js", before: "],\n theme: {" do
11
+ " // Nuntius content\n" +
12
+ %w[/app/views/**/* /app/helpers/**/* /app/controllers/**/* /app/components/**/* /app/javascript/**/*.js /app/assets/**/*.css].map { |path| " \"#{Nuntius::Engine.root}#{path}\"" }.join(",\n") +
13
+ ",\n "
14
+ end
15
+ end
16
+
17
+ def add_content_application_tailwind_css
18
+ inject_into_file "app/assets/stylesheets/application.tailwind.css", before: "@tailwind base;" do
19
+ "@import '#{Nuntius::Engine.root}/app/assets/stylesheets/nuntius/application.css';\n"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ Nuntius.setup do |config|
4
+ config.base_controller = "::ApplicationController"
5
+ config.logger = -> { Rails.logger }
6
+
7
+ config.transport :mail
8
+ config.transport :push
9
+ config.transport :sms
10
+ config.transport :voice
11
+ config.allow_custom_events = true
12
+
13
+ config.provider :smtp, transport: :mail, settings: lambda { |_message|
14
+ {
15
+ from_header: "Example <example@example.com>",
16
+ host: "",
17
+ port: "",
18
+ username: "",
19
+ password: "",
20
+ allow_list: ["example.com"]
21
+ }
22
+ }
23
+
24
+ config.provider :houston, transport: :push, settings: {certificate: ""}
25
+ config.provider :firebase, transport: :push, settings: {server_key: ""}
26
+
27
+ config.provider :message_bird, transport: :sms, priority: 1, timeout: 20, settings: {from: "YourApp", auth_token: ""}
28
+ config.provider :twilio, transport: :sms, priority: 2, settings: {sid: "", auth_token: "", from: ""}
29
+
30
+ config.provider :twilio, transport: :voice, settings: {sid: "", auth_token: "", from: ""}
31
+ end
@@ -3,9 +3,20 @@
3
3
  module Nuntius
4
4
  module Options
5
5
  module ClassMethods
6
- def option(name, default: nil)
7
- attr_accessor(name)
8
- schema[name] = default
6
+ def option(name, default: nil, proc: false)
7
+ attr_writer(name)
8
+ schema[name] = {default: default, proc: proc}
9
+
10
+ if schema[name][:proc]
11
+ define_method(name) do |*params|
12
+ value = instance_variable_get(:"@#{name}")
13
+ instance_exec(*params, &value)
14
+ end
15
+ else
16
+ define_method(name) do
17
+ instance_variable_get(:"@#{name}")
18
+ end
19
+ end
9
20
  end
10
21
 
11
22
  def schema
@@ -14,8 +25,8 @@ module Nuntius
14
25
  end
15
26
 
16
27
  def set_defaults!
17
- self.class.schema.each do |name, default|
18
- instance_variable_set(:"@#{name}", default)
28
+ self.class.schema.each do |name, options|
29
+ instance_variable_set(:"@#{name}", options[:default])
19
30
  end
20
31
  end
21
32
 
@@ -27,7 +38,7 @@ module Nuntius
27
38
  class Configuration
28
39
  include Options
29
40
 
30
- option :logger, default: -> { Rails.logger }
41
+ option :logger, default: -> { Rails.logger }, proc: true
31
42
  option :admin_authentication_module, default: "Auxilium::Concerns::AdminAuthenticated"
32
43
  option :base_controller, default: "::ApplicationController"
33
44
  option :base_runner, default: "Nuntius::BasicApplicationRunner"
@@ -36,7 +47,7 @@ module Nuntius
36
47
  option :jobs_queue_name, default: "message"
37
48
  option :allow_custom_events, default: false
38
49
  option :active_storage_service
39
- option :host, default: ->(message) {}
50
+ option :host, default: ->(message) {}, proc: true
40
51
 
41
52
  attr_accessor :visible_scope, :add_metadata, :metadata_fields, :default_template_scope
42
53
  attr_writer :metadata_humanize, :default_params, :flow_color
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nuntius
4
- VERSION = "1.2.2"
4
+ VERSION = "1.3.0"
5
5
  end
@@ -1,27 +1,13 @@
1
- # frozen_string_literal: true
2
-
3
- desc "Release a new version"
4
1
  namespace :nuntius do
5
- task :release do
6
- version_file = "./lib/nuntius/version.rb"
7
- File.open(version_file, "w") do |file|
8
- file.puts <<~EOVERSION
9
- # frozen_string_literal: true
10
-
11
- module Nuntius
12
- VERSION = '#{Nuntius::VERSION.split(".").map(&:to_i).tap { |parts| parts[2] += 1 }.join(".")}'
13
- end
14
- EOVERSION
15
- end
16
- module Nuntius
17
- remove_const :VERSION
2
+ namespace :tailwindcss do
3
+ desc "Configure your Tailwind CSS"
4
+ task :config do
5
+ Rails::Generators.invoke("nuntius:tailwind_config", ["--force"])
18
6
  end
19
- load version_file
20
- puts "Updated version to #{Nuntius::VERSION}"
21
-
22
- `git commit lib/nuntius/version.rb -m "Version #{Nuntius::VERSION}"`
23
- `git push`
24
- `git tag #{Nuntius::VERSION}`
25
- `git push --tags`
26
7
  end
27
8
  end
9
+
10
+ if Rake::Task.task_defined?("tailwindcss:build")
11
+ Rake::Task["tailwindcss:build"].enhance(["nuntius:tailwindcss:config"])
12
+ Rake::Task["tailwindcss:watch"].enhance(["nuntius:tailwindcss:config"])
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nuntius
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom de Grunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-05 00:00:00.000000000 Z
11
+ date: 2024-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apnotic
@@ -374,6 +374,34 @@ dependencies:
374
374
  - - "~>"
375
375
  - !ruby/object:Gem::Version
376
376
  version: '0'
377
+ - !ruby/object:Gem::Dependency
378
+ name: debug
379
+ requirement: !ruby/object:Gem::Requirement
380
+ requirements:
381
+ - - "~>"
382
+ - !ruby/object:Gem::Version
383
+ version: '0'
384
+ type: :development
385
+ prerelease: false
386
+ version_requirements: !ruby/object:Gem::Requirement
387
+ requirements:
388
+ - - "~>"
389
+ - !ruby/object:Gem::Version
390
+ version: '0'
391
+ - !ruby/object:Gem::Dependency
392
+ name: rubocop
393
+ requirement: !ruby/object:Gem::Requirement
394
+ requirements:
395
+ - - "~>"
396
+ - !ruby/object:Gem::Version
397
+ version: '1'
398
+ type: :development
399
+ prerelease: false
400
+ version_requirements: !ruby/object:Gem::Requirement
401
+ requirements:
402
+ - - "~>"
403
+ - !ruby/object:Gem::Version
404
+ version: '1'
377
405
  - !ruby/object:Gem::Dependency
378
406
  name: standard
379
407
  requirement: !ruby/object:Gem::Requirement
@@ -398,6 +426,7 @@ files:
398
426
  - MIT-LICENSE
399
427
  - README.md
400
428
  - Rakefile
429
+ - app/assets/stylesheets/nuntius/application.css
401
430
  - app/controllers/nuntius/admin/campaigns_controller.rb
402
431
  - app/controllers/nuntius/admin/layouts/attachments_controller.rb
403
432
  - app/controllers/nuntius/admin/layouts_controller.rb
@@ -467,13 +496,14 @@ files:
467
496
  - app/services/nuntius/deliver_campaign_service.rb
468
497
  - app/services/nuntius/deliver_inbound_message_service.rb
469
498
  - app/services/nuntius/retrieve_inbound_mail_service.rb
470
- - app/tables/nuntius_campaigns_table.rb
471
- - app/tables/nuntius_layouts_table.rb
472
- - app/tables/nuntius_lists_table.rb
473
- - app/tables/nuntius_locales_table.rb
474
- - app/tables/nuntius_messages_table.rb
475
- - app/tables/nuntius_subscribers_table.rb
476
- - app/tables/nuntius_templates_table.rb
499
+ - app/tables/nuntius/application_table.rb
500
+ - app/tables/nuntius/campaigns_table.rb
501
+ - app/tables/nuntius/layouts_table.rb
502
+ - app/tables/nuntius/lists_table.rb
503
+ - app/tables/nuntius/locales_table.rb
504
+ - app/tables/nuntius/messages_table.rb
505
+ - app/tables/nuntius/subscribers_table.rb
506
+ - app/tables/nuntius/templates_table.rb
477
507
  - app/transports/nuntius/base_transport.rb
478
508
  - app/transports/nuntius/mail_transport.rb
479
509
  - app/transports/nuntius/push_transport.rb
@@ -529,6 +559,9 @@ files:
529
559
  - db/migrate/20220412114148_add_last_sent_to_message.rb
530
560
  - db/migrate/20240205204719_add_description_to_list.rb
531
561
  - db/migrate/20240206203019_add_slug_to_nuntius_list.rb
562
+ - lib/generators/nuntius/install_generator.rb
563
+ - lib/generators/nuntius/tailwind_config_generator.rb
564
+ - lib/generators/nuntius/templates/config/initializers/nuntius.rb
532
565
  - lib/nuntius.rb
533
566
  - lib/nuntius/active_record_helpers.rb
534
567
  - lib/nuntius/active_storage_helpers.rb
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class NuntiusCampaignsTable < ActionTable::ActionTable
4
- model Nuntius::Campaign
5
-
6
- column(:name)
7
- column(:metadata) { |campaign| Nuntius.config.metadata_humanize(campaign.metadata) }
8
- column(:transport)
9
- column(:state)
10
- column(:list, sort_field: "nuntius_lists.name") { |campaign| campaign.list.name }
11
-
12
- column :actions, title: "", sortable: false do |campaign|
13
- next unless campaign.can_publish?
14
-
15
- content_tag(:span, class: "btn-group btn-group-xs") do
16
- concat link_to(content_tag(:i, nil, class: "fa fa-paper-plane"), nuntius.publish_admin_campaign_path(campaign), data: {turbo_confirm: "Are you sure you want to send out this campaign?", turbo_method: :post}, class: "btn btn-xs btn-danger")
17
- end
18
- end
19
-
20
- initial_order :name, :asc
21
-
22
- row_link { |campaign| nuntius.edit_admin_campaign_path(campaign) }
23
-
24
- private
25
-
26
- def scope
27
- @scope = Nuntius::Campaign.visible
28
- @scope = Nuntius::Campaign.joins(:list)
29
- end
30
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class NuntiusLayoutsTable < ActionTable::ActionTable
4
- model Nuntius::Layout
5
-
6
- column(:name)
7
- column(:metadata) { |layout| Nuntius.config.metadata_humanize(layout.metadata) }
8
-
9
- column :actions, title: "", sortable: false do |layout|
10
- content_tag(:span, class: "btn-group btn-group-xs") do
11
- concat link_to(content_tag(:i, nil, class: "fa fa-trash"), nuntius.admin_layout_url(layout), data: {turbo_confirm: "Are you sure you want to delete the layout?", turbo_method: :delete}, class: "btn btn-xs btn-danger")
12
- end
13
- end
14
-
15
- initial_order :name, :asc
16
-
17
- row_link { |layout| nuntius.edit_admin_layout_path(layout) }
18
-
19
- private
20
-
21
- def scope
22
- @scope = Nuntius::Layout.visible
23
- end
24
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class NuntiusListsTable < ActionTable::ActionTable
4
- model Nuntius::List
5
-
6
- column(:name)
7
- column(:metadata) { |list| Nuntius.config.metadata_humanize(list.metadata) }
8
- column(:subscribers, sort_field: "subscribers_count") { |list| list.subscribers.count || "-" }
9
-
10
- initial_order :name, :asc
11
-
12
- row_link { |list| nuntius.edit_admin_list_path(list) }
13
-
14
- private
15
-
16
- def scope
17
- @scope = Nuntius::List.visible
18
- end
19
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class NuntiusLocalesTable < ActionTable::ActionTable
4
- model Nuntius::Locale
5
-
6
- column(:key)
7
- column(:metadata) { |locale| Nuntius.config.metadata_humanize(locale.metadata) }
8
-
9
- initial_order :key
10
-
11
- row_link { |locale| nuntius.edit_admin_locale_path(locale) }
12
-
13
- private
14
-
15
- def scope
16
- @scope = Nuntius::Locale.visible
17
- end
18
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class NuntiusMessagesTable < ActionTable::ActionTable
4
- model Nuntius::Message
5
-
6
- column(:to)
7
- column(:created_at, html_value: proc { |message| ln(message.created_at) })
8
- column(:last_sent_at, html_value: proc { |message| ln(message.last_sent_at) })
9
- column(:origin, sort_field: "nuntius_messages.campaign_id, nuntius_messages.template_id") do |message|
10
- link_to message.campaign&.name, nuntius.edit_admin_campaign_path(message.campaign) if message.campaign
11
- link_to message.template&.description, nuntius.edit_admin_template_path(message.template) if message.template
12
- end
13
- column(:subject) do |message|
14
- if message.nuntiable
15
- link_to "#{message.nuntiable_type} [#{message.nuntiable}]", begin
16
- url_for(message.nuntiable)
17
- rescue
18
- "#"
19
- end
20
- end
21
- end
22
- column(:status)
23
-
24
- initial_order :created_at, :desc
25
-
26
- row_link { |message| nuntius.admin_message_path(message) }
27
-
28
- private
29
-
30
- def scope
31
- @scope = Nuntius::Message.visible
32
- @scope = @scope.where(nuntiable_id: params[:nuntiable_id], nuntiable_type: params[:nuntiable_type]) if params[:nuntiable_id]
33
- @scope = @scope.where(template_id: params[:template_id]) if params[:template_id]
34
- @scope
35
- end
36
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class NuntiusSubscribersTable < ActionTable::ActionTable
4
- model Nuntius::Subscriber
5
-
6
- column(:name, sortable: false)
7
- column(:email)
8
- column(:phonenumber)
9
- column(:unsubscribed_at) { |subscriber| ln(subscriber.unsubscribed_at) }
10
-
11
- initial_order :name, :asc
12
-
13
- row_link { |subscriber| nuntius.edit_admin_list_subscriber_path(subscriber, list_id: subscriber.list) }
14
-
15
- private
16
-
17
- def scope
18
- @scope = Nuntius::Subscriber.where(list_id: params[:list_id])
19
- end
20
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class NuntiusTemplatesTable < ActionTable::ActionTable
4
- model Nuntius::Template
5
-
6
- column(:description)
7
- column(:enabled, as: :boolean)
8
- column(:klass)
9
- column(:event)
10
- column(:messages, sort_field: "message_count") { |template| link_to template.messages.count, nuntius.admin_messages_path(template_id: template.id) }
11
-
12
- column(:metadata) { |template| Nuntius.config.metadata_humanize(template.metadata) }
13
- column(:created_at, html_value: proc { |flow| ln(flow.created_at) })
14
-
15
- column(:traffic_light, sortable: false) do |template|
16
- color = Nuntius.config.flow_color(template.id).light_color || "green"
17
-
18
- "<span class='traffic-signal-#{color.downcase}'><i class='fa fa-circle fa-xl'></i></span>"
19
- end
20
-
21
- column :actions, title: "", sortable: false do |template|
22
- content_tag(:span, class: "btn-group btn-group-xs") do
23
- concat link_to(content_tag(:i, nil, class: "fa fa-trash"), nuntius.admin_template_path(template), data: {turbo_confirm: "Are you sure you want to delete the template?", turbo_method: :delete}, class: "btn btn-xs btn-danger")
24
- end
25
- end
26
-
27
- initial_order :description, :asc
28
-
29
- row_link { |template| nuntius.edit_admin_template_path(template) }
30
-
31
- private
32
-
33
- def scope
34
- @scope = Nuntius::Template.visible
35
- @scope = Nuntius::Template.visible.select("nuntius_templates.*, (select count(id) from nuntius_messages where nuntius_messages.template_id = nuntius_templates.id) as message_count")
36
- end
37
- end