decidim-generators 0.27.9 → 0.28.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -5
- data/Gemfile.lock +346 -403
- data/README.md +2 -2
- data/lib/decidim/generators/app_generator.rb +83 -8
- data/lib/decidim/generators/app_templates/.node-version +1 -0
- data/lib/decidim/generators/app_templates/.rubocop.yml +2 -0
- data/lib/decidim/generators/app_templates/.ruby-version +1 -0
- data/lib/decidim/generators/app_templates/README.md.erb +7 -12
- data/lib/decidim/generators/app_templates/another_dummy_authorization_handler.rb +1 -1
- data/lib/decidim/generators/app_templates/budgets_workflow_random.rb +1 -1
- data/lib/decidim/generators/app_templates/bullet_initializer.rb +1 -1
- data/lib/decidim/generators/app_templates/database.yml.erb +1 -1
- data/lib/decidim/generators/app_templates/decidim_application.scss +2 -1
- data/lib/decidim/generators/app_templates/dummy_authorization_handler.rb +5 -5
- data/lib/decidim/generators/app_templates/initializer.rb +16 -8
- data/lib/decidim/generators/app_templates/rack_profiler_initializer.rb +2 -1
- data/lib/decidim/generators/app_templates/secrets.yml.erb +14 -10
- data/lib/decidim/generators/component_generator.rb +37 -2
- data/lib/decidim/generators/component_templates/.eslintrc.json +3 -0
- data/lib/decidim/generators/component_templates/.node-version +1 -0
- data/lib/decidim/generators/component_templates/.rubocop.yml +2 -0
- data/lib/decidim/generators/component_templates/.ruby-version +1 -0
- data/lib/decidim/generators/component_templates/.stylelintrc.json +3 -0
- data/lib/decidim/generators/component_templates/Gemfile.erb +5 -6
- data/lib/decidim/generators/component_templates/README.md.erb +7 -1
- data/lib/decidim/generators/component_templates/app/controllers/decidim/component/admin/application_controller.rb.erb +11 -0
- data/lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb +23 -0
- data/lib/decidim/generators/component_templates/decidim-component.gemspec.erb +10 -8
- data/lib/decidim/generators/component_templates/github/ci.yml.erb +77 -0
- data/lib/decidim/generators/component_templates/gitignore +5 -0
- data/lib/decidim/generators/component_templates/lib/decidim/component/test/factories.rb.erb +1 -0
- data/lib/decidim/generators/component_templates/package.json.erb +21 -0
- data/lib/decidim/generators/component_templates/spec/lib/version_spec.rb.erb +13 -0
- data/lib/decidim/generators/component_templates/spec/permissions/admin/permissions_spec.rb.erb +40 -0
- data/lib/decidim/generators/install_generator.rb +12 -7
- data/lib/decidim/generators/test/generator_examples.rb +72 -40
- data/lib/decidim/generators/version.rb +1 -1
- metadata +29 -15
- data/decidim-generators.gemspec +0 -35
- data/lib/decidim/generators/app_templates/_decidim-settings.scss +0 -7
- data/lib/decidim/generators/app_templates/social_share_button.rb +0 -8
- data/lib/decidim/generators/component_templates/circleci/config.yml +0 -47
data/README.md
CHANGED
@@ -28,14 +28,14 @@ require in your final decidim application in order to use it. To do that, you
|
|
28
28
|
need to include the plugin in your application's `Gemfile`.
|
29
29
|
|
30
30
|
For example, if you generated your component at
|
31
|
-
`~/decidim-module-experimental_component`, you
|
31
|
+
`~/decidim-module-experimental_component`, you will need to edit your `Gemfile` like
|
32
32
|
this in order for the component to be used:
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
gem "decidim-experimental_plugin", path: "~/decidim-module-experimental_plugin"
|
36
36
|
```
|
37
37
|
|
38
|
-
Once you do that, and boot your application, you
|
38
|
+
Once you do that, and boot your application, you will see the new component being
|
39
39
|
offered in the "New component" selector on the "Components" section of any
|
40
40
|
participatory space in the admin dashboard.
|
41
41
|
|
@@ -55,11 +55,11 @@ module Decidim
|
|
55
55
|
|
56
56
|
class_option :skip_bundle, type: :boolean,
|
57
57
|
default: true, # this is to avoid installing gems in this step yet (done by InstallGenerator)
|
58
|
-
desc: "
|
58
|
+
desc: "Do not run bundle install"
|
59
59
|
|
60
60
|
class_option :skip_gemfile, type: :boolean,
|
61
61
|
default: false,
|
62
|
-
desc: "
|
62
|
+
desc: "Do not generate a Gemfile for the application"
|
63
63
|
|
64
64
|
class_option :demo, type: :boolean,
|
65
65
|
default: false,
|
@@ -71,7 +71,7 @@ module Decidim
|
|
71
71
|
|
72
72
|
class_option :force_ssl, type: :string,
|
73
73
|
default: "true",
|
74
|
-
desc: "
|
74
|
+
desc: "Does not force to use ssl"
|
75
75
|
|
76
76
|
class_option :locales, type: :string,
|
77
77
|
default: "",
|
@@ -87,11 +87,16 @@ module Decidim
|
|
87
87
|
|
88
88
|
class_option :skip_webpack_install, type: :boolean,
|
89
89
|
default: true,
|
90
|
-
desc: "
|
90
|
+
desc: "Do not run Webpack install"
|
91
91
|
|
92
92
|
class_option :dev_ssl, type: :boolean,
|
93
93
|
default: false,
|
94
|
-
desc: "
|
94
|
+
desc: "Do not add Puma development SSL configuration options"
|
95
|
+
|
96
|
+
# we disable the webpacker installation as we will use shakapacker
|
97
|
+
def webpacker_gemfile_entry
|
98
|
+
[]
|
99
|
+
end
|
95
100
|
|
96
101
|
def database_yml
|
97
102
|
template "database.yml.erb", "config/database.yml", force: true
|
@@ -122,11 +127,26 @@ module Decidim
|
|
122
127
|
template "LICENSE-AGPLv3.txt", "LICENSE-AGPLv3.txt"
|
123
128
|
end
|
124
129
|
|
130
|
+
def rubocop
|
131
|
+
copy_file ".rubocop.yml", ".rubocop.yml"
|
132
|
+
end
|
133
|
+
|
134
|
+
def ruby_version
|
135
|
+
copy_file ".ruby-version", ".ruby-version", force: true
|
136
|
+
end
|
137
|
+
|
138
|
+
def node_version
|
139
|
+
copy_file ".node-version", ".node-version"
|
140
|
+
end
|
141
|
+
|
125
142
|
def gemfile
|
126
143
|
return if options[:skip_gemfile]
|
127
144
|
|
128
145
|
if branch.present?
|
129
146
|
get target_gemfile, "Gemfile", force: true
|
147
|
+
append_file "Gemfile", %(\ngem "net-imap", "~> 0.2.3", group: :development)
|
148
|
+
append_file "Gemfile", %(\ngem "net-pop", "~> 0.1.1", group: :development)
|
149
|
+
append_file "Gemfile", %(\ngem "net-smtp", "~> 0.3.1", group: :development)
|
130
150
|
get "#{target_gemfile}.lock", "Gemfile.lock", force: true
|
131
151
|
else
|
132
152
|
copy_file target_gemfile, "Gemfile", force: true
|
@@ -139,7 +159,7 @@ module Decidim
|
|
139
159
|
|
140
160
|
gsub_file "Gemfile", /gem "decidim-dev".*/, "gem \"decidim-dev\", #{gem_modifier}"
|
141
161
|
|
142
|
-
%w(conferences
|
162
|
+
%w(conferences design elections initiatives templates).each do |component|
|
143
163
|
if options[:demo]
|
144
164
|
gsub_file "Gemfile", /gem "decidim-#{component}".*/, "gem \"decidim-#{component}\", #{gem_modifier}"
|
145
165
|
else
|
@@ -209,6 +229,16 @@ module Decidim
|
|
209
229
|
prepend_to_file "config/spring.rb", "require \"decidim/spring\"\n\n"
|
210
230
|
end
|
211
231
|
|
232
|
+
def tweak_csp_initializer
|
233
|
+
return unless File.exist?("config/initializers/content_security_policy.rb")
|
234
|
+
|
235
|
+
remove_file("config/initializers/content_security_policy.rb")
|
236
|
+
create_file "config/initializers/content_security_policy.rb" do
|
237
|
+
%(# For tuning the Content Security Policy, check the Decidim documentation site
|
238
|
+
# https://docs.decidim.org/develop/en/customize/content_security_policy)
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
212
242
|
def puma_ssl_options
|
213
243
|
return unless options[:dev_ssl]
|
214
244
|
|
@@ -227,8 +257,29 @@ module Decidim
|
|
227
257
|
CONFIG
|
228
258
|
end
|
229
259
|
|
230
|
-
def
|
231
|
-
|
260
|
+
def modify_gitignore
|
261
|
+
return if options[:skip_git]
|
262
|
+
|
263
|
+
append_file ".gitignore", <<~GITIGNORE
|
264
|
+
|
265
|
+
# Ignore env configuration files
|
266
|
+
.env
|
267
|
+
.envrc
|
268
|
+
.rbenv-vars
|
269
|
+
|
270
|
+
# Ignore the files and folders generated through Webpack
|
271
|
+
/public/decidim-packs
|
272
|
+
/public/packs-test
|
273
|
+
/public/sw.js
|
274
|
+
/public/sw.js.map
|
275
|
+
|
276
|
+
# Ignore node modules
|
277
|
+
/node_modules
|
278
|
+
GITIGNORE
|
279
|
+
end
|
280
|
+
|
281
|
+
def add_ignore_tailwind_configuration
|
282
|
+
append_file ".gitignore", "\n\n# Ignore Tailwind configuration\ntailwind.config.js" unless options["skip_git"]
|
232
283
|
end
|
233
284
|
|
234
285
|
def remove_default_error_pages
|
@@ -236,6 +287,10 @@ module Decidim
|
|
236
287
|
remove_file "public/500.html"
|
237
288
|
end
|
238
289
|
|
290
|
+
def remove_default_favicon
|
291
|
+
remove_file "public/favicon.ico"
|
292
|
+
end
|
293
|
+
|
239
294
|
def decidim_initializer
|
240
295
|
copy_file "initializer.rb", "config/initializers/decidim.rb"
|
241
296
|
|
@@ -262,6 +317,26 @@ module Decidim
|
|
262
317
|
"# config.available_locales = Rails.application.secrets.decidim[:available_locales].presence || [:en]"
|
263
318
|
end
|
264
319
|
|
320
|
+
def dev_performance_config
|
321
|
+
gsub_file "config/environments/development.rb", /^end\n$/, <<~CONFIG
|
322
|
+
|
323
|
+
# Performance configs for local testing
|
324
|
+
if ENV.fetch("RAILS_BOOST_PERFORMANCE", false).to_s == "true"
|
325
|
+
# Indicate boost performance mode
|
326
|
+
config.boost_performance = true
|
327
|
+
# Enable caching and eager load
|
328
|
+
config.eager_load = true
|
329
|
+
config.cache_classes = true
|
330
|
+
# Logging
|
331
|
+
config.log_level = :info
|
332
|
+
config.action_view.logger = nil
|
333
|
+
# Compress the HTML responses with gzip
|
334
|
+
config.middleware.use Rack::Deflater
|
335
|
+
end
|
336
|
+
end
|
337
|
+
CONFIG
|
338
|
+
end
|
339
|
+
|
265
340
|
def authorization_handler
|
266
341
|
return unless options[:demo]
|
267
342
|
|
@@ -0,0 +1 @@
|
|
1
|
+
18.17.1
|
@@ -0,0 +1 @@
|
|
1
|
+
3.1.1
|
@@ -6,17 +6,12 @@ This is the open-source repository for <%= app_name %>, based on [Decidim](https
|
|
6
6
|
|
7
7
|
## Setting up the application
|
8
8
|
|
9
|
-
You will need to do some steps before having the app working properly once you
|
9
|
+
You will need to do some steps before having the app working properly once you have deployed it:
|
10
10
|
|
11
|
-
1.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
```
|
17
|
-
3. Visit `<your app url>/system` and login with your system admin credentials
|
18
|
-
4. Create a new organization. Check the locales you want to use for that organization, and select a default locale.
|
19
|
-
5. Set the correct default host for the organization, otherwise the app will not work properly. Note that you need to include any subdomain you might be using.
|
20
|
-
6. Fill the rest of the form and submit it.
|
11
|
+
1. Create a System Admin user: `bin/rails decidim_system:create_admin`
|
12
|
+
1. Visit `<your app url>/system` and login with your system admin credentials
|
13
|
+
1. Create a new organization. Check the locales you want to use for that organization, and select a default locale.
|
14
|
+
1. Set the correct default host for the organization, otherwise the app will not work properly. Note that you need to include any subdomain you might be using.
|
15
|
+
1. Fill the rest of the form and submit it.
|
21
16
|
|
22
|
-
You
|
17
|
+
You are good to go!
|
@@ -9,7 +9,7 @@ class AnotherDummyAuthorizationHandler < Decidim::AuthorizationHandler
|
|
9
9
|
validate :valid_passport_number
|
10
10
|
|
11
11
|
def metadata
|
12
|
-
super.merge(passport_number
|
12
|
+
super.merge(passport_number:, postal_code:)
|
13
13
|
end
|
14
14
|
|
15
15
|
def unique_id
|
@@ -5,7 +5,7 @@
|
|
5
5
|
# Note: random selection should be deterministic for the same user and the same budgets component.
|
6
6
|
# As the budget resources list could change and affect the random selection, it also allows to finish orders created on other budgets.
|
7
7
|
class BudgetsWorkflowRandom < Decidim::Budgets::Workflows::Base
|
8
|
-
# Highlight the resource if the user
|
8
|
+
# Highlight the resource if the user did not vote and is allowed to vote on it.
|
9
9
|
def highlighted?(resource)
|
10
10
|
vote_allowed?(resource)
|
11
11
|
end
|
@@ -41,7 +41,7 @@ development:
|
|
41
41
|
#password:
|
42
42
|
|
43
43
|
# Connect on a TCP socket. Omitted by default since the client uses a
|
44
|
-
# domain socket that
|
44
|
+
# domain socket that does not need configuration. Windows does not have
|
45
45
|
# domain sockets, so uncomment these lines.
|
46
46
|
#host: localhost
|
47
47
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
// Notice that this file is included at the very end of the stylesheets packs to have
|
3
3
|
// more priority
|
4
4
|
//
|
5
|
-
// To override CSS
|
5
|
+
// To override the Tailwind CSS configuration you can do so by following the instructions
|
6
|
+
// available at https://docs.decidim.org/en/develop/customize/styles.html#_tailwind_css
|
6
7
|
//
|
7
8
|
// By default this is empty.
|
@@ -43,7 +43,7 @@ class DummyAuthorizationHandler < Decidim::AuthorizationHandler
|
|
43
43
|
# be created or not, you should return a Boolean value.
|
44
44
|
#
|
45
45
|
# Note that if you set some validations and overwrite this method, then the
|
46
|
-
# validations will not run, so it
|
46
|
+
# validations will not run, so it is easier to remove this method and rewrite
|
47
47
|
# your logic using ActiveModel validations.
|
48
48
|
#
|
49
49
|
# def valid?
|
@@ -66,10 +66,10 @@ class DummyAuthorizationHandler < Decidim::AuthorizationHandler
|
|
66
66
|
# can do it here.
|
67
67
|
#
|
68
68
|
# You must return a Hash that will be serialized to the authorization when
|
69
|
-
# it
|
69
|
+
# it is created, and available though authorization.metadata
|
70
70
|
#
|
71
71
|
def metadata
|
72
|
-
super.merge(document_number
|
72
|
+
super.merge(document_number:, postal_code:, scope_id:)
|
73
73
|
end
|
74
74
|
|
75
75
|
private
|
@@ -105,7 +105,7 @@ class DummyAuthorizationHandler < Decidim::AuthorizationHandler
|
|
105
105
|
if disallowed_user_postal_code
|
106
106
|
if user_postal_code
|
107
107
|
i18n_postal_codes_key = "extra_explanation.user_postal_codes"
|
108
|
-
user_postal_code_params = { user_postal_code:
|
108
|
+
user_postal_code_params = { user_postal_code: }
|
109
109
|
else
|
110
110
|
i18n_postal_codes_key = "extra_explanation.postal_codes"
|
111
111
|
user_postal_code_params = {}
|
@@ -126,7 +126,7 @@ class DummyAuthorizationHandler < Decidim::AuthorizationHandler
|
|
126
126
|
if disallowed_user_user_scope
|
127
127
|
if user_scope_id
|
128
128
|
i18n_scope_key = "extra_explanation.user_scope"
|
129
|
-
user_scope_params = { user_scope_name:
|
129
|
+
user_scope_params = { user_scope_name: }
|
130
130
|
else
|
131
131
|
i18n_scope_key = "extra_explanation.scope"
|
132
132
|
user_scope_params = {}
|
@@ -40,6 +40,11 @@ Decidim.configure do |config|
|
|
40
40
|
# Enable the service worker. By default is disabled in development and enabled in the rest of environments
|
41
41
|
config.service_worker_enabled = Rails.application.secrets.decidim[:service_worker_enabled].present?
|
42
42
|
|
43
|
+
# Sets the list of static pages' slugs that can include content blocks.
|
44
|
+
# By default is only enabled in the terms-of-service static page to allow a summary to be added and include
|
45
|
+
# sections with a two-pane view
|
46
|
+
config.page_blocks = Rails.application.secrets.decidim[:page_blocks].presence || %w(terms-of-service)
|
47
|
+
|
43
48
|
# Map and Geocoder configuration
|
44
49
|
#
|
45
50
|
# See Decidim docs at https://docs.decidim.org/en/develop/services/maps.html
|
@@ -336,6 +341,9 @@ Decidim.configure do |config|
|
|
336
341
|
#
|
337
342
|
# config.machine_translation_service = "MyTranslationService"
|
338
343
|
|
344
|
+
# Defines the social networking services used for social sharing
|
345
|
+
config.social_share_services = Rails.application.secrets.decidim[:social_share_services]
|
346
|
+
|
339
347
|
# Defines the name of the cookie used to check if the user allows Decidim to
|
340
348
|
# set cookies.
|
341
349
|
config.consent_cookie_name = Rails.application.secrets.decidim[:consent_cookie_name] if Rails.application.secrets.decidim[:consent_cookie_name].present?
|
@@ -370,6 +378,10 @@ Decidim.configure do |config|
|
|
370
378
|
# }
|
371
379
|
# ]
|
372
380
|
|
381
|
+
# Defines additional content security policies following the structure
|
382
|
+
# Read more: https://docs.decidim.org/en/develop/configure/initializer#_content_security_policy
|
383
|
+
config.content_security_policies_extra = {}
|
384
|
+
|
373
385
|
# Admin admin password configurations
|
374
386
|
Rails.application.secrets.dig(:decidim, :admin_password, :strong).tap do |strong_pw|
|
375
387
|
# When the strong password is not configured, default to true
|
@@ -388,7 +400,8 @@ Decidim.configure do |config|
|
|
388
400
|
end
|
389
401
|
config.follow_http_x_forwarded_host = Rails.application.secrets.decidim[:follow_http_x_forwarded_host].present?
|
390
402
|
config.maximum_conversation_message_length = Rails.application.secrets.decidim[:maximum_conversation_message_length].to_i
|
391
|
-
config.
|
403
|
+
config.password_similarity_length = Rails.application.secrets.decidim[:password_similarity_length] if Rails.application.secrets.decidim[:password_similarity_length].present?
|
404
|
+
config.denied_passwords = Rails.application.secrets.decidim[:denied_passwords] if Rails.application.secrets.decidim[:denied_passwords].present?
|
392
405
|
config.allow_open_redirects = Rails.application.secrets.decidim[:allow_open_redirects] if Rails.application.secrets.decidim[:allow_open_redirects].present?
|
393
406
|
end
|
394
407
|
|
@@ -437,12 +450,6 @@ if Decidim.module_installed? :accountability
|
|
437
450
|
end
|
438
451
|
end
|
439
452
|
|
440
|
-
if Decidim.module_installed? :consultations
|
441
|
-
Decidim::Consultations.configure do |config|
|
442
|
-
config.stats_cache_expiration_time = Rails.application.secrets.dig(:decidim, :consultations, :stats_cache_expiration_time).to_i.minutes
|
443
|
-
end
|
444
|
-
end
|
445
|
-
|
446
453
|
if Decidim.module_installed? :initiatives
|
447
454
|
Decidim::Initiatives.configure do |config|
|
448
455
|
unless Rails.application.secrets.dig(:decidim, :initiatives, :creation_enabled) == "auto"
|
@@ -466,9 +473,10 @@ end
|
|
466
473
|
|
467
474
|
if Decidim.module_installed? :elections
|
468
475
|
Decidim::Elections.configure do |config|
|
469
|
-
config.setup_minimum_hours_before_start = Rails.application.secrets.dig(:elections, :setup_minimum_hours_before_start).presence ||
|
476
|
+
config.setup_minimum_hours_before_start = Rails.application.secrets.dig(:elections, :setup_minimum_hours_before_start).presence || 1
|
470
477
|
config.start_vote_maximum_hours_before_start = Rails.application.secrets.dig(:elections, :start_vote_maximum_hours_before_start).presence || 6
|
471
478
|
config.voter_token_expiration_minutes = Rails.application.secrets.dig(:elections, :voter_token_expiration_minutes).presence || 120
|
479
|
+
config.document_types = Rails.application.secrets.dig(:elections, :document_types).presence || %w(identification_number passport)
|
472
480
|
end
|
473
481
|
|
474
482
|
Decidim::Votings.configure do |config|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
if Rails.env.development?
|
3
|
+
if Rails.env.development? && !Rails.application.config.try(:boost_performance)
|
4
4
|
require "rack-mini-profiler"
|
5
5
|
|
6
6
|
# initialization is skipped so trigger it
|
7
7
|
Rack::MiniProfilerRails.initialize!(Rails.application)
|
8
|
+
Rack::MiniProfiler.config.skip_paths << "/favicon.ico"
|
8
9
|
end
|
@@ -4,11 +4,11 @@
|
|
4
4
|
# If you change this key, all old signed cookies will become invalid!
|
5
5
|
|
6
6
|
# Make sure the secret is at least 30 characters and all random,
|
7
|
-
# no regular words or you
|
7
|
+
# no regular words or you will be exposed to dictionary attacks.
|
8
8
|
# You can use `rails secret` to generate a secure secret key.
|
9
9
|
|
10
10
|
# Make sure the secrets in this file are kept private
|
11
|
-
# if you
|
11
|
+
# if you are sharing your code publicly.
|
12
12
|
|
13
13
|
decidim_default: &decidim_default
|
14
14
|
application_name: <%%= Decidim::Env.new("DECIDIM_APPLICATION_NAME", "My Application Name").to_json %>
|
@@ -38,9 +38,12 @@ decidim_default: &decidim_default
|
|
38
38
|
enable_remember_me: <%%= Decidim::Env.new("DECIDIM_ENABLE_REMEMBER_ME", "auto").default_or_present_if_exists.to_s %>
|
39
39
|
follow_http_x_forwarded_host: <%%= Decidim::Env.new("DECIDIM_FOLLOW_HTTP_X_FORWARDED_HOST").to_boolean_string %>
|
40
40
|
maximum_conversation_message_length: <%%= Decidim::Env.new("DECIDIM_MAXIMUM_CONVERSATION_MESSAGE_LENGTH", "1000").to_i %>
|
41
|
-
|
41
|
+
password_similarity_length: <%%= Decidim::Env.new("DECIDIM_PASSWORD_SIMILARITY_LENGTH", 4).to_i %>
|
42
|
+
denied_passwords: <%%= Decidim::Env.new("DECIDIM_DENIED_PASSWORDS").to_array(separator: ", ").to_json %>
|
42
43
|
allow_open_redirects: <%%= Decidim::Env.new("DECIDIM_ALLOW_OPEN_REDIRECTS").to_boolean_string %>
|
44
|
+
social_share_services: <%%= Decidim::Env.new("DECIDIM_SOCIAL_SHARE_SERVICES", "X, Facebook, WhatsApp, Telegram").to_array.to_json %>
|
43
45
|
service_worker_enabled: <%%= Decidim::Env.new("DECIDIM_SERVICE_WORKER_ENABLED", Rails.env.exclude?("development")).to_boolean_string %>
|
46
|
+
page_blocks: <%%= Decidim::Env.new("DECIDIM_PAGE_BLOCKS", "terms-of-service").to_array %>
|
44
47
|
admin_password:
|
45
48
|
expiration_days: <%%= Decidim::Env.new("DECIDIM_ADMIN_PASSWORD_EXPIRATION_DAYS", 90).to_i %>
|
46
49
|
min_length: <%%= Decidim::Env.new("DECIDIM_ADMIN_PASSWORD_MIN_LENGTH", 15).to_i %>
|
@@ -63,8 +66,6 @@ decidim_default: &decidim_default
|
|
63
66
|
enable_proposal_linking: <%%= Decidim::Env.new("BUDGETS_ENABLE_PROPOSAL_LINKING", "auto").default_or_present_if_exists.to_s %>
|
64
67
|
accountability:
|
65
68
|
enable_proposal_linking: <%%= Decidim::Env.new("ACCOUNTABILITY_ENABLE_PROPOSAL_LINKING", "auto").default_or_present_if_exists.to_s %>
|
66
|
-
consultations:
|
67
|
-
stats_cache_expiration_time: <%%= Decidim::Env.new("CONSULTATIONS_STATS_CACHE_EXPIRATION_TIME", 5).to_i %>
|
68
69
|
initiatives:
|
69
70
|
creation_enabled: <%%= Decidim::Env.new("INITIATIVES_CREATION_ENABLED", "auto").default_or_present_if_exists.to_s %>
|
70
71
|
similarity_threshold: <%%= Decidim::Env.new("INITIATIVES_SIMILARITY_THRESHOLD", 0.25).to_f %>
|
@@ -78,8 +79,6 @@ decidim_default: &decidim_default
|
|
78
79
|
max_time_in_validating_state: <%%= Decidim::Env.new("INITIATIVES_MAX_TIME_IN_VALIDATING_STATE", 60).to_i %>
|
79
80
|
print_enabled: <%%= Decidim::Env.new("INITIATIVES_PRINT_ENABLED", "auto").default_or_present_if_exists.to_s %>
|
80
81
|
do_not_require_authorization: <%%= Decidim::Env.new("INITIATIVES_DO_NOT_REQUIRE_AUTHORIZATION").to_boolean_string %>
|
81
|
-
verifications:
|
82
|
-
document_types: <%%= Decidim::Env.new("VERIFICATIONS_DOCUMENT_TYPES", "identification_number,passport").to_array %>
|
83
82
|
|
84
83
|
elections_default: &elections_default
|
85
84
|
bulletin_board_server: <%%= Decidim::Env.new("ELECTIONS_BULLETIN_BOARD_SERVER", 'http://bulletin-board.lvh.me:8000/api').to_s %>
|
@@ -90,6 +89,8 @@ elections_default: &elections_default
|
|
90
89
|
scheme_name: "dummy"
|
91
90
|
quorum: 2
|
92
91
|
number_of_trustees: 3
|
92
|
+
setup_minimum_hours_before_start: 1
|
93
|
+
document_types: <%%= Decidim::Env.new("ELECTIONS_DOCUMENT_TYPES", "identification_number,passport").to_array.to_json %>
|
93
94
|
|
94
95
|
storage_default: &storage_default
|
95
96
|
provider: <%%= Decidim::Env.new("STORAGE_PROVIDER", "local").to_s %>
|
@@ -126,13 +127,15 @@ default: &default
|
|
126
127
|
enabled: <%%= Decidim::Env.new("OMNIAUTH_FACEBOOK_APP_ID").to_boolean_string %>
|
127
128
|
app_id: <%%= ENV["OMNIAUTH_FACEBOOK_APP_ID"] %>
|
128
129
|
app_secret: <%%= ENV["OMNIAUTH_FACEBOOK_APP_SECRET"] %>
|
130
|
+
icon: facebook-fill
|
129
131
|
twitter:
|
130
132
|
enabled: <%%= Decidim::Env.new("OMNIAUTH_TWITTER_API_KEY").to_boolean_string %>
|
131
133
|
api_key: <%%= ENV["OMNIAUTH_TWITTER_API_KEY"] %>
|
132
134
|
api_secret: <%%= ENV["OMNIAUTH_TWITTER_API_SECRET"] %>
|
135
|
+
icon: twitter-x-fill
|
133
136
|
google_oauth2:
|
134
137
|
enabled: <%%= Decidim::Env.new("OMNIAUTH_GOOGLE_CLIENT_ID").to_boolean_string %>
|
135
|
-
|
138
|
+
icon: google-fill
|
136
139
|
client_id: <%%= ENV["OMNIAUTH_GOOGLE_CLIENT_ID"] %>
|
137
140
|
client_secret: <%%= ENV["OMNIAUTH_GOOGLE_CLIENT_SECRET"] %>
|
138
141
|
maps:
|
@@ -164,7 +167,7 @@ development:
|
|
164
167
|
omniauth:
|
165
168
|
developer:
|
166
169
|
enabled: true
|
167
|
-
icon: phone
|
170
|
+
icon: phone-line
|
168
171
|
|
169
172
|
test:
|
170
173
|
<<: *default
|
@@ -208,9 +211,10 @@ production:
|
|
208
211
|
scheme_name: <%%= Decidim::Env.new("ELECTIONS_SCHEME_NAME", "electionguard").to_s %>
|
209
212
|
number_of_trustees: <%%= Decidim::Env.new("ELECTIONS_NUMBER_OF_TRUSTEES").to_i %>
|
210
213
|
quorum: <%%= Decidim::Env.new("ELECTIONS_QUORUM").to_i %>
|
211
|
-
setup_minimum_hours_before_start: <%%= Decidim::Env.new("ELECTIONS_SETUP_MINIMUM_HOURS_BEFORE_START",
|
214
|
+
setup_minimum_hours_before_start: <%%= Decidim::Env.new("ELECTIONS_SETUP_MINIMUM_HOURS_BEFORE_START", 1).to_i %>
|
212
215
|
start_vote_maximum_hours_before_start: <%%= Decidim::Env.new("ELECTIONS_START_VOTE_MAXIMUM_HOURS_BEFORE_START", 6).to_i %>
|
213
216
|
voter_token_expiration_minutes: <%%= Decidim::Env.new("ELECTIONS_VOTER_TOKEN_EXPIRATION_MINUTES", 120).to_i %>
|
217
|
+
document_types: <%%= Decidim::Env.new("ELECTIONS_DOCUMENT_TYPES", "identification_number,passport").to_array.to_json %>
|
214
218
|
votings:
|
215
219
|
check_census_max_requests: <%%= Decidim::Env.new("VOTINGS_CHECK_CENSUS_MAX_REQUESTS", 5).to_i %>
|
216
220
|
throttling_period: <%%= Decidim::Env.new("VOTINGS_THROTTLING_PERIOD", 1).to_i %>
|
@@ -3,8 +3,10 @@
|
|
3
3
|
|
4
4
|
require "bundler"
|
5
5
|
require "thor"
|
6
|
+
require "json"
|
6
7
|
require "active_support/inflector"
|
7
8
|
require "decidim/core/version"
|
9
|
+
require "decidim/generators"
|
8
10
|
|
9
11
|
module Decidim
|
10
12
|
module Generators
|
@@ -17,7 +19,10 @@ module Decidim
|
|
17
19
|
:component_folder,
|
18
20
|
:component_description,
|
19
21
|
:core_version,
|
20
|
-
:
|
22
|
+
:npm_package_version,
|
23
|
+
:required_ruby_version,
|
24
|
+
:security_email,
|
25
|
+
:edge_git_branch
|
21
26
|
|
22
27
|
source_root File.expand_path("component_templates", __dir__)
|
23
28
|
|
@@ -30,8 +35,12 @@ module Decidim
|
|
30
35
|
@component_module_name = component_name.camelize
|
31
36
|
@component_folder = options[:destination_folder] || "decidim-module-#{component_name}"
|
32
37
|
@core_version = Decidim::Core.version
|
38
|
+
@npm_package_version = "^#{semver_friendly_version}"
|
39
|
+
@edge_git_branch = Decidim::Generators.edge_git_branch
|
33
40
|
@component_description = ask "Write a description for the new component:"
|
34
41
|
@required_ruby_version = RUBY_VERSION.length == 5 ? RUBY_VERSION[0..2] : RUBY_VERSION
|
42
|
+
@security_email = ask "Provide a public email in case of security concern:"
|
43
|
+
format_email!
|
35
44
|
|
36
45
|
template "decidim-component.gemspec.erb", "#{component_folder}/decidim-#{component_name}.gemspec"
|
37
46
|
template "Gemfile.erb", "#{component_folder}/Gemfile" if options[:external]
|
@@ -39,7 +48,13 @@ module Decidim
|
|
39
48
|
template "LICENSE-AGPLv3.txt", "#{component_folder}/LICENSE-AGPLv3.txt"
|
40
49
|
template "README.md.erb", "#{component_folder}/README.md"
|
41
50
|
template "gitignore", "#{component_folder}/.gitignore"
|
42
|
-
template "
|
51
|
+
template "github/ci.yml.erb", "#{component_folder}/.github/workflows/ci_#{component_name}.yml"
|
52
|
+
template "package.json.erb", "#{component_folder}/package.json"
|
53
|
+
copy_file ".ruby-version", "#{component_folder}/.ruby-version"
|
54
|
+
copy_file ".node-version", "#{component_folder}/.node-version"
|
55
|
+
copy_file ".rubocop.yml", "#{component_folder}/.rubocop.yml"
|
56
|
+
copy_file ".eslintrc.json", "#{component_folder}/.eslintrc.json"
|
57
|
+
copy_file ".stylelintrc.json", "#{component_folder}/.stylelintrc.json"
|
43
58
|
|
44
59
|
app_folder = "#{component_folder}/app"
|
45
60
|
template "app/packs/js/entrypoint.js", "#{app_folder}/packs/entrypoints/decidim_#{component_name}.js"
|
@@ -49,6 +64,7 @@ module Decidim
|
|
49
64
|
template "app/controllers/decidim/component/admin/application_controller.rb.erb", "#{app_folder}/controllers/decidim/#{component_name}/admin/application_controller.rb"
|
50
65
|
template "app/helpers/decidim/component/application_helper.rb.erb", "#{app_folder}/helpers/decidim/#{component_name}/application_helper.rb"
|
51
66
|
template "app/models/decidim/component/application_record.rb.erb", "#{app_folder}/models/decidim/#{component_name}/application_record.rb"
|
67
|
+
template "app/permissions/decidim/component/admin/permissions.rb.erb", "#{app_folder}/permissions/decidim/#{component_name}/admin/permissions.rb"
|
52
68
|
|
53
69
|
bin_folder = "#{component_folder}/bin"
|
54
70
|
template "bin/rails.erb", "#{bin_folder}/rails"
|
@@ -71,13 +87,32 @@ module Decidim
|
|
71
87
|
spec_folder = "#{component_folder}/spec"
|
72
88
|
template "spec/spec_helper.rb.erb", "#{spec_folder}/spec_helper.rb"
|
73
89
|
template "spec/factories.rb.erb", "#{spec_folder}/factories.rb"
|
90
|
+
template "spec/permissions/admin/permissions_spec.rb.erb", "#{spec_folder}/permissions/admin/permissions_spec.rb"
|
91
|
+
template "spec/lib/version_spec.rb.erb", "#{spec_folder}/lib/decidim/#{component_name}/version_spec.rb"
|
74
92
|
|
75
93
|
if options[:external]
|
76
94
|
inside(component_folder) do
|
77
95
|
Bundler.with_original_env { run "bundle install" }
|
96
|
+
Bundler.with_original_env { run "bundle lock --add-platform x86_64-linux" }
|
97
|
+
Bundler.with_original_env { run "bundle lock --add-platform ruby" }
|
78
98
|
end
|
79
99
|
end
|
80
100
|
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
def format_email!
|
105
|
+
return unless @security_email&.include?("@")
|
106
|
+
|
107
|
+
split = @security_email.split("@")
|
108
|
+
email = split.first
|
109
|
+
domain = split.last.gsub(".", " [dot] ")
|
110
|
+
@security_email = "#{email} [at] #{domain}"
|
111
|
+
end
|
112
|
+
|
113
|
+
def semver_friendly_version
|
114
|
+
Decidim::Generators.version.gsub(/\.pre/, "-pre").gsub(/\.dev/, "-dev").gsub(/.rc(\d*)/, "-rc\\1")
|
115
|
+
end
|
81
116
|
end
|
82
117
|
end
|
83
118
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
18.17.1
|
@@ -0,0 +1 @@
|
|
1
|
+
3.1.1
|
@@ -1,24 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
|
3
|
-
If you want to modify it you can do it in the Decidim::GemManager.patch_component_gemfile_generator method %>
|
2
|
+
|
4
3
|
source "https://rubygems.org"
|
5
4
|
|
6
5
|
ruby RUBY_VERSION
|
7
6
|
|
8
|
-
gem "decidim", "
|
7
|
+
gem "decidim", git: "https://github.com/decidim/decidim"
|
9
8
|
gem "decidim-<%= component_name %>", path: "."
|
10
9
|
|
11
|
-
gem "puma", ">=
|
10
|
+
gem "puma", ">= 4.3"
|
12
11
|
gem "bootsnap", "~> 1.4"
|
13
12
|
|
14
13
|
group :development, :test do
|
15
14
|
gem "byebug", "~> 11.0", platform: :mri
|
16
15
|
|
17
|
-
gem "decidim-dev", "
|
16
|
+
gem "decidim-dev", git: "https://github.com/decidim/decidim"
|
18
17
|
end
|
19
18
|
|
20
19
|
group :development do
|
21
|
-
gem "faker", "
|
20
|
+
gem "faker", "~> 2.14"
|
22
21
|
gem "letter_opener_web", "~> 2.0"
|
23
22
|
gem "listen", "~> 3.1"
|
24
23
|
gem "spring", "~> 2.0"
|
@@ -23,7 +23,13 @@ bundle
|
|
23
23
|
|
24
24
|
## Contributing
|
25
25
|
|
26
|
-
|
26
|
+
Contributions are welcome !
|
27
|
+
|
28
|
+
We expect the contributions to follow the [Decidim's contribution guide](https://github.com/decidim/decidim/blob/develop/CONTRIBUTING.adoc).
|
29
|
+
|
30
|
+
## Security
|
31
|
+
|
32
|
+
Security is very important to us. If you have any issue regarding security, please disclose the information responsibly by sending an email to __<%= security_email %>__ and not by creating a Github issue.
|
27
33
|
|
28
34
|
## License
|
29
35
|
|