turbo_chat 0.1.2 → 0.1.3

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +192 -607
  3. data/app/assets/config/turbo_chat_manifest.js +6 -0
  4. data/app/assets/javascripts/turbo_chat/application.js +4 -0
  5. data/app/assets/javascripts/{chat_gem → turbo_chat}/lifecycle_events.js +1 -1
  6. data/app/assets/javascripts/{chat_gem → turbo_chat}/messages.js +4 -4
  7. data/app/assets/javascripts/{chat_gem → turbo_chat}/realtime.js +3 -3
  8. data/app/controllers/turbo_chat/application_controller.rb +66 -0
  9. data/app/controllers/{chat_gem → turbo_chat}/chat_memberships_controller.rb +4 -4
  10. data/app/controllers/{chat_gem → turbo_chat}/chat_messages_controller.rb +7 -7
  11. data/app/controllers/{chat_gem → turbo_chat}/chats_controller/event_payload_support.rb +5 -5
  12. data/app/controllers/{chat_gem → turbo_chat}/chats_controller/invitation_support.rb +4 -4
  13. data/app/controllers/{chat_gem → turbo_chat}/chats_controller.rb +10 -10
  14. data/app/helpers/{chat_gem → turbo_chat}/application_helper/config_support.rb +2 -2
  15. data/app/helpers/{chat_gem → turbo_chat}/application_helper/mention_support/entry_builder.rb +1 -1
  16. data/app/helpers/{chat_gem → turbo_chat}/application_helper/mention_support/permission_support.rb +2 -2
  17. data/app/helpers/{chat_gem → turbo_chat}/application_helper/mention_support/token_builder.rb +1 -1
  18. data/app/helpers/{chat_gem → turbo_chat}/application_helper/mention_support.rb +5 -5
  19. data/app/helpers/{chat_gem → turbo_chat}/application_helper/message_rendering.rb +11 -11
  20. data/app/helpers/{chat_gem → turbo_chat}/application_helper/participant_support.rb +2 -2
  21. data/app/helpers/turbo_chat/application_helper.rb +12 -0
  22. data/app/models/{chat_gem → turbo_chat}/application_record.rb +1 -1
  23. data/app/models/{chat_gem → turbo_chat}/chat.rb +7 -7
  24. data/app/models/{chat_gem → turbo_chat}/chat_membership.rb +5 -5
  25. data/app/models/{chat_gem → turbo_chat}/chat_message/blocked_words_moderation.rb +7 -7
  26. data/app/models/{chat_gem → turbo_chat}/chat_message/body_length_validation.rb +2 -2
  27. data/app/models/{chat_gem → turbo_chat}/chat_message/broadcasting.rb +1 -1
  28. data/app/models/{chat_gem → turbo_chat}/chat_message/formatting.rb +3 -3
  29. data/app/models/{chat_gem → turbo_chat}/chat_message/mention_validation.rb +3 -3
  30. data/app/models/{chat_gem → turbo_chat}/chat_message/signals.rb +2 -2
  31. data/app/models/{chat_gem → turbo_chat}/chat_message.rb +11 -11
  32. data/app/views/layouts/turbo_chat/application.html.erb +20 -0
  33. data/app/views/turbo_chat/chat_messages/_chat_message.html.erb +1 -0
  34. data/app/views/{chat_gem → turbo_chat}/chat_messages/_form.html.erb +2 -2
  35. data/app/views/{chat_gem → turbo_chat}/chat_messages/_message.html.erb +2 -2
  36. data/app/views/{chat_gem → turbo_chat}/chat_messages/_signals.html.erb +1 -1
  37. data/app/views/{chat_gem → turbo_chat}/chats/show.html.erb +3 -3
  38. data/config/routes.rb +1 -1
  39. data/db/migrate/20260215000000_create_turbo_chat_chats.rb +8 -0
  40. data/db/migrate/{20260215000001_create_chat_gem_chat_memberships.rb → 20260215000001_create_turbo_chat_chat_memberships.rb} +5 -5
  41. data/db/migrate/{20260215000002_create_chat_gem_chat_messages.rb → 20260215000002_create_turbo_chat_chat_messages.rb} +4 -4
  42. data/db/migrate/20260218000011_add_closed_at_to_turbo_chat_chats.rb +6 -0
  43. data/db/migrate/20260218000012_add_custom_role_key_to_chat_memberships.rb +2 -2
  44. data/db/migrate/20260218000013_add_invitation_accepted_to_turbo_chat_chat_memberships.rb +5 -0
  45. data/lib/generators/turbo_chat/install/install_generator.rb +1 -1
  46. data/lib/generators/turbo_chat/install/templates/turbo_chat.rb +2 -0
  47. data/lib/tasks/turbo_chat_tasks.rake +6 -2
  48. data/lib/{chat_gem → turbo_chat}/configuration.rb +4 -2
  49. data/lib/turbo_chat/engine.rb +29 -0
  50. data/lib/{chat_gem → turbo_chat}/model_extensions/chat_participant.rb +6 -6
  51. data/lib/{chat_gem → turbo_chat}/moderation.rb +11 -11
  52. data/lib/{chat_gem → turbo_chat}/permission.rb +1 -1
  53. data/lib/{chat_gem → turbo_chat}/signals.rb +5 -5
  54. data/lib/turbo_chat/version.rb +1 -3
  55. data/lib/turbo_chat.rb +11 -15
  56. metadata +53 -58
  57. data/app/assets/config/chat_gem_manifest.js +0 -6
  58. data/app/assets/javascripts/chat_gem/application.js +0 -4
  59. data/app/controllers/chat_gem/application_controller.rb +0 -41
  60. data/app/helpers/chat_gem/application_helper.rb +0 -12
  61. data/app/views/chat_gem/chat_messages/_chat_message.html.erb +0 -1
  62. data/app/views/layouts/chat_gem/application.html.erb +0 -20
  63. data/db/migrate/20260215000000_create_chat_gem_chats.rb +0 -8
  64. data/db/migrate/20260218000011_add_closed_at_to_chat_gem_chats.rb +0 -6
  65. data/db/migrate/20260218000013_add_invitation_accepted_to_chat_gem_chat_memberships.rb +0 -5
  66. data/lib/chat_gem/engine.rb +0 -29
  67. data/lib/chat_gem/version.rb +0 -3
  68. data/lib/chat_gem.rb +0 -24
  69. data/lib/generators/chat_gem/install/install_generator.rb +0 -18
  70. data/lib/generators/chat_gem/install/templates/chat_gem.rb +0 -36
  71. data/lib/tasks/chat_gem_tasks.rake +0 -1
  72. /data/app/assets/javascripts/{chat_gem → turbo_chat}/shared.js +0 -0
  73. /data/app/assets/stylesheets/{chat_gem → turbo_chat}/application.css +0 -0
  74. /data/app/views/{chat_gem → turbo_chat}/chat_messages/_signal.html.erb +0 -0
  75. /data/app/views/{chat_gem → turbo_chat}/chat_messages/index.html.erb +0 -0
  76. /data/app/views/{chat_gem → turbo_chat}/chats/index.html.erb +0 -0
  77. /data/app/views/{chat_gem → turbo_chat}/chats/new.html.erb +0 -0
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo_chat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Haumer
@@ -59,69 +59,64 @@ extra_rdoc_files: []
59
59
  files:
