decidim 0.8.4 → 0.9.0

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.

data/README.md CHANGED
@@ -41,7 +41,7 @@ Project management [[See on Waffle.io]](https://waffle.io/decidim/decidim)
41
41
 
42
42
  * [Get started with Decidim](#getting-started-with-decidim)
43
43
  * [Contribute to the project](#how-to-contribute)
44
- * [Decidim components](#officially-supported-libraries)
44
+ * [Officially supported modules](#officially-supported-modules)
45
45
  * [How to test Decidim engines](docs/testing.md)
46
46
  * [Create & browse development app](#browse-decidim)
47
47
  * [Technical tradeoffs](#technical-tradeoffs)
@@ -56,7 +56,7 @@ We've set up a guide on how to install, set up and upgrade Decidim. See the [Get
56
56
 
57
57
  ### As a Translator
58
58
 
59
- Decidim is already translated on multiple languages (English, Spanish, Catalan, Basque, Italian, Finnish, Dutch, French, Russian and Ukrainian). You can help us at [Crowdin, the translation service](https://crowdin.com/project/decidim), reviewing these translations or proposing a new language to add to the platform.
59
+ Decidim is already translated on multiple languages (English, Spanish, Catalan, Basque, Galician, Italian, Finnish, Dutch, French, Portuguese (and Brazilian Portuguese), Swedish, Russian and Ukrainian). You can help us at [Crowdin, the translation service](https://crowdin.com/project/decidim), reviewing these translations or proposing a new language to add to the platform.
60
60
 
61
61
  ### As a Developer
62
62
 
@@ -64,7 +64,7 @@ In order to develop on decidim, you'll need:
64
64
 
65
65
  * **Git** 2.15+
66
66
  * **PostgreSQL** 9.4+
67
- * **Ruby** 2.4.1
67
+ * **Ruby** 2.5.0 (2.3+ should work just fine, but that's the version we test against)
68
68
  * **NodeJS** 9.x.x (with `yarn` as a package manager)
69
69
  * **ImageMagick**
70
70
  * **Chrome** browser and [chromedriver](https://sites.google.com/a/chromium.org/chromedriver/).
@@ -106,24 +106,24 @@ After you create a development app (`bundle exec rake development_app`):
106
106
  * Go to 'http://localhost:3000/admin'
107
107
  * Login data: admin@example.org | decidim123456
108
108
 
109
- ## Officially supported libraries
110
-
111
- | Library | Description |
112
- | ------------- |-------------|
113
- | [Admin](https://github.com/decidim/decidim/tree/master/decidim-admin) | This library adds an administration dashboard so users can manage their organization and all other entities. |
114
- | [API](https://github.com/decidim/decidim/tree/master/decidim-api) | This library exposes a GraphQL API to programatically interact with the Decidim platform via HTTP |
115
- | [Assemblies](https://github.com/decidim/decidim/tree/master/decidim-assemblies) | Permanent participatory spaces. Currently in beta as an optional feature, can be included by explicitly adding `decidim-assemblies` to the Gemfile. |
116
- | [Budgets](https://github.com/decidim/decidim/tree/master/decidim-budgets) | Adds a participatory budgets system to any participatory space. |
117
- | [Comments](https://github.com/decidim/decidim/tree/master/decidim-comments) | The Comments module adds the ability to include comments to any resource which can be commentable by users. |
118
- | [Core](https://github.com/decidim/decidim/tree/master/decidim-core) | The basics of Decidim: users, organizations, etc. This is the only required engine to run Decidim, all the others are optional. |
119
- | [Participatory Processes](https://github.com/decidim/decidim/tree/master/decidim-participatory_processes) | The main concept of a Decidim installation: participatory processes. |
120
- | [Dev](https://github.com/decidim/decidim/tree/master/decidim-dev) | This gem aids the local development of Decidim's features. |
121
- | [Meeting](https://github.com/decidim/decidim/tree/master/decidim-meetings) | The Meeting module adds meeting to any participatory space. It adds a CRUD engine to the admin and public view scoped inside the participatory space. |
122
- | [Pages](https://github.com/decidim/decidim/tree/master/decidim-pages) | The Pages module adds static page capabilities to any participatory space. It basically provides an interface to include arbitrary HTML content to any step. |
123
- | [Proposals](https://github.com/decidim/decidim/tree/master/decidim-proposals) | The Proposals module adds one of the main features of Decidim: allows users to contribute to a participatory space by creating proposals. |
124
- | [Accountability](https://github.com/decidim/decidim/tree/master/decidim-accountability) | Adds an accountability section to any participatory space so users can follow along the state of the accepted proposals. |
125
- | [Surveys](https://github.com/decidim/decidim/tree/master/decidim-surveys) | Adds the ability for admins to create arbitrary surveys. |
126
- | [System](https://github.com/decidim/decidim/tree/master/decidim-system) | Multitenant Admin to manage multiple organizations in a single installation |
109
+ ## Officially supported modules
110
+
111
+ | Library | Description |
112
+ | --------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
113
+ | [Admin](https://github.com/decidim/decidim/tree/master/decidim-admin) | Adds an administration dashboard so users can manage their organization and all other entities. |
114
+ | [API](https://github.com/decidim/decidim/tree/master/decidim-api) | Exposes a GraphQL API to programatically interact with the Decidim platform via HTTP |
115
+ | [Assemblies](https://github.com/decidim/decidim/tree/master/decidim-assemblies) | Permanent participatory spaces. |
116
+ | [Budgets](https://github.com/decidim/decidim/tree/master/decidim-budgets) | Adds a participatory budgets system to any participatory space. |
117
+ | [Comments](https://github.com/decidim/decidim/tree/master/decidim-comments) | The Comments module adds the ability to include comments to any resource which can be commentable by users. |
118
+ | [Core](https://github.com/decidim/decidim/tree/master/decidim-core) | The basics of Decidim: users, organizations, etc. This is the only required engine to run Decidim, all the others are optional. |
119
+ | [Participatory Processes](https://github.com/decidim/decidim/tree/master/decidim-participatory_processes) | The main concept of a Decidim installation: participatory processes. |
120
+ | [Dev](https://github.com/decidim/decidim/tree/master/decidim-dev) | Aids the local development of Decidim's features. |
121
+ | [Meeting](https://github.com/decidim/decidim/tree/master/decidim-meetings) | The Meeting module adds meeting to any participatory space. It adds a CRUD engine to the admin and public view scoped inside the participatory space. |
122
+ | [Pages](https://github.com/decidim/decidim/tree/master/decidim-pages) | The Pages module adds static page capabilities to any participatory space. It basically provides an interface to include arbitrary HTML content to any step. |
123
+ | [Proposals](https://github.com/decidim/decidim/tree/master/decidim-proposals) | The Proposals module adds one of the main features of Decidim: allows users to contribute to a participatory space by creating proposals. |
124
+ | [Accountability](https://github.com/decidim/decidim/tree/master/decidim-accountability) | Adds an accountability section to any participatory space so users can follow along the state of the accepted proposals. |
125
+ | [Surveys](https://github.com/decidim/decidim/tree/master/decidim-surveys) | Adds the ability for admins to create arbitrary surveys. |
126
+ | [System](https://github.com/decidim/decidim/tree/master/decidim-system) | Multitenant Admin to manage multiple organizations in a single installation |
127
127
 
128
128
  ## Technical tradeoffs
129
129
 
data/Rakefile CHANGED
@@ -3,93 +3,54 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
  require "generators/decidim/app_generator"
6
- require "generators/decidim/docker_generator"
7
-
8
- DECIDIM_GEMS = %w(core system admin api participatory_processes assemblies pages meetings proposals comments accountability budgets surveys verifications dev).freeze
6
+ require "decidim/component_manager"
9
7
 
10
8
  RSpec::Core::RakeTask.new(:spec)
11
9
 
12
10
  task default: :spec
13
11
 
14
12
  desc "Runs all tests in all Decidim engines"
15
- task :test_all do
16
- tested_gems = DECIDIM_GEMS - ["dev"]
17
-
18
- dirs = [__dir__] + tested_gems.map { |name| "#{__dir__}/decidim-#{name}" }
13
+ task test_all: [:test_main, :test_subgems]
19
14
 
20
- dirs.each do |dir|
21
- Dir.chdir(dir) do
22
- puts "Running #{File.basename(dir)}'s tests..."
23
- status = system "rake"
24
- abort unless status || ENV["FAIL_FAST"] == "false"
25
- end
26
- end
15
+ desc "Runs all tests in decidim subgems"
16
+ task test_subgems: :test_app do
17
+ Decidim::ComponentManager.run_all("rake", include_root: false)
27
18
  end
28
19
 
29
- def replace_file(name, regexp, replacement)
30
- new_content = File.read(name).gsub(regexp, replacement)
31
-
32
- File.open(name, "w") { |f| f.write(new_content) }
33
- end
34
-
35
- def version
36
- File.read("#{__dir__}/.decidim-version").strip
20
+ desc "Runs all tests in the main decidim gem"
21
+ task :test_main do
22
+ Decidim::ComponentManager.new(__dir__).run("rake")
37
23
  end
38
24
 
39
25
  desc "Update version in all gems to the one set in the `.decidim-version` file"
40
26
  task :update_versions do
41
- replace_file(
42
- "#{__dir__}/package.json",
43
- /^ "version": "[^"]*"/,
44
- " \"version\": \"#{version.gsub(/\.pre/, "-pre")}\""
45
- )
46
-
47
- DECIDIM_GEMS.each do |name|
48
- replace_file(
49
- "#{__dir__}/decidim-#{name}/lib/decidim/#{name}/version.rb",
50
- /def self\.version(\s*)"[^"]*"/,
51
- "def self.version\\1\"#{version}\""
52
- )
53
- end
54
-
55
- replace_file(
56
- "#{__dir__}/lib/decidim/version.rb",
57
- /def self\.version(\s*)"[^"]*"/,
58
- "def self.version\\1\"#{version}\""
59
- )
27
+ Decidim::ComponentManager.replace_versions
60
28
  end
61
29
 
62
30
  desc "Installs all gems locally."
63
31
  task :install_all do
64
- system "rake install:local"
65
- DECIDIM_GEMS.each do |name|
66
- Dir.chdir("#{__dir__}/decidim-#{name}") do
67
- system "rake install:local"
68
- end
69
- end
32
+ Decidim::ComponentManager.run_all(
33
+ "rake install:local",
34
+ out: File::NULL
35
+ )
70
36
  end
71
37
 
72
38
  desc "Uninstalls all gems locally."
73
39
  task :uninstall_all do
74
- system("gem uninstall decidim -v #{version} --executables --force")
75
- DECIDIM_GEMS.each do |name|
76
- system("gem uninstall decidim-#{name} -v #{version} --executables --force")
77
- end
40
+ Decidim::ComponentManager.run_all(
41
+ "gem uninstall %name -v %version --executables --force",
42
+ out: File::NULL
43
+ )
78
44
  end
79
45
 
80
46
  desc "Pushes a new build for each gem."
81
47
  task release_all: [:update_versions, :check_locale_completeness, :webpack] do
82
- sh "rake release" rescue nil
83
- DECIDIM_GEMS.each do |name|
84
- Dir.chdir("#{__dir__}/decidim-#{name}") do
85
- sh "rake release" rescue nil
86
- end
87
- end
48
+ Decidim::ComponentManager.run_all("rake release")
88
49
  end
89
50
 
90
51
  desc "Makes sure all official locales are complete and clean."
91
52
  task :check_locale_completeness do
92
- system({ "ENFORCED_LOCALES" => "en,ca,es" }, "rspec spec/i18n_spec.rb")
53
+ system({ "ENFORCED_LOCALES" => "en,ca,es", "SKIP_NORMALIZATION" => "true" }, "rspec spec/i18n_spec.rb")
93
54
  end
94
55
 
95
56
  desc "Generates a dummy app for testing"
@@ -98,9 +59,7 @@ task :test_app do
98
59
 
99
60
  Dir.chdir(__dir__) do
100
61
  sh "rm -fR #{dummy_app_path}", verbose: false
101
- end
102
62
 
103
- Bundler.with_clean_env do
104
63
  Decidim::Generators::AppGenerator.start(
105
64
  [dummy_app_path, "--path", "../..", "--recreate_db", "--demo"]
106
65
  )
@@ -113,22 +72,9 @@ task :development_app do
113
72
  sh "rm -fR development_app", verbose: false
114
73
  end
115
74
 
116
- Bundler.with_clean_env do
117
- Decidim::Generators::AppGenerator.start(
118
- ["development_app", "--path", "..", "--recreate_db", "--seed_db", "--demo"]
119
- )
120
- end
121
- end
122
-
123
- desc "Generates a development app based on Docker."
124
- task :docker_development_app do
125
- docker_app_path = __dir__ + "/docker_development_app"
126
-
127
- Bundler.with_clean_env do
128
- Decidim::Generators::DockerGenerator.start(
129
- ["docker_development_app", "--docker_app_path", docker_app_path]
130
- )
131
- end
75
+ Decidim::Generators::AppGenerator.start(
76
+ ["development_app", "--path", "..", "--recreate_db", "--seed_db", "--demo"]
77
+ )
132
78
  end
133
79
 
134
80
  desc "Build webpack bundle files"
@@ -0,0 +1,58 @@
1
+ # Content processors
2
+
3
+ A content processor is a concept to refer to a set of two classes: a content parser class and a content renderer class.
4
+
5
+ The content parser class is used to process the text before it is saved to the database, and the associated renderer class is used to render the saved content.
6
+
7
+ ## How do I add a content processor?
8
+
9
+ Register the content processor in an `initializer`:
10
+
11
+ ```
12
+ Decidim.content_processors += [:special_words]
13
+ ```
14
+
15
+ Declare the parser class:
16
+
17
+ ```rb
18
+ class Decidim::ContentParsers::SpecialWordsParser < BaseParser
19
+ Metadata = Struct.new(:count)
20
+
21
+ def rewrite
22
+ content.gsub('foo', '~~foo~~')
23
+ end
24
+
25
+ def metadata
26
+ Metadata.new(content.scan('foo').size)
27
+ end
28
+ end
29
+ ```
30
+
31
+ And the renderer class:
32
+
33
+ ```rb
34
+ class Decidim::ContentRenderers::SpecialWordsRenderer < BaseRenderer
35
+ def render
36
+ content.gsub(/\~\~(.*?)\~\~/, '<del>\1</del>')
37
+ end
38
+ end
39
+ ```
40
+
41
+ ## How to use the content parser class
42
+
43
+ ```rb
44
+ parser = Decidim::ContentParsers::SpecialWordsParser.new(content)
45
+ parser.rewrite # returns the content rewritten
46
+ parser.metadata # returns a Metadata object
47
+ ```
48
+
49
+ ## How to use the content renderer class
50
+
51
+ ```rb
52
+ renderer = Decidim::ContentRenderers::SpecialWordsRenderer.new(content)
53
+ parser.render # returns the content formatted
54
+ ```
55
+
56
+ ## Additional documentation
57
+
58
+ You can check the docs in the base classes and the user processor.
@@ -0,0 +1,17 @@
1
+ # Authorizations
2
+
3
+ One particular thing about this kind of applications is the need to Authorize a given user. This is specially important when you want to have legally bindings decisions taken on the platform. There are several ways that this could be done:
4
+
5
+ * By sending a SMS code to users to verify that their have a valid cellphone
6
+
7
+ * By allowing users to upload a photo or scanned image of their identity document
8
+
9
+ * By sending users a code through postal code
10
+
11
+ * By allowing users to go to to a physical office and check their documentation
12
+
13
+ * By checking some information through other systems (as a Municipal Census on the case of Municipalities, Cities or Towns)
14
+
15
+ * By having a list of valid users emails
16
+
17
+ Right now Decidim supports only a few of these cases, but we have an internal API where you can program your own kind of verifications. You can go see some example code, read more about how to work with Decidim modules, or even see how it’s done for Decidim Barcelona, the Barcelona City Council.
@@ -0,0 +1,28 @@
1
+ # Code
2
+
3
+ Decidim is multiple things:
4
+
5
+ * A command line utility, which can create an application
6
+ * A set of libraries, that the application can use
7
+
8
+ Most of the time, you should work with the generated application. That application (development_app on this docs) should be named as your project, for instance for Barcelona City Council is `DecidimBarcelona`, so for creating it should be:
9
+
10
+ ```
11
+ decidim DecidimBarcelona
12
+ ```
13
+
14
+ If you want to override/change anything (for instance the homepage), you can just do it with the same name of the file, through Monkey Patching.
15
+
16
+ If you want to extend Decidim, the prefered way should be by having a Module. This is a Ruby on Rails Engine which provides ruby code (models, views, controllers, assets, etc). You can use it through multiple ways:
17
+
18
+ * Putting it on the same directory as your app and pointing on the Gemfile. [See example on GitHub](https://github.com/AjuntamentdeBarcelona/decidim-barcelona/tree/c210b5338d7ba1338c9879627e081da1441f1946). For instance:
19
+ ```
20
+ gem "decidim-debates", path: "decidim-debates"
21
+ ```
22
+
23
+ * Publishing on a git reposotory and pointing in on the Gemfile. For instance:
24
+ ```
25
+ gem "decidim-consultations", git: "https://github.com/decidim/decidim-module-consultations"
26
+ ```
27
+
28
+ * Publishing it on rubygems.org
@@ -0,0 +1,11 @@
1
+ # Gemfile
2
+
3
+ You can add and change your Gemfile as you want, this is a classic Ruby on Rails application. For example to add[ rails-footnotes](https://github.com/josevalim/rails-footnotes) gem you would just add:
4
+
5
+ ```
6
+ gem 'rails-footnotes', '~> 4.0'
7
+ ```
8
+
9
+ And then just do the classic Ruby on Rails flow bundle install and following any gem specific install steps from its own documentation.
10
+
11
+ You may also be interested on Adding a Decidim module.
@@ -0,0 +1,7 @@
1
+ # Images
2
+
3
+ You can change most of the images (for instance the logo, main banner on homepage, contents of participatory processes, etc) through the Administration panel.
4
+
5
+ If you want to override the standard images given by Decidim (for instance the initial image for user’s avatars) you can do it by naming it the same way as the original image, in this case it should be `app/assets/images/decidim/default-avatar.svg`
6
+
7
+ If you want to add a new image you can do it as any Rails application, leaving it on your image’s asset folder and using image_tag helper. You can see more documentation on [Rails guide](http://guides.rubyonrails.org/asset_pipeline.html).
@@ -0,0 +1,9 @@
1
+ # Javascript
2
+
3
+ If you want to add some custom Javascript code, just add it to app/assets/javascripts/application.js. For example to create a new alert just add:
4
+
5
+ ```
6
+ $(function(){
7
+ alert('foobar');
8
+ });
9
+ ```
@@ -0,0 +1,15 @@
1
+ # CSS Styles with SASS
2
+
3
+ One of the first things you’ll want to do after you install Decidim is applying your own corporative image. To do this, you can go to app/assets/stylesheets/application.css.sass on your generated application with your own colors. There you can override any class using CSS with SASS.
4
+
5
+ We use [SASS, with SCSS syntax](http://sass-lang.com/guide) as CSS preprocessor.
6
+
7
+ Also you can check your scss files syntax with
8
+
9
+ ```
10
+ scss-lint
11
+ ```
12
+
13
+ ## **Accesibility**
14
+
15
+ To maintain accesibility level, if you add new colors use a[ Color contrast checker](http://webaim.org/resources/contrastchecker/) (WCAG AA is mandatory, WCAG AAA is recommended)
@@ -0,0 +1,15 @@
1
+ # Custom Texts
2
+
3
+ You can change most of the texts through the Administration panel.
4
+
5
+ If you want to change a given text that isn’t on the Administration panel, and belongs on Decidim code, you should first find out which key is being used. For instance, we want to change the home page text where it says "Let's build a more open, transparent and collaborative society.", we would search the text (using [github](https://github.com/decidim/decidim/search?utf8=%E2%9C%93&q=%22Let%27s+build+a+more+open%2C+transparent+and+collaborative+society.%22&type= ) or grep) and then I’d extract that key and their parents. On this case it’d be:
6
+
7
+ ```yml
8
+ en:
9
+ pages:
10
+ home:
11
+ footer_sub_hero:
12
+ footer_sub_hero_body: Let's build a more open, transparent and collaborative society.<br /> Join, participate and decide.
13
+ ```
14
+
15
+ We need to create a file for this translation as Rails documentation says, for instance config/locales/home.en.yml
@@ -0,0 +1,5 @@
1
+ # Views (HTML)
2
+
3
+ If you want to add a new HTML page, you can do this by working as a regular Rails application.
4
+
5
+ If you want to override a view or partial given by Decidim you can do this just by naming it with the same filename that you already have.
@@ -35,6 +35,7 @@ Afterwards, you can create an application with the nice `decidim` executable:
35
35
  ```
36
36
  $ decidim decidim_application
37
37
  $ cd decidim_application
38
+ $ bundle install
38
39
  ```
39
40
 
40
41
  ### Initializing your app for local development
@@ -78,8 +79,6 @@ We also have other guides on how to configure some extra features:
78
79
 
79
80
  ## Deploy
80
81
 
81
- Once you've generated the Decidim app you might need to do some changes in order to deploy it. You can check [`codegram/decidim-deploy-heroku`](https://github.com/codegram/decidim-deploy-heroku) for an opinionated example of things to do before deploying to Heroku, for example.
82
-
83
82
  Once you've successfully deployed your app to your favorite platform, you'll need to create your `System` user. First you'll need to create your `Decidim::System` user in your production Ruby on Rails console:
84
83
 
85
84
  ```ruby
@@ -103,7 +102,7 @@ If you want, you can create seed data in production. Run this command in your pr
103
102
  $ SEED=true rails db:seed
104
103
  ```
105
104
 
106
- If you used Codegram's [`decidim-deploy-heroku`](https://github.com/codegram/decidim-deploy-heroku), then you're all set. Otherwise you'll need to login as system user and edit the host for the organization. Set it to you production host, without the protocol and the port (so if your host is `https://my.host:3001`, you need to write `my.host`).
105
+ You'll need to login as system user and edit the host for the organization. Set it to you production host, without the protocol and the port (so if your host is `https://my.host:3001`, you need to write `my.host`).
107
106
 
108
107
  ## Keeping your app up-to-date
109
108
 
@@ -23,7 +23,7 @@
23
23
  s.email = ["your_eamail@example.org"]
24
24
  s.license = "AGPL-3.0"
25
25
  s.homepage = "https://github.com/decidim/decidim"
26
- s.required_ruby_version = ">= 2.3.1"
26
+ s.required_ruby_version = ">= 2.4.2"
27
27
 
28
28
  s.name = "decidim-<engine_name>"
29
29
  s.summary = "<engine_description>"
@@ -156,8 +156,13 @@
156
156
  Decidim::Dev.dummy_app_path = File.expand_path(File.join("..", "spec", "decidim_dummy_app"))
157
157
 
158
158
  require "decidim/dev/test/base_spec_helper"
159
+
159
160
  ```
160
161
 
162
+ 1. Upload to GitHub with the naming *decidim-module-<engine_name>*, so it's easier to find on
163
+ the [dependency graph](https://github.com/decidim/decidim/network/dependents).
164
+
165
+
161
166
  ## Experimental way
162
167
 
163
168
  Plugin creation is being automated in