decidim 0.29.3 → 0.30.0.rc1

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/decidim.gemspec +1 -1
  3. data/docs/antora.yml +1 -1
  4. data/docs/modules/configure/assets/images/system-dashboard.png +0 -0
  5. data/docs/modules/configure/assets/images/system-log_in.png +0 -0
  6. data/docs/modules/configure/pages/environment_variables.adoc +25 -1
  7. data/docs/modules/configure/pages/initializer.adoc +27 -1
  8. data/docs/modules/configure/pages/system.adoc +145 -0
  9. data/docs/modules/customize/pages/menu.adoc +1 -1
  10. data/docs/modules/customize/pages/oauth.adoc +1 -1
  11. data/docs/modules/develop/assets/images/taxonomies.png +0 -0
  12. data/docs/modules/develop/pages/ai_tools/lang_detection_formatter.adoc +9 -0
  13. data/docs/modules/develop/pages/ai_tools/spam_detection_analyzer.adoc +20 -0
  14. data/docs/modules/develop/pages/ai_tools/spam_detection_service.adoc +25 -0
  15. data/docs/modules/develop/pages/ai_tools/spam_detection_strategy.adoc +43 -0
  16. data/docs/modules/develop/pages/ai_tools/spam_detection_trainer.adoc +83 -0
  17. data/docs/modules/develop/pages/ai_tools.adoc +12 -0
  18. data/docs/modules/develop/pages/classes/models.adoc +4 -3
  19. data/docs/modules/develop/pages/commentable.adoc +127 -0
  20. data/docs/modules/develop/pages/endorsable.adoc +6 -15
  21. data/docs/modules/develop/pages/share_tokens.adoc +153 -11
  22. data/docs/modules/develop/pages/taxonomies.adoc +476 -0
  23. data/docs/modules/install/pages/manual.adoc +4 -4
  24. data/docs/modules/services/pages/aitools.adoc +164 -0
  25. data/docs/modules/services/pages/index.adoc +1 -0
  26. data/docs/modules/services/pages/maps.adoc +3 -3
  27. data/lib/decidim/version.rb +1 -1
  28. data/package-lock.json +300 -167
  29. data/packages/browserslist-config/package.json +1 -1
  30. data/packages/core/package.json +4 -2
  31. data/packages/dev/package.json +1 -1
  32. data/packages/eslint-config/package.json +1 -1
  33. data/packages/prettier-config/package.json +1 -1
  34. data/packages/stylelint-config/package.json +1 -1
  35. data/packages/webpacker/package.json +1 -1
  36. data/packages/webpacker/src/override-config.js +11 -1
  37. metadata +55 -42
@@ -70,7 +70,7 @@ Given that some settings have been defined in the Administration Panel, for the
70
70
 
71
71
  === The "Endorse" buttons cell
72
72
 
73
- It normally appears in the resource detail view (show). At the action card, in right-side of the view.
73
+ It normally appears in the resource detail view (show), at the bottom of the resource content, but above the comments when comments are enabled.
74
74
  It allows users to endorse with any of their identities, the personal one, and/or their user_groups', if any.
75
75
  It also shows the current number of endorsements for this resource.
76
76
 
@@ -81,34 +81,25 @@ To render this button, `decidim-core` offers the `decidim/endorsement_buttons` c
81
81
  cell("decidim/endorsement_buttons", resource)
82
82
  ----
83
83
 
84
- This cell, renders the endorsements counter and the endorsement button by default. But it has the possibility to be invoked to render elements separately.
84
+ This cell will render the endorsement buttons depending on whether user endorsed the resource or not. The endorsements are labeled as *Likes*.
85
85
 
86
86
  [source,ruby]
87
87
  ----
88
88
  # By default the `show` method is invoked as usual
89
89
  # Renders `render_endorsements_count` and `render_endorsements_button` in a block.
90
- cell("decidim/endorsement_buttons", resource)
91
- # It is recommended to use the `endorsement_buttons_cell` helper method
92
- endorsement_buttons_cell(resource)
93
-
94
- # Renders the "Endorse" button
90
+ #
95
91
  # It takes into account:
96
92
  # - if endorsements are enabled
97
93
  # - if users are logged in
98
94
  # - if users can endorse with many identities (of their user_groups)
99
95
  # - if users require verification