60
60
  - MIT-LICENSE
61
61
  - README.md
62
- - app/assets/config/chat_gem_manifest.js
63
- - app/assets/javascripts/chat_gem/application.js
64
- - app/assets/javascripts/chat_gem/lifecycle_events.js
65
- - app/assets/javascripts/chat_gem/messages.js
66
- - app/assets/javascripts/chat_gem/realtime.js
67
- - app/assets/javascripts/chat_gem/shared.js
68
- - app/assets/stylesheets/chat_gem/application.css
69
- - app/controllers/chat_gem/application_controller.rb
70
- - app/controllers/chat_gem/chat_memberships_controller.rb
71
- - app/controllers/chat_gem/chat_messages_controller.rb
72
- - app/controllers/chat_gem/chats_controller.rb
73
- - app/controllers/chat_gem/chats_controller/event_payload_support.rb
74
- - app/controllers/chat_gem/chats_controller/invitation_support.rb
75
- - app/helpers/chat_gem/application_helper.rb
76
- - app/helpers/chat_gem/application_helper/config_support.rb
77
- - app/helpers/chat_gem/application_helper/mention_support.rb
78
- - app/helpers/chat_gem/application_helper/mention_support/entry_builder.rb
79
- - app/helpers/chat_gem/application_helper/mention_support/permission_support.rb
80
- - app/helpers/chat_gem/application_helper/mention_support/token_builder.rb
81
- - app/helpers/chat_gem/application_helper/message_rendering.rb
82
- - app/helpers/chat_gem/application_helper/participant_support.rb
83
- - app/models/chat_gem/application_record.rb
84
- - app/models/chat_gem/chat.rb
85
- - app/models/chat_gem/chat_membership.rb
86
- - app/models/chat_gem/chat_message.rb
87
- - app/models/chat_gem/chat_message/blocked_words_moderation.rb
88
- - app/models/chat_gem/chat_message/body_length_validation.rb
89
- - app/models/chat_gem/chat_message/broadcasting.rb
90
- - app/models/chat_gem/chat_message/formatting.rb
91
- - app/models/chat_gem/chat_message/mention_validation.rb
92
- - app/models/chat_gem/chat_message/signals.rb
93
- - app/views/chat_gem/chat_messages/_chat_message.html.erb
94
- - app/views/chat_gem/chat_messages/_form.html.erb
95
- - app/views/chat_gem/chat_messages/_message.html.erb
96
- - app/views/chat_gem/chat_messages/_signal.html.erb
97
- - app/views/chat_gem/chat_messages/_signals.html.erb
98
- - app/views/chat_gem/chat_messages/index.html.erb
99
- - app/views/chat_gem/chats/index.html.erb
100
- - app/views/chat_gem/chats/new.html.erb
101
- - app/views/chat_gem/chats/show.html.erb
102
- - app/views/layouts/chat_gem/application.html.erb
62
+ - app/assets/config/turbo_chat_manifest.js
63
+ - app/assets/javascripts/turbo_chat/application.js
64
+ - app/assets/javascripts/turbo_chat/lifecycle_events.js
65
+ - app/assets/javascripts/turbo_chat/messages.js
66
+ - app/assets/javascripts/turbo_chat/realtime.js
67
+ - app/assets/javascripts/turbo_chat/shared.js
68
+ - app/assets/stylesheets/turbo_chat/application.css
69
+ - app/controllers/turbo_chat/application_controller.rb
70
+ - app/controllers/turbo_chat/chat_memberships_controller.rb
71
+ - app/controllers/turbo_chat/chat_messages_controller.rb
72
+ - app/controllers/turbo_chat/chats_controller.rb
73
+ - app/controllers/turbo_chat/chats_controller/event_payload_support.rb
74
+ - app/controllers/turbo_chat/chats_controller/invitation_support.rb
75
+ - app/helpers/turbo_chat/application_helper.rb
76
+ - app/helpers/turbo_chat/application_helper/config_support.rb
77
+ - app/helpers/turbo_chat/application_helper/mention_support.rb
78
+ - app/helpers/turbo_chat/application_helper/mention_support/entry_builder.rb
79
+ - app/helpers/turbo_chat/application_helper/mention_support/permission_support.rb
80
+ - app/helpers/turbo_chat/application_helper/mention_support/token_builder.rb
81
+ - app/helpers/turbo_chat/application_helper/message_rendering.rb
82
+ - app/helpers/turbo_chat/application_helper/participant_support.rb
83
+ - app/models/turbo_chat/application_record.rb
84
+ - app/models/turbo_chat/chat.rb
85
+ - app/models/turbo_chat/chat_membership.rb
86
+ - app/models/turbo_chat/chat_message.rb
87
+ - app/models/turbo_chat/chat_message/blocked_words_moderation.rb
88
+ - app/models/turbo_chat/chat_message/body_length_validation.rb
89
+ - app/models/turbo_chat/chat_message/broadcasting.rb
90
+ - app/models/turbo_chat/chat_message/formatting.rb
91
+ - app/models/turbo_chat/chat_message/mention_validation.rb
92
+ - app/models/turbo_chat/chat_message/signals.rb
93
+ - app/views/layouts/turbo_chat/application.html.erb
94
+ - app/views/turbo_chat/chat_messages/_chat_message.html.erb
95
+ - app/views/turbo_chat/chat_messages/_form.html.erb
96
+ - app/views/turbo_chat/chat_messages/_message.html.erb
97
+ - app/views/turbo_chat/chat_messages/_signal.html.erb
98
+ - app/views/turbo_chat/chat_messages/_signals.html.erb
99
+ - app/views/turbo_chat/chat_messages/index.html.erb
100
+ - app/views/turbo_chat/chats/index.html.erb
101
+ - app/views/turbo_chat/chats/new.html.erb
102
+ - app/views/turbo_chat/chats/show.html.erb
103
103
  - config/routes.rb
