decidim 0.30.1 → 0.31.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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -9
  3. data/decidim-core/lib/decidim/{webpacker → shakapacker}/configuration.rb +4 -4
  4. data/decidim-core/lib/decidim/{webpacker → shakapacker}/runner.rb +3 -3
  5. data/decidim-core/lib/decidim/shakapacker/shakapacker.rb +8 -0
  6. data/decidim-core/lib/decidim/{webpacker → shakapacker}/shakapacker.yml +3 -1
  7. data/decidim-core/lib/decidim/{webpacker → shakapacker}/webpack/custom.js +1 -1
  8. data/decidim.gemspec +1 -1
  9. data/docs/antora.yml +1 -1
  10. data/docs/modules/configure/pages/environment_variables.adoc +184 -35
  11. data/docs/modules/configure/pages/index.adoc +2 -3
  12. data/docs/modules/configure/pages/initializer.adoc +45 -31
  13. data/docs/modules/configure/pages/system.adoc +3 -3
  14. data/docs/modules/customize/assets/images/social-share-modal-default.png +0 -0
  15. data/docs/modules/customize/pages/admin_filters.adoc +2 -2
  16. data/docs/modules/customize/pages/content_security_policy.adoc +1 -1
  17. data/docs/modules/customize/pages/images.adoc +1 -1
  18. data/docs/modules/customize/pages/index.adoc +1 -0
  19. data/docs/modules/customize/pages/javascript.adoc +5 -18
  20. data/docs/modules/customize/pages/localization.adoc +75 -0
  21. data/docs/modules/customize/pages/oauth.adoc +12 -0
  22. data/docs/modules/customize/pages/social_shares.adoc +0 -3
  23. data/docs/modules/customize/pages/styles.adoc +3 -16
  24. data/docs/modules/develop/assets/attachments/grafana/metadecidim-csv.json +1106 -0
  25. data/docs/modules/develop/assets/attachments/grafana/metadecidim-graphql.json +632 -0
  26. data/docs/modules/develop/assets/images/grafana/create_account_confirm.png +0 -0
  27. data/docs/modules/develop/assets/images/grafana/create_account_form.png +0 -0
  28. data/docs/modules/develop/assets/images/grafana/create_account_setup.png +0 -0
  29. data/docs/modules/develop/assets/images/grafana/dashboard_example_csv.png +0 -0
  30. data/docs/modules/develop/assets/images/grafana/dashboard_example_graphql.png +0 -0
  31. data/docs/modules/develop/assets/images/grafana/dashboard_import.png +0 -0
  32. data/docs/modules/develop/assets/images/grafana/dashboard_import_csv.png +0 -0
  33. data/docs/modules/develop/assets/images/grafana/dashboards.png +0 -0
  34. data/docs/modules/develop/assets/images/grafana/homepage.png +0 -0
  35. data/docs/modules/develop/pages/api.adoc +12 -2
  36. data/docs/modules/develop/pages/classes/models.adoc +2 -2
  37. data/docs/modules/develop/pages/commentable.adoc +9 -11
  38. data/docs/modules/develop/pages/components.adoc +10 -10
  39. data/docs/modules/develop/pages/elections.adoc +101 -0
  40. data/docs/modules/develop/pages/fixing_locales.adoc +7 -12
  41. data/docs/modules/develop/pages/grafana.adoc +100 -0
  42. data/docs/modules/develop/pages/likeable.adoc +106 -0
  43. data/docs/modules/develop/pages/machine_translations.adoc +6 -2
  44. data/docs/modules/develop/pages/maintainers/releases.adoc +40 -202
  45. data/docs/modules/develop/pages/maps.adoc +8 -8
  46. data/docs/modules/develop/pages/modules.adoc +1 -1
  47. data/docs/modules/develop/pages/notifications.adoc +27 -56
  48. data/docs/modules/develop/pages/permissions.adoc +19 -19
  49. data/docs/modules/develop/pages/share_tokens.adoc +2 -2
  50. data/docs/modules/develop/pages/taxonomies.adoc +1 -15
  51. data/docs/modules/install/pages/checklist.adoc +2 -1
  52. data/docs/modules/install/pages/index.adoc +7 -12
  53. data/docs/modules/install/pages/manual.adoc +27 -35
  54. data/docs/modules/install/pages/update.adoc +0 -2
  55. data/docs/modules/install/partials/version_matrix.adoc +4 -2
  56. data/docs/modules/services/pages/activestorage.adoc +4 -3
  57. data/docs/modules/services/pages/aitools.adoc +0 -2
  58. data/docs/modules/services/pages/etherpad.adoc +5 -20
  59. data/docs/modules/services/pages/machine_translation.adoc +38 -0
  60. data/docs/modules/services/pages/maps.adoc +8 -66
  61. data/docs/modules/services/pages/pdf.adoc +33 -0
  62. data/docs/modules/services/pages/sms.adoc +6 -7
  63. data/docs/modules/services/pages/social_providers.adoc +1 -1
  64. data/docs/modules/services/pages/timestamp.adoc +47 -0
  65. data/lib/decidim/version.rb +1 -1
  66. data/package-lock.json +2413 -2624
  67. data/package.json +3 -2
  68. data/packages/browserslist-config/package.json +1 -1
  69. data/packages/core/package.json +2 -3
  70. data/packages/dev/package.json +2 -2
  71. data/packages/eslint-config/package.json +1 -1
  72. data/packages/prettier-config/package.json +1 -1
  73. data/packages/stylelint-config/package.json +1 -1
  74. data/packages/webpacker/package.json +3 -2
  75. data/packages/webpacker/src/loaders/decidim-sass-loader.js +18 -11
  76. metadata +68 -54
  77. data/docs/modules/develop/pages/endorsable.adoc +0 -110
  78. data/docs/modules/develop/pages/guide_migrate_webpacker_app.adoc +0 -257
  79. data/docs/modules/develop/pages/guide_migrate_webpacker_module.adoc +0 -132
  80. data/docs/modules/develop/pages/metrics.adoc +0 -123
  81. data/docs/modules/develop/pages/troubleshooting_metrics.adoc +0 -255
  82. /data/decidim-core/lib/decidim/{webpacker → shakapacker}/esbuild.config.js +0 -0
  83. /data/decidim-core/lib/decidim/{webpacker → shakapacker}/postcss.config.js +0 -0
  84. /data/decidim-core/lib/decidim/{webpacker → shakapacker}/tsconfig.json +0 -0
  85. /data/decidim-core/lib/decidim/{webpacker → shakapacker}/webpack/.modernizrrc +0 -0
  86. /data/decidim-core/lib/decidim/{webpacker → shakapacker}/webpack/webpack.config.js +0 -0
