audiences 1.5.4 → 1.6

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.
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Unreleased
2
2
 
3
+ # Version 1.6 (2025-03-19)
4
+
5
+ - Prepackaged audiences-react in UJS [#510](https://github.com/powerhome/audiences/pull/510)
6
+
3
7
  # Version 1.5.4 (2024-12-19)
4
8
 
5
9
  - Fix `authenticate` / `authentication` configuration [#481](https://github.com/powerhome/audiences/pull/481)
data/docs/README.md CHANGED
@@ -26,12 +26,19 @@ $ gem install audiences
26
26
 
27
27
  ### Creating/Managing Audiences
28
28
 
29
- An audience is tied to an owning model within your application. In this document, we'll use a `Team` model as an example. To create audiences for a team using `audiences-react`, render an audiences editor for your model.
29
+ An audience is tied to an owning model within your application. In this document, we'll use a `Team` model as an example. To create audiences for a team use the `audiences-ujs` package bundled with the gem. Render the audiences editor in your view as follows:
30
30
 
31
- This can be done with an unobtrusive JS renderer like `react-rails` or a custom one as shown in [our dummy app](../audiences/spec/dummy/app/frontend/entrypoints/application.js). The editor requires two arguments:
31
+ ```erb
32
+ <%= javascript_include_tag "audiences-ujs", defer: true %>
33
+ <%= render_audiences_editor(@example_owner.members_context) %>
34
+ ```
35
+
36
+ This eliminates the need for `audiences-react` as a separate dependency.
37
+
38
+ ### Required Arguments:
39
+ - **Context**: Example: `owner.members_context`
32
40
 
33
- - The audiences mount point: `audiences.root_url` URL helper
34
- - The context signed key: I.e.: `owner.members_signed_key` or `Audiences::Context.for(owner, relation:).signed_key`
41
+ For more details, refer to [editor_helper](../lib/audiences/editor_helper.rb).
35
42
 
36
43
  ### Configuring Audiences
37
44
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Audiences
4
+ module EditorHelper
5
+ def render_audiences_editor(context, html_class: "audiences-editor",
6
+ uri: Audiences::Engine.routes.url_helpers.root_path)
7
+ content_tag(:div, "",
8
+ data: {
9
+ react_class: "AudiencesEditor",
10
+ audiences_uri: uri,
11
+ audiences_context: context.signed_key,
12
+ },
13
+ class: html_class)
14
+ end
15
+ end
16
+ end
@@ -10,6 +10,10 @@ module Audiences
10
10
  class Engine < ::Rails::Engine
11
11
  isolate_namespace Audiences
12
12
 
13
+ initializer "audiences.assets.precompile" do |app|
14
+ app.config.assets.precompile += %w[audiences-ujs.js] if app.config.respond_to?(:assets)
15
+ end
16
+
13
17
  initializer "audiences.model" do
14
18
  if Audiences.config.identity_class
15
19
  ActiveSupport.on_load(:active_record) do
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Audiences
4
+ class Railtie < Rails::Railtie
5
+ initializer "audiences.editor_helper" do
6
+ ActiveSupport.on_load(:action_view) do
7
+ require "audiences/editor_helper"
8
+ include Audiences::EditorHelper
9
+ end
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Audiences
4
- VERSION = "1.5.4"
4
+ VERSION = "1.6"
5
5
  end
data/lib/audiences.rb CHANGED
@@ -36,3 +36,4 @@ module_function
36
36
  end
37
37
 
38
38
  require "audiences/configuration"
39
+ require "audiences/railtie"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audiences
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.4
4
+ version: '1.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-02-07 00:00:00.000000000 Z
11
+ date: 2025-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -33,6 +33,7 @@ extensions: []
33
33
  extra_rdoc_files: []
34
34
  files:
35
35
  - Rakefile
36
+ - app/assets/builds/audiences-ujs.js
36
37
  - app/controllers/audiences/application_controller.rb
37
38
  - app/controllers/audiences/contexts_controller.rb
38
39
  - app/controllers/audiences/scim_proxy_controller.rb
@@ -61,9 +62,11 @@ files:
61
62
  - docs/README.md
62
63
  - lib/audiences.rb
63
64
  - lib/audiences/configuration.rb
65
+ - lib/audiences/editor_helper.rb
64
66
  - lib/audiences/engine.rb
65
67
  - lib/audiences/model.rb
66
68
  - lib/audiences/notifications.rb
69
+ - lib/audiences/railtie.rb
67
70
  - lib/audiences/scim.rb
68
71
  - lib/audiences/scim/client.rb
69
72
  - lib/audiences/scim/resource.rb
@@ -93,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
96
  - !ruby/object:Gem::Version
94
97
  version: '0'
95
98
  requirements: []
96
- rubygems_version: 3.5.23
99
+ rubygems_version: 3.5.16
97
100
  signing_key:
98
101
  specification_version: 4
99
102
  summary: Audiences system