decidim 0.10.1 → 0.11.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim might be problematic. Click here for more details.

Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -7
  3. data/Rakefile +17 -31
  4. data/docs/add_authenticable_action.md +12 -5
  5. data/docs/adding_fixtures_aka_dummy_content.md +4 -2
  6. data/docs/advanced/components.md +60 -0
  7. data/docs/advanced/content_processors.md +20 -0
  8. data/docs/advanced/followers.md +2 -2
  9. data/docs/advanced/view_models_aka_cells.md +91 -0
  10. data/docs/checklist.md +47 -0
  11. data/docs/customization/code.md +5 -3
  12. data/docs/customization/gemfile.md +2 -2
  13. data/docs/customization/javascript.md +1 -1
  14. data/docs/customization/oauth.md +23 -0
  15. data/docs/customization/styles.md +3 -7
  16. data/docs/data-picker.md +10 -3
  17. data/docs/getting_started.md +60 -25
  18. data/docs/services/analytics.md +1 -1
  19. data/docs/services/geocoding.md +4 -4
  20. data/docs/services/social_providers.md +26 -26
  21. data/lib/decidim.rb +2 -0
  22. data/lib/decidim/{component_manager.rb → gem_manager.rb} +49 -4
  23. data/lib/decidim/version.rb +1 -1
  24. metadata +82 -55
  25. data/Gemfile +0 -26
  26. data/Gemfile.lock +0 -606
  27. data/bin/decidim +0 -6
  28. data/docs/advanced/features.md +0 -60
  29. data/lib/generators/decidim/app_generator.rb +0 -159
  30. data/lib/generators/decidim/install_generator.rb +0 -138
  31. data/lib/generators/decidim/templates/Dockerfile.erb +0 -1
  32. data/lib/generators/decidim/templates/README.md.erb +0 -22
  33. data/lib/generators/decidim/templates/cable.yml.erb +0 -9
  34. data/lib/generators/decidim/templates/carrierwave.rb +0 -28
  35. data/lib/generators/decidim/templates/database.yml.erb +0 -87
  36. data/lib/generators/decidim/templates/decidim.scss.erb +0 -3
  37. data/lib/generators/decidim/templates/decidim_controller.rb.erb +0 -5
  38. data/lib/generators/decidim/templates/docker-compose.yml.erb +0 -26
  39. data/lib/generators/decidim/templates/example_authorization_handler.rb +0 -55
  40. data/lib/generators/decidim/templates/initializer.rb +0 -47
  41. data/lib/generators/decidim/templates/secrets.yml.erb +0 -61
  42. data/lib/generators/decidim/templates/social_share_button.rb +0 -8