@@ -1,110 +0,0 @@
1
- = Endorsable
2
-
3
- == Things can be endorsable
4
-
5
- `Endorsable` is a feature to allow participants to promote (reivindicate, etc.) resources in the platform to their followers.
6
-
7
- When endorsing an element the endorsements counter for this element is increased and a notification to all the followers of the participant is sent.
8
-
9
- Participants can endorse with their own identity or with the identify of the `user_groups` they belong to. Each endorsing identity on its own will increment the endorsements counter by one.
10
-
11
- == Data model
12
-
13
- A `decidim_endorsements` table registers each endorsement that each identity gives to each element. This is, one endorsable has many endorsements, and each endorsement belongs to one endorsable.
14
- For performance, an endorsable has a counter cache of endorsements.
15
-
16
- [source,ascii]
17
- ----
18
- +----------------------+
19
- | Decidim::Endorsable |
20
- | ((Proposal,...)) | +-------------+
21
- +----------------------+ 0..N +--------------------+ +--+Decidim::User|
22
- |-has_many endorsements|-------+Decidim::Endorsement| | +-------------+
23
- |#counter cache column | +--------------------+ |
24
- |-endorsements_counter | |-author: may be a |<--+
25
- +----------------------+ | user or a | |
26
- | user_group | | +------------------+
27
- +--------------------+ +--+Decidim::UserGroup|
28
- +------------------+
29
- ----
30
-
31
- Thus, each endorsable must have the endorsements counter cache column.
32
- This is an example migration to add the endorsements counter cache column to a resource:
33
-
34
- [source,ruby]
35
- ----
36
- class AddEndorsementsCounterCacheToProposals < ActiveRecord::Migration[5.2]
37
- def change
38
- add_column :decidim_proposals_proposals, :endorsements_count, :integer, null: false, default: 0
39
- end
40
- end
41
- ----
42
-
43
- == Administration Panel
44
-
45
- It is a good practice to give the opportunity to the admin to switch Endorsements on and off.
46
-
47
- There are two switches that are normally defined in the manifest of the element in the following way (usually this would be at component.rb in a Decidim engine):
48
-
49
- [source,ruby]
50
- ----
51
- settings.attribute :endorsements_enabled, type: :boolean, default: true
52
- settings.attribute :endorsements_blocked, type: :boolean
53
- ----
54
-
55
- * `endorsements_enabled`: when enabled endorsement functionality appears in the public views, when disabled, this functionality is hidden.
56
- * `endorsements_blocked`: when blocked, the counter of endorsements is visible but no more endorsements can be added or withdrawn, the button is hidden.
57
-
58
- == Permissions
59
-
60
- In some cases, it may be interesting to require the user to be verified in order to be able to endorse. To do so, add the endorse action to the component manifest:
61
-
62
- [source,ruby]
63
- ----
64
- component.actions = %w(endorse vote create withdraw amend)
65
- ----
66
-
67
- Given that some settings have been defined in the Administration Panel, for the user to have permissions to endorse endorsements should be enabled and not blocked.
68
-
69
- == Public view
70
-
71
- === The "Endorse" buttons cell
72
-
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
- It allows users to endorse with any of their identities, the personal one, and/or their user_groups', if any.
75
- It also shows the current number of endorsements for this resource.
76
-
77
- To render this button, `decidim-core` offers the `decidim/endorsement_buttons` cell. It is strongly recommended to use this cell to make new resources endorsable.
78
-
79
- [source,ruby]
80
- ----
81
- cell("decidim/endorsement_buttons", resource)
82
- ----
83
-
84
- This cell will render the endorsement buttons depending on whether user endorsed the resource or not. The endorsements are labeled as *Likes*.
85
-
86
- [source,ruby]
87
- ----
88
- # By default the `show` method is invoked as usual
89
- # Renders `render_endorsements_count` and `render_endorsements_button` in a block.
90
- #
91
- # It takes into account:
92
- # - if endorsements are enabled
93
- # - if users are logged in
94
- # - if users require verification
95
- #
96
- cell("decidim/endorsement_buttons", resource)
97
- ----
98
-
99
- === The list of endorsers
100
-
101
- 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.
102
-
103
- [source,ruby]
104
- ----
105
- # to render the list of endorsers, the cell requires the endorsable resource, and the current user
106
- cell "decidim/endorsers_list", resource
107
- # or using the helper
108
- endorsers_list_cell(resource)
109
- ----
110
-
@@ -1,257 +0,0 @@
1
- = Migrate to Webpacker an instance app
2
-
3
- In order to migrate an existing Decidim app to Webpacker, there are a few changes your need to run in your code.
4
-
5
- NOTE: this recipe might not work for all the cases, it tries to cover the generic scenarios. If you find yourself with a complex scenario and want to improve this guide feel free to open a PR to complete the guide.
6
-
7
- == About Webpacker
8
-
9
- It is recommended to understand how Webpacker works. More information:
10
-
11
- * https://github.com/rails/webpacker#usage[Webpacker README]
12
- * https://edgeguides.rubyonrails.org/webpacker.html[Rails Webpacker guide]
13
-
14
- == Requirements
15
-
16
- Before starting the migration, please check you have the following dependencies installed:
17
-
18
- - Node.js version 16.9.x (this version is mandatory)
19
- - Npm version 7.21.x (it works with other versions, but this is the recommended)
20
- - Decidim updated to at least v0.25.0.rc4
21
-
22
- == Guide
23
-
24
- === Add Webpacker to the application
25
-
26
- Follow these steps. If you want more information you can find it at the https://github.com/rails/webpacker#installation[Webpacker installation guide].
27
-
28
- * Install it
29
-
30
- [source,console]
31
- ----
32
- bundle exec rails webpacker:install
33
- ----
34
-
35
- * Install Decidim webpacker custom code
36
-
37
- [source,console]
38
- ----
39
- bundle exec rails decidim:webpacker:install
40
- ----
41
-
42
- This task do a few steps to allow the Rails instance to have a webpacker instance sharing the code between itself and Decidim gem.
43
-
44
- This task is automatically performed every time decidim is updated, to get the latest Webpack configuration. This happens when you run the `decidim:upgrade` task.
45
-
46
- === Copy Decidim custom CSS and JavaScript
47
-
48
- `webpacker:install` task should have created to you the following dirs structure:
49
-
50
- [source,console]
51
- ----
52
- app/packs:
53
- ├── entrypoints
54
- └── src
55
- └── stylesheets
56
- └── images
57
- ----
58
-
59
- If it is not the case you must create it. Then, copy Decidim customizable assets
60
-
61
- * Copy the file https://github.com/decidim/decidim/blob/develop/decidim-generators/lib/decidim/generators/app_templates/decidim_application.js[decidim_application.js] to `app/packs/src/decidim/decidim_application.js`
62
- * Copy the file https://github.com/decidim/decidim/blob/develop/decidim-generators/lib/decidim/generators/app_templates/decidim_application.scss[decidim_application.scss] to `app/packs/stylesheets/decidim/decidim_application.scss`
63
- * Copy the file https://github.com/decidim/decidim/blob/develop/decidim-generators/lib/decidim/generators/app_templates/_decidim-settings.scss[_decidim-settings.scss] to `app/packs/stylesheets/decidim/_decidim-settings.scss`
64
-
65
- These files are hooked into Decidim packs (specifically into decidim-core pack) and will be automatically included inside that pack when compiled.
66
-
67
- You can download these files directly with these commands:
68
-
69
- [source,console]
70
- ----
71
- mkdir -p app/packs/src/decidim app/packs/stylesheets/decidim app/packs/images
72
- touch app/packs/src/decidim/.keep app/packs/stylesheets/decidim/.keep app/packs/images/.keep
73
- wget https://raw.githubusercontent.com/decidim/decidim/develop/decidim-generators/lib/decidim/generators/app_templates/decidim_application.js -O app/packs/src/decidim/decidim_application.js
74
- wget https://raw.githubusercontent.com/decidim/decidim/develop/decidim-generators/lib/decidim/generators/app_templates/decidim_application.scss -O app/packs/stylesheets/decidim/decidim_application.scss
75
- wget https://raw.githubusercontent.com/decidim/decidim/develop/decidim-generators/lib/decidim/generators/app_templates/_decidim-settings.scss -O app/packs/stylesheets/decidim/_decidim-settings.scss
76
- ----
77
-
78
- === Migrate images
79
-
80
- Copy the existing images from `app/assets/images` to `app/packs/images`. Images will be available at `/media/images/image.png`
81
-
82
- [source,console]
83
- ----
84
- cp -rp app/assets/images/* app/packs/images/
85
- ----
86
-
87
- For instance, add the image "app/packs/images/test.png" in a view using the helper:
88
-
89
- [source,erb]
90
- ----
91
- <%= image_pack_tag "media/images/test.png" %>
92
- ----
93
-
94
- Note that, by default, all images are flattened in a single directory (any subdirectory structure is lost when requiring an image using the `image_pack_tag`).
95
- So, if you have a file in a subdirectory such as `app/packs/images/subfolder/test.png`, you still need to call for the image using `image_pack_tag "media/images/test.png"`
96
-
97
- === Migrate stylesheets
98
-
99
- Existing stylesheets should be moved from `app/assets/stylesheets` to `app/packs/stylesheets` and imported with `@import` into `decidim_application.scss`. Take into account that you might need to adjust a bit the paths of the `@import` to adjust them to the new locations.
100
-
101
- If that CSS file is replacing a Decidim file, there is no need to add it to `decidim_application.scss`.
102
-
103
- If any of the CSS is re-defining CSS vars add them to `_decidim-settings.scss`.
104
-
105
- === Migrate javascripts
106
-
107
- Existing javascripts should be moved from `app/assets/javascripts` to `app/packs/src` and imported with `import` into `decidim_application.js`. Take into account that you might need to adjust a bit the paths of the `import` to adjust them to the new locations.
108
-
109
- If that JS file is replacing a Decidim file, there is no need to add it to `decidim_application.js`
110
-
111
- === Update Rails helpers
112
-
113
- `javascript_include_tag` and `stylesheet_link_tag` have been replaced by `javascript_pack_tag` and `stylesheet_pack_tag`. This only needs to be done if you are modifying the `application.html` file or partial in your layout.
114
-
115
- For images, if they are in `app/packs/images` you need to replace `ìmage_tag` with `image_pack_tag`.
116
-
117
- === Migrate vendorized files and gems
118
-
119
- Sometimes assets are included in `vendor/assets/` folder or imported from gems. For each specific one you should check:
120
-
121
- 1. if the asset is a javascript that is available as npm package the recommendation is to add it to package.json with `npm install`. If it is not available you might want to copy it to `app/packs/src` and import it.
122
- 2. if the asset is a stylesheet it should be copied to `app/packs/stylesheets` and imported with `@import...` from `_decidim-settings.scss`. Alternatively you can use the optional asset includes as described below to include these in the Decidim main SCSS files.
123
-
124
- === Migrate uploads to ActiveStorage
125
-
126
- The old method (CarrierWave) to handle user uploads has changed, now it uses ActiveStorage.
127
- This means that all the old files need to be migrated to the new system. Use the following rake task to perform this task:
128
-
129
- [source,console]
130
- ----
131
- RAILS_ENV=production bin/rails decidim:active_storage_migrations:migrate_from_carrierwave_to_active_storage
132
- ----
133
-
134
- === Optional asset includes
135
-
136
- Decidim Webpacker provides a new configuration convention that allows you to add extra configurations for webpacker using a configuration file named `config/assets.rb`. Within this file, you have the following API methods available:
137
-
138
- [source,ruby]
139
- ----
140
- # frozen_string_literal: true
141
- # This file is located at `config/assets.rb` of your module.
142
-
143
- # Define the base path of your module. Please note that `Rails.root` may not be
144
- # used because we are not inside the Rails environment when this file is loaded.
145
- base_path = File.expand_path("..", __dir__)
146
-
147
- # If you want to import some extra SCSS files in the Decidim main SCSS file
148
- # without adding any extra stylesheet inclusion tags, you can use the following
149
- # method to register the stylesheet import for the main application. This would
150
- # include an SCSS file at `app/packs/stylesheets/your_app_extensions.scss` into
151
- # the Decidim's main SCSS file.
152
- Decidim::Webpacker.register_stylesheet_import("stylesheets/your_app_extensions")
153
-
154
- # If you want to do the same but include the SCSS file for the admin panel's
155
- # main SCSS file, you can use the following method.
156
- Decidim::Webpacker.register_stylesheet_import("stylesheets/your_app_admin_extensions", group: :admin)
157
- ----
158
-
159
- === Remove Sprockets references
160
-
161
- The completely remove Sprockets references from your application:
162
-
163
- * Review your Gemfile and remove any reference to `sprockets` and `sassc-rails`
164
- * Remove `config/initializers/assets.rb`
165
- * Remove `app/assets` folder
166
- * In `config/application.rb` replace:
167
-
168
- [source,ruby]
169
- ----
170
- require 'rails/all'
171
- ----
172
-
173
- with:
174
-
175
- [source,ruby]
176
- ----
177
- require "decidim/rails"
178
- # Add the frameworks used by your app that are not loaded by Decidim.
179
- # require "action_cable/engine"
180
- # require "action_mailbox/engine"
181
- # require "action_text/engine"
182
- ----
183
-
184
- * In `config/environments/*.rb` remove any line containing `config.assets.*` (i.e `config.assets.debug = true`)
185
-
186
- === Help Decidim to know the application's assets folder
187
-
188
- To prevent Zeitwerk issues trying to autoload the non-ruby application folders, modify the `config/initializers/decidim.rb` file to include the following:
189
-
190
- [source,ruby]
191
- ---
192
- # Inform Decidim about the assets folder
193
- Decidim.register_assets_path File.expand_path("app/packs", Rails.application.root)
194
- ---
195
-
196
- === Deployment
197
-
198
- The deployment needs to be updated to manually run `npm install` before assets are precompiled.
199
-
200
- In the case of Capistrano this can be done with a before hook (can be added at the end of your `config/deploy.rb` file):
201
-
202
- [source,ruby]
203
- ----
204
- namespace :deploy do
205
- desc "Decidim webpacker configuration"
206
- task :decidim_webpacker_install do
207
- on roles(:all) do
208
- within release_path do
209
- execute :npm, "install"
210
- end
211
- end
212
- end
213
-
214
- before "deploy:assets:precompile", "deploy:decidim_webpacker_install"
215
- end
216
- ----
217
-
218
- Also, in the case of Capistrano it is interesting to add to the shared_paths the following folders:
219
-
220
- * `storage` *IMPORTANT!*
221
- * `tmp/webpacker-cache`
222
- * `node_modules`
223
- * `public/decidim-packs`
224
-
225
- == Troubleshooting
226
-
227
- If you have the following exception when executing `bundle exec rails decidim:upgrade` or `bundle exec rails decidim:webpacker:install`
228
-
229
- [source,console]
230
- ----
231
- npm ERR! code ERESOLVE
232
- npm ERR! ERESOLVE unable to resolve dependency tree
233
- npm ERR!
234
- ----
235
-
236
- Then you need to check again that you are using the correct Node.js and NPM versions.
237
-
238
- In some case it might be that some packages are not well resolved when installing NPM modules. If you get messages like:
239
-
240
- [source,console]
241
- ----
242
- ...
243
- [webpack-cli] Error: Cannot find module '@rails/webpacker'
244
- ...
245
- ----
246
-
247
- These might be due some kind of corruption in your `package-lock.json` file, you can try either to remove this file and recreate it with `npm install` or to add the package `@rails/webpacker` manually in your `package.json` file next to the `@decidim/webpacker` package:
248
-
249
- [source,json]
250
- ----
251
- ...
252
- "@decidim/webpacker": "^0.25.2",
253
- "@rails/webpacker": "^6.0.0-rc.5",
254
- ...
255
- ----
256
-
257
- Then execute `npm install`.
@@ -1,132 +0,0 @@
1
- = Migrate to Webpacker a Decidim module
2
-
3
- Decidim modules are included to Decidim apps as gems. Since the introduction of Webpacker to manage and compile assets in Decidim, there are some changes required to make modules compatible with Decidim
4
-
5
- == About Webpacker
6
-
7
- It is recommended to understand how Webpacker works. More information:
8
-
9
- * https://github.com/rails/webpacker#usage
10
- * https://edgeguides.rubyonrails.org/webpacker.html
11
-
12
- == Overview
13
-
14
- The recommended way to import assets from a gem in a Rails app using Webpacker is to publish a package in npmjs.org and include it in the package.json via `npm install`. Then the assets are available to Webpack via node_modules/ folder
15
-
16
- Once created, you should update the instructions to install the module and add the step to add the assets with npm.
17
-
18
- == Folder migration
19
-
20
- It is recommend to migrate to the new folders structure:
21
-
22
- ```
23
- app/packs:
24
- ├── entrypoints
25
- └── src
26
- └── stylesheets
27
- └── images
28
- ```
29
-
30
- == Update Rails helpers
31
-
32
- `javascript_include_tag` and `stylesheet_link_tag` have been replaced by `javascript_pack_tag` and `stylesheet_pack_tag`
33
-
34
- For images, if they are in `app/packs/images` you could use `image_pack_tag`.
35
-
36
- == Asset compilation
37
-
38
- As all assets are now compiled using Webpacker without ever loading the Rails or Decidim environment, there are some new conventions how to tell Webpacker about the Decidim module's assets.
39
-
40
- To begin with, create a new file named `config/assets.rb` inside your Decidim module.
41
-
42
- After this, add the following contents in that file, depending what kind of assets your module provides:
43
-
44
- [source,ruby]
45
- ----
46
- # frozen_string_literal: true
47
- # This file is located at `config/assets.rb` of your module.
48
-
49
- # Define the base path of your module. Please note that `Rails.root` may not be
50
- # used because we are not inside the Rails environment when this file is loaded.
51
- base_path = File.expand_path("..", __dir__)
52
-
53
- # Register an additional load path for webpack. All the assets within these
54
- # directories will be available for inclusion within the Decidim assets. For
55
- # example, if you have `app/packs/src/decidim/foo.js`, you can include that file
56
- # in your JavaScript entrypoints (or other JavaScript files within Decidim)
57
- # using `import "src/decidim/foo"` after you have registered the additional path
58
- # as follows.
59
- Decidim::Webpacker.register_path("#{base_path}/app/packs")
60
-
61
- # Register the entrypoints for your module. These entrypoints can be included
62
- # within your application using `javascript_pack_tag` and if you include any
63
- # SCSS files within the entrypoints, they become available for inclusion using
64
- # `stylesheet_pack_tag`.
65
- Decidim::Webpacker.register_entrypoints(
66
- decidim_foo: "#{base_path}/app/packs/entrypoints/decidim_foo.js",
67
- decidim_foo_admin: "#{base_path}/app/packs/entrypoints/decidim_foo_admin.js"
68
- )
69
-
70
- # If you want to import some extra SCSS files in the Decidim main SCSS file
71
- # without adding any extra stylesheet inclusion tags, you can use the following
72
- # method to register the stylesheet import for the main application.
73
- Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/foo/app")
74
-
75
- # If you want to do the same but include the SCSS file for the admin panel's
76
- # main SCSS file, you can use the following method.
77
- Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/foo/admin", group: :admin)
78
-
79
- # If you want to override some SCSS variables/settings for Foundation from the
80
- # module, you can add the following registered import.
81
- Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/foo/settings", type: :settings)
82
-
83
- # If you want to do the same but override the SCSS variables of the admin
84
- # panel's styles, you can use the following method.
85
- Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/foo/admin_settings", type: :settings, group: :admin)
86
- ----
87
-
88
- == Component stylesheet migration
89
-
90
- In older Decidim versions your components could define their own stylesheet as follows:
91
-
92
- [source,ruby]
93
- ----
94
- Decidim.register_component(:your_component) do |component|
95
- component.engine = Decidim::YourComponent::Engine
96
- component.stylesheet = "decidim/your_component/your_component"
97
- component.admin_stylesheet = "decidim/your_component/your_component_admin"
98
- end
99
- ----
100
-
101
- These were automatically included in the main application's stylesheet file and also in the admin panel's stylesheet file. These no longer work with Webpacker as the Decidim environment is not loaded when Webpacker compiles the assets.
102
-
103
- What you should do instead is to follow the asset compilation migration guide above and migrate these definitions into your module's `config/assets.rb` file as follows:
104
-
105
- [source,ruby]
106
- ----
107
- # frozen_string_literal: true
108
- # This file is located at `config/assets.rb` of your module.
109
-
110
- base_path = File.expand_path("..", __dir__)
111
-
112
- # Register the additional path for Webpacker in order to make the module's
113
- # stylesheets available for inclusion.
114
- Decidim::Webpacker.register_path("#{base_path}/app/packs")
115
-
116
- # Register the main application's stylesheet include statement:
117
- Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/your_component/your_component")
118
-
119
- # Register the admin panel's stylesheet include statement:
120
- Decidim::Webpacker.register_stylesheet_import("stylesheets/decidim/your_component/your_component_admin", group: :admin)
121
- ----
122
-
123
- === Help Decidim to know the module's assets folder
124
-
125
- To prevent Zeitwerk issues trying to autoload the non-ruby module folders, modify the `lib/[module_name]/engine.rb` file to include the following:
126
-
127
- [source,ruby]
128
- ---
129
- initializer "[module_name].webpacker.assets_path" do
130
- Decidim.register_assets_path File.expand_path("app/packs", root)
131
- end
132
- ---
@@ -1,123 +0,0 @@
1
- = Metrics
2
-
3
- Metrics calculations must be executed everyday. Some `rake task` have been added to perform it.
4
-
5
- * To execute all metrics at once. Related to previous date from _today_
6
- +
7
- [source,ruby]
8
- ----
9
- bundle exec rake decidim:metrics:all
10
- ----
11
-
12
- * To execute an specific metric. Related to previous date from _today_
13
- +
14
- [source,ruby]
15
- ----
16
- bundle exec rake decidim:metrics:one["<metric name>"]
17
- ----
18
-
19
- * To execute metrics for a given date (all or an specific one)
20
- +
21
- [source,ruby]
22
- ----
23
- bundle exec rake decidim:metrics:all["YYYY-MM-DD"]
24
- bundle exec rake decidim:metrics:one["<metric name>","YYYY-MM-DD"]
25
- ----
26
-
27
- * It is possible to rebuild one or all metrics since some specific day. This is useful in case current metrics are no generated or corrupt. *Depending on the size of the database this can take a long time!*. The command will execute the same calculations as the commands above for *each* day between _today_ and the date specified.
28
- * To rebuild metrics since a given date (all or an specific one)
29
- +
30
- [source,ruby]
31
- ----
32
- bundle exec rake decidim:metrics:rebuild["YYYY-MM-DD"]
33
- bundle exec rake decidim:metrics:rebuild["<metric name>","YYYY-MM-DD"]
34
- ----
35
-
36
- == Available metrics
37
-
38
- * Use the command `decidim:metrics:list` to list all available metrics using the console:
39
-
40
- [source,ruby]
41
- ----
42
- bundle exec rake decidim:metrics:list
43
- ----
44
-
45
- Currently, available metrics are:
46
-
47
- * *users*, created `Users`
48
- * *proposals*, published, not withdrawn and not _hidden_ `Proposals`
49
- * *accepted_proposals*, accepted `Proposals`
50
- * *supports*, supports given to `Proposals`
51
- * *assemblies*, published `Assemblies`
52
- * *participatory_processes*, published `ParticipatoryProcesses`
53
- * *results*, `Results` in `Accountability`
54
- * *comments*, `Comments` generated by users, related to public elements and not _hidden_
55
- * *meetings*, public `Meetings`
56
-
57
- Only available for `ParticipatorySpaces` (restricted to `ParticipatoryProcesses`)
58
-
59
- * *participants*, unique users who make at least one of the following actions:
60
- ** Answer a survey
61
- ** Create a debate
62
- ** Create a proposal
63
- ** Endorse a proposal
64
- ** Leave a comment
65
- ** Support a proposal
66
- ** Vote a participatory budgeting project
67
- * *followers*, unique users who follow any participatory element in a `ParticipatorySpace`
68
- * *endorsements*, number of `Endorsements` in `Proposals`, within a `ParticipatorySpace`
69
- * *debates*, number of `Debates` within a `ParticipatorySpace`
70
- * *survey_answers*, number of answered `Surveys` by users within a `ParticipatorySpace`
71
-
72
- == Configuration
73
-
74
- * A *crontab* line must be added to your server to maintain them updated daily. You could use https://github.com/javan/whenever[Whenever] to manage it directly from the APP. You probably want to schedule a `bundle exec rake decidim:metrics:all` every night.
75
- * An *ActiveJob* queue, like https://github.com/mperham/sidekiq[Sidekiq] or https://github.com/collectiveidea/delayed_job/[DelayedJob]
76
-
77
- == Persistence
78
-
79
- The metrics module precomputes calculations and persists them into
80
- `decidim_metrics` database table. So this module only uses one single table to
81
- persist metrics from all times and types.
82
-
83
- The `decidim_metrics` table has the following fields:
84
-
85
- * `day`: the day for which the metric has been computed.
86
- * `metric_type`: the type of the metric. One of: users, proposals, accepted_proposals, supports, assemblies.
87
- * `cumulative`: quantity accumulated to day `"day`".
88
- * `quantity`: quantity for the current day, `"day`".
89
- * `decidim_organization_id`: the FK to the organization to which this Metric belongs to.
90
- * `participatory_space_type` + `participatory_space_id`: the FK to the participatory space to which this Metric belongs to, if any.
91
- * `related_object_type` + `related_object_id`: the FK to the object to which this Metric belongs to, if any.
92
- * `decidim_category_id`: the FK to the category for this Metric, if any.
93
-
94
- Relations around `decidim_metrics` table:
95
-
96
- [source,ascii]
97
- ----
98
- +------------------------+
99
- +--------------+ | ParticipatoryProcesses |
100
- | Organization | +----+------------------------+
101
- +------+-------+ |
102
- | +--------------------+ | +------------+
103
- | | | +----+ Assemblies |
104
- | +----->+ ParticipatorySpace +<----+ +------------+
105
- | | | | | +-------------+
106
- | | +--------------------+ +----+ Initiatives |
107
- | | +-------------+
108
- | |
109
- | |
110
- +-----+-------+---+
111
- | |
112
- | decidim_metrics |
113
- | |
114
- +--------+--------+ +----------------+
115
- | | related_object |
116
- +--------------->+ |
117
- | [polymorphic] |
118
- +----------------+
119
- ----
120
-
121
- == Troubleshooting
122
-
123
- If you find problems in your metrics numbers you can follow the guide xref:develop:troubleshooting_metrics.adoc[Troubleshooting metrics].