104
- - db/migrate/20260215000000_create_chat_gem_chats.rb
105
- - db/migrate/20260215000001_create_chat_gem_chat_memberships.rb
106
- - db/migrate/20260215000002_create_chat_gem_chat_messages.rb
107
- - db/migrate/20260218000011_add_closed_at_to_chat_gem_chats.rb
104
+ - db/migrate/20260215000000_create_turbo_chat_chats.rb
105
+ - db/migrate/20260215000001_create_turbo_chat_chat_memberships.rb
106
+ - db/migrate/20260215000002_create_turbo_chat_chat_messages.rb
107
+ - db/migrate/20260218000011_add_closed_at_to_turbo_chat_chats.rb
108
108
  - db/migrate/20260218000012_add_custom_role_key_to_chat_memberships.rb
109
- - db/migrate/20260218000013_add_invitation_accepted_to_chat_gem_chat_memberships.rb
110
- - lib/chat_gem.rb
111
- - lib/chat_gem/configuration.rb
112
- - lib/chat_gem/engine.rb
113
- - lib/chat_gem/model_extensions/chat_participant.rb
114
- - lib/chat_gem/moderation.rb
115
- - lib/chat_gem/permission.rb
116
- - lib/chat_gem/signals.rb
117
- - lib/chat_gem/version.rb
118
- - lib/generators/chat_gem/install/install_generator.rb
119
- - lib/generators/chat_gem/install/templates/chat_gem.rb
109
+ - db/migrate/20260218000013_add_invitation_accepted_to_turbo_chat_chat_memberships.rb
120
110
  - lib/generators/turbo_chat/install/install_generator.rb