data/bin/decidim DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require_relative "../lib/generators/decidim/app_generator"
5
-
6
- Decidim::Generators::AppGenerator.start
@@ -1,60 +0,0 @@
1
- # Features
2
-
3
- Features are the core contract between external modules and the core. They're used to define pieces of functionality that are pluggable to participatory processes and can be enabled or disabled by the administrator.
4
-
5
- ## How do I create a new feature?
6
-
7
- Features are just gems with one or more Rails engines included in it. You can use as an example [decidim-pages](https://github.com/decidim/decidim/tree/master/decidim-pages).
8
-
9
- Check out the `lib/decidim/pages` folder: It includes several files, the most important of which is `feature.rb`.
10
-
11
- ## Defining a feature manifest
12
-
13
- Features are defined in a manifest, along with its engine and admin engine counterpart.
14
-
15
- There's a DSL available to describe all this:
16
-
17
- ```ruby
18
- # :my_feature is the unique name of the feature that will be globally registered.
19
- Decidim.register_feature(:my_feature) do |feature|
20
- # The user will be redirected to the feature's engine when accessing it through
21
- # the public page of a participatory process. A feature's engine is isolated
22
- # from the outside so it can deal with its own dependencies without having to
23
- # know its render path or its parent resources.
24
- feature.engine = MyFeature::Engine
25
-
26
- # A component's admin engine will get rendered on the admin panel and follows
27
- # the same principles as the engine. It's isolated from the outside and
28
- # doesn't care about external dependencies. It only needs to care about its
29
- # underlying `feature`.
30
- feature.admin_engine = MyFeature::AdminEngine
31
-
32
- # Feature hooks get called whenever relevant lifecycle events happen, like
33
- # adding a new feature o destroying it. You always get passed the instance
34
- # so you can act on it. Creating or destroying a comoponent is transactional
35
- # along with its hooks, so you can decide to halt the transaction by raising
36
- # an exception.
37
- #
38
- # Valid hook names are :create and :destroy.
39
- feature.on(:create) do |feature|
40
- MyFeature::DoSomething.with(feature)
41
- end
42
-
43
- # Export definitions allow features to declare any number of exportable files.
44
- #
45
- # An export definition needs a unique name, a collection, and a Serializer. If
46
- # no serializer is provided, a default, naive one will be used.
47
- #
48
- # Exports are then exposed via the UI, so the implementer only needs to care
49
- # about the export definitions.
50
- feature.exports :feature_resources do |exports|
51
- exports.collection do |feature|
52
- MyFeature::Resource.where(feature: feature)
53
- end
54
-
55
- exports.serializer MyFeature::ResourceSerializer
56
- end
57
- end
58
- ```
59
-
60
- Every model in a feature doesn't have to (and should not) know about its parent participatory process, but instead should be scoped to the features.
@@ -1,159 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler"
4
- require "rails/generators"
5
- require "rails/generators/rails/app/app_generator"
6
- require "decidim/version"
7
- require_relative "install_generator"
8
-
9
- module Decidim
10
- module Generators
11
- # Generates a Rails app and installs decidim to it. Uses the default Rails
12
- # generator for most of the work.
13
- #
14
- # Remember that, for how generators work, actions are executed based on the
15
- # definition order of the public methods.
16
- class AppGenerator < Rails::Generators::AppGenerator
17
- hide!
18
-
19
- def source_paths
20
- [
21
- File.expand_path("templates", __dir__),
22
- Rails::Generators::AppGenerator.source_root
23
- ]
24
- end
25
-
26
- source_root File.expand_path("templates", __dir__)
27
-
28
- class_option :path, type: :string,
29
- default: nil,
30
- desc: "Path to the gem"
31
-
32
- class_option :edge, type: :boolean,
33
- default: false,
34
- desc: "Use GitHub's edge version from master branch"
35
-
36
- class_option :branch, type: :string,
37
- default: nil,
38
- desc: "Use a specific branch from GitHub's version"
39
-
40
- class_option :recreate_db, type: :boolean,
41
- default: false,
42
- desc: "Recreate test database"
43
-
44
- class_option :seed_db, type: :boolean,
45
- default: false,
46
- desc: "Seed test database"
47
-
48
- class_option :skip_bundle, type: :boolean,
49
- default: true,
50
- desc: "Don't run bundle install"
51
-
52
- class_option :skip_gemfile, type: :boolean,
53
- default: false,
54
- desc: "Don't generate a Gemfile for the application"
55
-
56
- class_option :demo, type: :boolean,
57
- default: false,
58
- desc: "Generate a demo authorization handler"
59
-
60
- def database_yml
61
- template "database.yml.erb", "config/database.yml", force: true
62
- end
63
-
64
- def decidim_controller
65
- template "decidim_controller.rb.erb", "app/controllers/decidim_controller.rb", force: true
66
- end
67
-
68
- def docker
69
- template "Dockerfile.erb", "Dockerfile"
70
- template "docker-compose.yml.erb", "docker-compose.yml"
71
- end
72
-
73
- def cable_yml
74
- template "cable.yml.erb", "config/cable.yml", force: true
75
- end
76
-
77
- def readme
78
- template "README.md.erb", "README.md", force: true
79
- end
80
-
81
- def gemfile
82
- return if options[:skip_gemfile]
83
-
84
- template target_gemfile, "Gemfile", force: true
85
- template "#{target_gemfile}.lock", "Gemfile.lock", force: true
86
-
87
- gem_modifier = if options[:path]
88
- "path: \"#{options[:path]}\""
89
- elsif options[:edge]
90
- "git: \"https://github.com/decidim/decidim.git\""
91
- elsif options[:branch]
92
- "git: \"https://github.com/decidim/decidim.git\", branch: \"#{options[:branch]}\""
93
- else
94
- "\"#{Decidim.version}\""
95
- end
96
-
97
- gsub_file "Gemfile", /gem "#{current_gem}".*/, "gem \"#{current_gem}\", #{gem_modifier}"
98
- gsub_file "Gemfile", /gem "decidim-dev".*/, "gem \"decidim-dev\", #{gem_modifier}" if current_gem == "decidim"
99
-
100
- Bundler.with_original_env { run "bundle install" }
101
- end
102
-
103
- def add_ignore_uploads
104
- append_file ".gitignore", "\n# Ignore public uploads\npublic/uploads" unless options["skip_git"]
105
- end
106
-
107
- def remove_default_error_pages
108
- remove_file "public/404.html"
109
- remove_file "public/500.html"
110
- end
111
-
112
- def authorization_handler
113
- template "initializer.rb", "config/initializers/decidim.rb"
114
-
115
- template "example_authorization_handler.rb", "app/services/example_authorization_handler.rb" if options[:demo]
116
- end
117
-
118
- def install
119
- Decidim::Generators::InstallGenerator.start(
120
- [
121
- "--recreate_db=#{options[:recreate_db]}",
122
- "--seed_db=#{options[:seed_db]}",
123
- "--app_name=#{app_name}"
124
- ]
125
- )
126
- end
127
-
128
- private
129
-
130
- def current_gem
131
- return "decidim" unless options[:path]
132
-
133
- File.read(gemspec).match(/name\s*=\s*['"](?<name>.*)["']/)[:name]
134
- end
135
-
136
- def gemspec
137
- File.expand_path(Dir.glob("*.gemspec", base: expanded_path).first, expanded_path)
138
- end
139
-
140
- def target_gemfile
141
- root = if options[:path]
142
- expanded_path
143
- else
144
- decidim_root
145
- end
146
-
147
- File.join(root, "Gemfile")
148
- end
149
-
150
- def expanded_path
151
- File.expand_path(options[:path])
152
- end
153
-
154
- def decidim_root
155
- File.expand_path(File.join("..", "..", ".."), __dir__)
156
- end
157
- end
158
- end
159
- end
@@ -1,138 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rails/generators/base"
4
- require "securerandom"
5
-
6
- module Decidim
7
- module Generators
8
- # Installs `decidim` to a Rails app by adding the needed lines of code
9
- # automatically to important files in the Rails app.
10
- #
11
- # Remember that, for how generators work, actions are executed based on the
12
- # definition order of the public methods.
13
- class InstallGenerator < Rails::Generators::Base
14
- desc "Install decidim"
15
- source_root File.expand_path("templates", __dir__)
16
-
17
- class_option :app_name, type: :string, default: nil,
18
- desc: "The name of the app"
19
- class_option :recreate_db, type: :boolean, default: false,
20
- desc: "Recreate db after installing decidim"
21
- class_option :seed_db, type: :boolean, default: false,
22
- desc: "Seed db after installing decidim"
23
-
24
- def install
25
- route "mount Decidim::Core::Engine => '/'"
26
- end
27
-
28
- def add_seeds
29
- append_file "db/seeds.rb", <<~RUBY
30
- # You can remove the 'faker' gem if you don't want Decidim seeds.
31
- Decidim.seed!
32
- RUBY
33
- end
34
-
35
- def copy_initializer
36
- template "carrierwave.rb", "config/initializers/carrierwave.rb"
37
- template "social_share_button.rb", "config/initializers/social_share_button.rb"
38
- end
39
-
40
- def secrets
41
- template "secrets.yml.erb", "config/secrets.yml", force: true
42
- end
43
-
44
- def remove_layout
45
- remove_file "app/views/layouts/application.html.erb"
46
- remove_file "app/views/layouts/mailer.text.erb"
47
- end
48
-
49
- def append_assets
50
- append_file "app/assets/javascripts/application.js", "//= require decidim"
51
- gsub_file "app/assets/javascripts/application.js", %r{//= require turbolinks\n}, ""
52
- inject_into_file "app/assets/stylesheets/application.css",
53
- before: "*= require_tree ." do
54
- "*= require decidim\n "
55
- end
56
-
57
- template "decidim.scss.erb", "app/assets/stylesheets/decidim.scss", force: true
58
- end
59
-
60
- def configure_js_compressor
61
- gsub_file "config/environments/production.rb", "config.assets.js_compressor = :uglifier", "config.assets.js_compressor = Uglifier.new(:harmony => true)"
62
- end
63
-
64
- def smtp_environment
65
- inject_into_file "config/environments/production.rb",
66
- after: "config.log_formatter = ::Logger::Formatter.new" do
67
- cut <<~RUBY
68
- |
69
- | config.action_mailer.smtp_settings = {
70
- | :address => Rails.application.secrets.smtp_address,
71
- | :port => Rails.application.secrets.smtp_port,
72
- | :authentication => Rails.application.secrets.smtp_authentication,
73
- | :user_name => Rails.application.secrets.smtp_username,
74
- | :password => Rails.application.secrets.smtp_password,
75
- | :domain => Rails.application.secrets.smtp_domain,
76
- | :enable_starttls_auto => Rails.application.secrets.smtp_starttls_auto,
77
- | :openssl_verify_mode => 'none'
78
- | }
79
- RUBY
80
- end
81
- end
82
-
83
- def copy_migrations
84
- rails "railties:install:migrations"
85
- recreate_db if options[:recreate_db]
86
- end
87
-
88
- def letter_opener_web
89
- letter_opener_route = cut <<~RUBY
90
- |
91
- | if Rails.env.development?
92
- | mount LetterOpenerWeb::Engine, at: "/letter_opener"
93
- | end
94
- RUBY
95
-
96
- route letter_opener_route
97
-
98
- inject_into_file "config/environments/development.rb",
99
- after: "config.action_mailer.raise_delivery_errors = false" do
100
- cut <<~RUBY
101
- |
102
- | config.action_mailer.delivery_method = :letter_opener_web
103
- | config.action_mailer.default_url_options = { port: 3000 }
104
- RUBY
105
- end
106
- end
107
-
108
- private
109
-
110
- def recreate_db
111
- soft_rails "db:environment:set", "db:drop"
112
- rails "db:create"
113
- rails "db:migrate"
114
- rails "db:seed" if options[:seed_db]
115
- rails "db:test:prepare"
116
- end
117
-
118
- # Runs rails commands in a subprocess, and aborts if it doesn't suceeed
119
- def rails(*args)
120
- abort unless system("bin/rails", *args)
121
- end
122
-
123
- # Runs rails commands in a subprocess silencing errors, and ignores status
124
- def soft_rails(*args)
125
- system("bin/rails", *args, err: File::NULL)
126
- end
127
-
128
- def scss_variables
129
- variables = File.join(Gem.loaded_specs["decidim-core"].full_gem_path, "app", "assets", "stylesheets", "decidim", "_variables.scss")
130
- File.read(variables).split("\n").map { |line| "// #{line}".gsub(" !default", "") }.join("\n")
131
- end
132
-
133
- def cut(text)
134
- text.gsub(/^ *\|/, "").rstrip
135
- end
136
- end
137
- end
138
- end
@@ -1 +0,0 @@
1
- FROM decidim/decidim:<%= Decidim.version %>
@@ -1,22 +0,0 @@
1
- # <%= app_name %>
2
-
3
- Citizen Participation and Open Government application.
4
-
5
- This is the open-source repository for <%= app_name %>, based on [Decidim](https://github.com/decidim/decidim).
6
-
7
- ## Setting up the application
8
-
9
- You will need to do some steps before having the app working properly once you've deployed it:
10
-
11
- 1. Open a Rails console in the server: `bundle exec rails console`
12
- 2. Create a System Admin user:
13
- ```ruby
14
- user = Decidim::System::Admin.new(email: <email>, password: <password>, password_confirmation: <password>)
15
- user.save!
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.
21
-
22
- You're good to go!
@@ -1,9 +0,0 @@
1
- development:
2
- adapter: async
3
-
4
- test:
5
- adapter: async
6
-
7
- production:
8
- adapter: redis
9
- url: <%%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %>
@@ -1,28 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Default CarrierWave setup.
4
- #
5
- CarrierWave.configure do |config|
6
- config.permissions = 0o666
7
- config.directory_permissions = 0o777
8
- config.storage = :file
9
- config.enable_processing = !Rails.env.test?
10
- end
11
-
12
- # Setup CarrierWave to use Amazon S3. Add `gem "fog-aws" to your Gemfile.
13
- #
14
- # CarrierWave.configure do |config|
15
- # config.storage = :fog
16
- # config.fog_provider = 'fog/aws' # required
17
- # config.fog_credentials = {
18
- # provider: 'AWS', # required
19
- # aws_access_key_id: Rails.application.secrets.aws_access_key_id, # required
20
- # aws_secret_access_key: Rails.application.secrets.aws_secret_access_key, # required
21
- # region: 'eu-west-1', # optional, defaults to 'us-east-1'
22
- # host: 's3.example.com', # optional, defaults to nil
23
- # endpoint: 'https://s3.example.com:8080' # optional, defaults to nil
24
- # }
25
- # config.fog_directory = 'name_of_directory' # required
26
- # config.fog_public = false # optional, defaults to true
27
- # config.fog_attributes = { 'Cache-Control' => "max-age=#{365.day.to_i}" } # optional, defaults to {}
28
- # end
@@ -1,87 +0,0 @@
1
- # PostgreSQL. Versions 9.1 and up are supported.
2
- #
3
- # Install the pg driver:
4
- # gem install pg
5
- # On OS X with Homebrew:
6
- # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7
- # On OS X with MacPorts:
8
- # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9
- # On Windows:
10
- # gem install pg
11
- # Choose the win32 build.
12
- # Install PostgreSQL and put its /bin directory on your path.
13
- #
14
- # Configure Using Gemfile
15
- # gem 'pg'
16
- #
17
- # On Linux, the 'host: "localhost"' line below should be commented out to avoid 'password required' error.
18
- #
19
- default: &default
20
- adapter: postgresql
21
- encoding: unicode
22
- # For details on connection pooling, see rails configuration guide
23
- # http://guides.rubyonrails.org/configuring.html#database-pooling
24
- pool: <%%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
25
- host: <%%= ENV.fetch("DATABASE_HOST") { "localhost" } %>
26
- username: <%%= ENV.fetch("DATABASE_USERNAME") { "" } %>
27
- password: <%%= ENV.fetch("DATABASE_PASSWORD") { "" } %>
28
-
29
- development:
30
- <<: *default
31
- database: <%%= ENV.fetch("DEV_DATABASE_NAME") { "<%= app_name %>_development" } %>
32
-
33
- # The specified database role being used to connect to postgres.
34
- # To create additional roles in postgres see `$ createuser --help`.
35
- # When left blank, postgres will use the default role. This is
36
- # the same name as the operating system user that initialized the database.
37
- #username: <%= app_name %>
38
-
39
- # The password associated with the postgres role (username).
40
- #password:
41
-
42
- # Connect on a TCP socket. Omitted by default since the client uses a
43
- # domain socket that doesn't need configuration. Windows does not have
44
- # domain sockets, so uncomment these lines.
45
- #host: localhost
46
-
47
- # The TCP port the server listens on. Defaults to 5432.
48
- # If your server runs on a different port number, change accordingly.
49
- #port: 5432
50
-
51
- # Schema search path. The server defaults to $user,public
52
- #schema_search_path: myapp,sharedapp,public
53
-
54
- # Minimum log levels, in increasing order:
55
- # debug5, debug4, debug3, debug2, debug1,
56
- # log, notice, warning, error, fatal, and panic
57
- # Defaults to warning.
58
- #min_messages: notice
59
-
60
- # Warning: The database defined as "test" will be erased and
61
- # re-generated from your development database when you run "rake".
62
- # Do not set this db to the same as development or production.
63
- test:
64
- <<: *default
65
- database: <%%= ENV.fetch("TEST_DATABASE_NAME") { "<%= app_name %>_test" } %>
66
-
67
- # As with config/secrets.yml, you never want to store sensitive information,
68
- # like your database password, in your source code. If your source code is
69
- # ever seen by anyone, they now have access to your database.
70
- #
71
- # Instead, provide the password as a unix environment variable when you boot
72
- # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
73
- # for a full rundown on how to provide these environment variables in a
74
- # production deployment.
75
- #
76
- # On some platform providers, you may have a full connection URL
77
- # available as an environment variable. For example:
78
- #
79
- # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
80
- #
81
- # You can use this database configuration with:
82
- #
83
- # production:
84
- # url: <%%= ENV['DATABASE_URL'] %>
85
- #
86
- production:
87
- url: <%%= ENV['DATABASE_URL'] %>