100
- endorsement_buttons_cell(resource).render_endorsements_button
101
-
102
- # Renders the counter of endorsements that appears in card.
103
- endorsement_buttons_cell(resource).render_endorsements_count
104
-
105
- # Renders a button to perform the endorse action, but only with the personal identity of the user. It does not take into account if the user belongs to any user group.
106
- endorsement_buttons_cell(resource).render_user_identity_endorse_button
96
+ #
97
+ cell("decidim/endorsement_buttons", resource)
107
98
  ----
108
99
 
109
100
  === The list of endorsers
110
101
 
111
- The `Decidim::EndorsersListCell` renders the list of endorsers of a resource. It is usually rendered in the show of the resource, just upside the comments.
102
+ The `Decidim::EndorsersListCell` renders the list of endorsers of a resource. It is usually rendered in the show page of the resource, just upside the comments. Additionally, this cell also renders the pop-up required to view the endorsers of a certain resource.
112
103
 
113
104
  [source,ruby]
114
105
  ----
@@ -1,6 +1,6 @@
1
1
  = Share tokens
2
2
 
3
- Share tokens can be assigned to any model to provide a system to share unpublished resources with expirable and manageable tokens.
3
+ Share tokens can be assigned to any model to provide a system to share unpublished resources with expiration dates through the creation/destruction of tokens.
4
4
 
5
5
  A share token is created by a user with an expiration time, and can be added as a query param to access otherwise restricted locations.
6
6
 