121
111
  - lib/generators/turbo_chat/install/templates/turbo_chat.rb
122
- - lib/tasks/chat_gem_tasks.rake
123
112
  - lib/tasks/turbo_chat_tasks.rake
124
113
  - lib/turbo_chat.rb
114
+ - lib/turbo_chat/configuration.rb
115
+ - lib/turbo_chat/engine.rb
116
+ - lib/turbo_chat/model_extensions/chat_participant.rb
117
+ - lib/turbo_chat/moderation.rb
118
+ - lib/turbo_chat/permission.rb
119
+ - lib/turbo_chat/signals.rb
125
120
  - lib/turbo_chat/version.rb
126
121
  - turbo_chat.gemspec
127
122
  homepage: https://github.com/Haumer/turbo_chat
@@ -1,6 +0,0 @@
1
- //= link chat_gem/application.css
2
- //= link chat_gem/application.js
3
- //= link chat_gem/shared.js
4
- //= link chat_gem/messages.js
5
- //= link chat_gem/realtime.js
6
- //= link chat_gem/lifecycle_events.js
@@ -1,4 +0,0 @@
1
- //= require chat_gem/shared
2
- //= require chat_gem/messages
3
- //= require chat_gem/realtime
4
- //= require chat_gem/lifecycle_events
@@ -1,41 +0,0 @@
1
- module ChatGem
2
- class ApplicationController < ::ApplicationController
3
- layout "chat_gem/application"
4
-
5
- helper_method :current_chat_participant
6
-
7
- private
8
-
9
- def current_chat_participant
10
- method_name = :chat_current_participant
11
- raise NotImplementedError, "Define ##{method_name} in your host application controller" unless respond_to?(method_name, true)
12
-
13
- participant = send(method_name)
14
- return participant if participant.nil? || participant.respond_to?(:active_chat_memberships)
15
-
16
- raise ArgumentError, "##{method_name} must return a model that uses `acts_as_chat_participant`"
17
- end
18
-
19
- def permission_for(chat = nil)
20
- ChatGem.configuration.permission_adapter.new(current_chat_participant, chat)
21
- end
22
-
23
- def authorize_create_chat!
24
- return if permission_for.can_create_chat?
25
-
26
- head :forbidden
27
- end
28
-
29
- def authorize_view_chat!(chat)
30
- return if permission_for(chat).can_view_chat?
31
-
32
- head :forbidden
33
- end
34
-
35
- def authorize_post_message!(chat)
36
- return if permission_for(chat).can_post_message?
37
-
38
- head :forbidden
39
- end
40
- end
41
- end
@@ -1,12 +0,0 @@
1
- module ChatGem
2
- module ApplicationHelper
3
- HEX_COLOR_PATTERN = /\A#(?:\h{3}|\h{6}|\h{8})\z/.freeze
4
- EMOJI_ALIAS_PATTERN = /:([a-z0-9_+\-]{2,32}):/i.freeze
5
- MENTION_PATTERN = /(?<![[:alnum:]_])@[[:alpha:]][[:alnum:]_]{0,31}/.freeze
6
-
7
- include ChatGem::ApplicationHelper::ConfigSupport
8
- include ChatGem::ApplicationHelper::ParticipantSupport
9
- include ChatGem::ApplicationHelper::MessageRendering
10
- include ChatGem::ApplicationHelper::MentionSupport
11
- end
12
- end
@@ -1 +0,0 @@
1
- <%= render "chat_gem/chat_messages/#{chat_message.kind}", chat_message: chat_message %>
@@ -1,20 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>TurboChat</title>
5
- <%= csrf_meta_tags %>
6
- <%= csp_meta_tag %>
7
- <%= action_cable_meta_tag %>
8
- <% if respond_to?(:turbo_include_tags) %>
9
- <%= turbo_include_tags %>
10
- <% end %>
11
- <%= stylesheet_link_tag "chat_gem/application", "data-turbo-track": "reload" %>
12
- <%= javascript_include_tag "chat_gem/shared", "data-turbo-track": "reload", defer: true %>
13
- <%= javascript_include_tag "chat_gem/messages", "data-turbo-track": "reload", defer: true %>
14
- <%= javascript_include_tag "chat_gem/realtime", "data-turbo-track": "reload", defer: true %>
15
- <%= javascript_include_tag "chat_gem/lifecycle_events", "data-turbo-track": "reload", defer: true %>
16
- </head>
17
- <body>
18
- <%= yield %>
19
- </body>
20
- </html>
@@ -1,8 +0,0 @@
1
- class CreateChatGemChats < ActiveRecord::Migration[7.0]
2
- def change
3
- create_table :chat_gem_chats do |t|
4
- t.string :title, null: false
5
- t.timestamps
6
- end
7
- end
8
- end
@@ -1,6 +0,0 @@
1
- class AddClosedAtToChatGemChats < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :chat_gem_chats, :closed_at, :datetime
4
- add_index :chat_gem_chats, :closed_at
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- class AddInvitationAcceptedToChatGemChatMemberships < ActiveRecord::Migration[7.0]
2
- def change
3
- add_column :chat_gem_chat_memberships, :invitation_accepted, :boolean, null: false, default: true
4
- end
5
- end
@@ -1,29 +0,0 @@
1
- module ChatGem
2
- class Engine < ::Rails::Engine
3
- isolate_namespace ChatGem
4
-
5
- initializer "chat_gem.helpers" do
6
- ActiveSupport.on_load(:action_controller_base) do
7
- helper ChatGem::ApplicationHelper
8
- end
9
-
10
- ActiveSupport.on_load(:action_view) do
11
- include ChatGem::ApplicationHelper
12
- end
13
- end
14
-
15
- initializer "chat_gem.assets.precompile" do |app|
16
- next unless app.config.respond_to?(:assets)
17
- next unless app.config.assets.respond_to?(:precompile)
18
-
19
- app.config.assets.precompile += %w[
20
- chat_gem/application.css
21
- chat_gem/application.js
22
- chat_gem/shared.js
23
- chat_gem/messages.js
24
- chat_gem/realtime.js
25
- chat_gem/lifecycle_events.js
26
- ]
27
- end
28
- end
29
- end
@@ -1,3 +0,0 @@
1
- module ChatGem
2
- VERSION = "0.1.2"
3
- end
data/lib/chat_gem.rb DELETED
@@ -1,24 +0,0 @@
1
- require "chat_gem/version"
2
- require "turbo-rails"
3
- require "chat_gem/configuration"
4
- require "chat_gem/model_extensions/chat_participant"
5
- require "chat_gem/permission"
6
- require "chat_gem/moderation"
7
- require "chat_gem/signals"
8
- require "chat_gem/engine"
9
-
10
- module ChatGem
11
- class << self
12
- def configuration
13
- @configuration ||= ChatGem::Configuration.new
14
- end
15
-
16
- def configure
17
- yield(configuration)
18
- end
19
- end
20
-
21
- def self.table_name_prefix
22
- "chat_gem_"
23
- end
24
- end
@@ -1,18 +0,0 @@
1
- require "rails/generators/base"
2
-
3
- module ChatGem
4
- module Generators
5
- class InstallGenerator < Rails::Generators::Base
6
- source_root File.expand_path("templates", __dir__)
7
- desc "Installs TurboChat initializer and copies engine migrations"
8
-
9
- def copy_initializer
10
- template "chat_gem.rb", "config/initializers/chat_gem.rb"
11
- end
12
-
13
- def install_migrations
14
- rake "railties:install:migrations FROM=chat_gem"
15
- end
16
- end
17
- end
18
- end
@@ -1,36 +0,0 @@
1
- TurboChat.configure do |config|
2
- config.permission_adapter = TurboChat::Permission
3
- config.max_chat_participants = 10
4
- config.max_message_length = 1000
5
- config.message_history_limit = 200
6
- config.enable_mentions = true
7
- config.mention_filter_exclude_self = true
8
- config.mention_filter_hide_roles = true
9
- config.enable_emoji_aliases = true
10
- config.emoji_aliases = TurboChat::Configuration::DEFAULT_EMOJI_ALIASES.dup
11
- config.blocked_words = []
12
- config.blocked_words_action = :reject
13
- config.mention_mark_hex_color = nil
14
- config.mention_highlight_hex_color = nil
15
- config.own_message_hex_color = nil
16
- config.other_message_hex_color = nil
17
- config.role_message_hex_colors = {}
18
- config.show_timestamp = true
19
- config.show_role = false
20
- config.active_chat_window = 5.minutes
21
- config.emit_typing_events = false
22
- config.emit_message_events = false
23
- config.emit_mention_events = false
24
- config.emit_invitation_events = false
25
- config.emit_chat_lifecycle_events = false
26
- config.emit_moderation_events = false
27
- config.emit_blocked_words_events = false
28
- config.show_self_signals = false
29
- config.replace_signals_on_message_submit = false
30
- config.message_css_class_resolver = nil
31
- config.render_message_html = false
32
- config.message_html_tags = %w[a b br code em i li ol p pre strong ul]
33
- config.message_html_attributes = %w[href target rel class]
34
- config.timestamp_formatter = ->(timestamp, _chat_message) { I18n.l(timestamp.in_time_zone, format: :long) }
35
- config.role_formatter = ->(role, _chat_message) { role.to_s.humanize }
36
- end
@@ -1 +0,0 @@
1
- # Add engine-specific tasks here.