@@ -12,7 +12,7 @@ The model must `include Decidim::ShareableWithToken` and implement `shareable_ur
12
12
  ----
13
13
  # Public: Public URL for your_resource with given share token as query parameter
14
14
  def shareable_url(share_token)
15
- your_resource_public_path(self, share_token: share_token.token)
15
+ your_resource_public_url(self, share_token: share_token.token)
16
16
  end
17
17
  ----
18
18
 
@@ -31,27 +31,169 @@ return unless token.present?
31
31
  allow! if Decidim::ShareToken.use!(token_for: your_resource, token: token)
32
32
  ----
33
33
 
34
+ Note that, if you are using a controller who is inheriting from `Decidim::ApplicationController`, you do not need to include the `:share_token` in the context when calling methods like `enforce_permission_to`, as it is already included in the `Decidim::NeedsPermissions` class through the method `store_share_token`.
35
+
34
36
  == Manage tokens
35
37
 
36
- Render the partial `decidim-admin/app/views/decidim/admin/share_tokens/_share_tokens.html.erb` inside a view, with:
38
+ By default, participatory spaces like process, assemblies, conferences and initiatives are configured to have share tokens, as well as the individual components that are included in them. Participatory spaces have a "Share tokens" tab in the admin view, where you can create new tokens, see the list of existing ones, and revoke them.
39
+ Tokens can also be managed in the components view similarly as other resources to give pre-access (with and action icon like permissions for instance).
40
+
41
+ Tokens generated for a participatory space are valid for all the components included in it (regardless of their publication status), and tokens generated for a component are valid for that component only.
42
+
43
+ == Implementation for participatory spaces
44
+
45
+ In order to implement share tokens for a participatory spaces, you need to:
46
+
47
+ === 1. Routes
48
+
49
+ Add the `share_tokens` CRUD routes in your `admin_engine.rb` file:
50
+
51
+ [source,ruby]
52
+ ----
53
+ scope "/assemblies/:assembly_slug" do
54
+ ...
55
+ resources :assembly_share_tokens, except: [:show], path: "share_tokens"
56
+ ...
57
+ end
58
+ ----
59
+
60
+ === 2. Controller
61
+
62
+ Add the controller for the participatory space, it only requires to inherit from `Decidim::Admin::ShareTokensController` and define the `resource` method to return the participatory space:
63
+
64
+ [source,ruby]
65
+ ----
66
+ # frozen_string_literal: true
67
+
68
+ module Decidim
69
+ module Assemblies
70
+ module Admin
71
+ # This controller allows sharing unpublished things.
72
+ # It is targeted for customizations for sharing unpublished things that lives under
73
+ # an assembly.
74
+ class AssemblyShareTokensController < Decidim::Admin::ShareTokensController
75
+ include Concerns::AssemblyAdmin
76
+
77
+ def resource
78
+ current_assembly
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ ----
85
+
86
+ === 3. Menu entry
87
+
88
+ Add the menu entry for the share tokens in the participatory space admin view. In Decidim we do this in the `menu.rb` file for each participatory space:
89
+
90
+ [source,ruby]
91
+ ----
92
+ Decidim.menu :admin_assembly_menu do |menu|
93
+ ...
94
+ menu.add_item :assembly_share_tokens,
95
+ I18n.t("menu.share_tokens", scope: "decidim.admin"),
96
+ decidim_admin_assemblies.assembly_share_tokens_path(current_participatory_space),
97
+ active: is_active_link?(decidim_admin_assemblies.assembly_share_tokens_path(current_participatory_space)),
98
+ icon_name: "share-line",
99
+ if: allowed_to?(:read, :share_tokens, current_participatory_space:)
100
+ ...
101
+ end
102
+ ----
103
+
104
+ === 4. Model
105
+
106
+ Ensure your participatory space model includes the `Decidim::ShareableWithToken` module and implements the `shareable_url` method:
107
+
108
+ [source,ruby]
109
+ ----
110
+ module Decidim
111
+ class Assembly < ApplicationRecord
112
+ ...
113
+ include Decidim::ShareableWithToken
114
+ ...
115
+ def shareable_url(share_token)
116
+ EngineRouter.main_proxy(self).assembly_url(self, share_token: share_token.token)
117
+ end
118
+ ...
119
+ end
120
+ end
121
+ ----
122
+
123
+ === 5. Permissions
124
+
125
+ Add the permissions logic to the participatory space controller in the `permissions.rb` file:
126
+
127
+ For admin controllers:
37
128
 
38
129
  [source,ruby]
39
130
  ----
40
- locals: { share_tokens: your_share_tokens_variable }
131
+ allow! if permission_action.subject == :share_tokens
132
+ ----
133
+
134
+ For frontend controllers:
135
+
136
+ [source,ruby]
137
+ ----
138
+ token = context[:share_token]
139
+
140
+ return unless token.present?
141
+
142
+ allow! if Decidim::ShareToken.use!(token_for: current_assembly, token: token)
41
143
  ----
42
144
 
43
- to let admins see and manage tokens for that resource.
145
+ == Implementation for components
44
146
 
45
- == Link to url with token
147
+ Components all inherit from `Decidim::Component`, so they already have the `Decidim::ShareableWithToken` module included. But you still need to do some steps:
46
148
 
47
- Implement a `share` action (see below) in the resource controller (admin scope), redirecting to a url with a newly generated token, so you can call `share_my_resource_url`.
149
+ === 1. Routes
150
+
151
+ Add the `share_tokens` CRUD routes in your `admin_engine.rb` file:
48
152
 
49
153
  [source,ruby]
50
154
  ----
51
- def share
52
- @your_resource = YourResource.find(params[:id]) # or whatever
53
- share_token = @your_resource.share_tokens.create!(user: current_user, organization: current_organization)
155
+ scope "/assemblies/:assembly_slug" do
156
+ ...
157
+ resources :components do
158
+ ...
159
+ resources :component_share_tokens, except: [:show], path: "share_tokens", as: "share_tokens"
160
+ ...
161
+ end
162
+ end
163
+ ----
164
+
165
+ === 2. Controller
166
+
167
+ Add the controller for the component, it only requires to inherit from `Decidim::Admin::ShareTokensController` and define the `resource` method to return the component:
54
168
 
55
- redirect_to share_token.url
169
+ [source,ruby]
170
+ ----
171
+ # frozen_string_literal: true
172
+
173
+ module Decidim
174
+ module Assemblies
175
+ module Admin
176
+ # This controller allows sharing unpublished things.
177
+ # It is targeted for customizations for sharing unpublished things that lives under
178
+ # an assembly.
179
+ class ComponentShareTokensController < Decidim::Admin::ShareTokensController
180
+ include Concerns::AssemblyAdmin
181
+
182
+ def resource
183
+ @resource ||= current_participatory_space.components.find(params[:component_id])
184
+ end
185
+ end
186
+ end
187
+ end
56
188
  end
57
189
  ----
190
+
191
+ === 3. Permissions
192
+
193
+ Similarly, add the same permissions logic to the component controller in the `permissions.rb` file as for participatory spaces.
194
+
195
+
196
+ == Other implementations
197
+
198
+ You can implement share tokens for any other model by following the same steps as for participatory spaces and components.
199
+ In that case, however, you might have to override some methods from the `Decidim::Admin::ShareTokensController` to adapt them to your model (check the source code for details).