decidim 0.20.1 → 0.23.1
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.
- checksums.yaml +4 -4
- data/README.md +35 -51
- data/docs/advanced/api.md +15 -0
- data/docs/advanced/authorship.md +1 -2
- data/docs/advanced/components.md +40 -0
- data/docs/advanced/content_blocks.md +5 -3
- data/docs/advanced/data-picker.md +37 -9
- data/docs/advanced/embeddable.md +20 -0
- data/docs/advanced/endorsable.md +113 -0
- data/docs/advanced/fixing_locales.md +88 -0
- data/docs/advanced/how_to_fix_metrics.md +238 -0
- data/docs/advanced/machine_translation_service.md +12 -0
- data/docs/advanced/metrics.md +8 -10
- data/docs/advanced/newsletter_templates.md +64 -0
- data/docs/advanced/notifications.md +114 -0
- data/docs/advanced/permissions.md +23 -0
- data/docs/advanced/profiling.md +43 -0
- data/docs/advanced/releases.md +114 -0
- data/docs/advanced/share_tokens.md +53 -0
- data/docs/advanced/templates.md +56 -0
- data/docs/advanced/testing.md +3 -0
- data/docs/customization/machine_translations.md +30 -0
- data/docs/customization/maps.md +610 -0
- data/docs/customization/views.md +31 -2
- data/docs/development_guide.md +55 -43
- data/docs/getting_started.md +14 -4
- data/docs/manual-installation.md +4 -0
- data/docs/services/elections_bulletin_board.md +38 -0
- data/docs/services/etherpad.md +37 -2
- data/docs/services/maps.md +362 -0
- data/docs/services/social_providers.md +49 -11
- data/lib/decidim/gem_manager.rb +1 -1
- data/lib/decidim/version.rb +1 -1
- metadata +61 -45
- data/docs/services/geocoding.md +0 -34
data/docs/customization/views.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# Views (HTML)
|
2
2
|
|
3
|
-
|
3
|
+
As usual you should make some tests with the changes that you made and configure a Continuous Integration environment for checking that your overrides doesn't get removed with new decidim versions.
|
4
4
|
|
5
|
-
|
5
|
+
## Overrides
|
6
|
+
|
7
|
+
To find what you need to change you'll need to make some detective work to find out which partial or view do you need to change. You can do so by:
|
8
|
+
|
9
|
+
- looking at your application log and finding the lines that start with "Rendered"
|
10
|
+
- inspecting with the web development tools of your browser, copying a special class and using `grep`, github search or your IDE search by multiple files to find out on which file this exists.
|
11
|
+
|
12
|
+
### Filename method
|
13
|
+
|
14
|
+
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. On more details, if you want to change the social media icons on the footer, you can do so by looking at which file you need to change, copying that file to your application with the same filename and directory structure, and making your local changes.
|
15
|
+
|
16
|
+
As an example, if I want to change the footer, you'd need to search for the file (on this case, it's on [`decidim-core/app/views/layouts/decidim/_mini_footer.html.erb`](https://github.com/decidim/decidim/blob/e181d7e67bdf915a3a8e58416c683f52346de047/decidim-core/app/views/layouts/decidim/_mini_footer.html.erb)), and copy that file to your own application on `app/views/layouts/decidim/_mini_footer.html.erb`).
|
17
|
+
|
18
|
+
## Deface method
|
19
|
+
|
20
|
+
You'll need the [`deface` gem](https://github.com/spree/deface) installed on your application, and follow their instructions on how to use the different overridign methods that they support.
|
21
|
+
|
22
|
+
As an example, if you want to change the footer, you can do so by creating the file `app/overrides/layouts/decidim/_main_footer/pre_footer.html.erb.deface` with these contents:
|
23
|
+
|
24
|
+
```html
|
25
|
+
<!-- insert_before ".main-footer" -->
|
26
|
+
hello world
|
27
|
+
```
|
28
|
+
|
29
|
+
## New pages
|
30
|
+
|
31
|
+
If you want to add a new HTML page, you can do this by working as a regular Rails application (ie, you can scaffold a new view and work with the HTML as usual).
|
32
|
+
|
33
|
+
As an example of how to do this on Decidim Barcelona application, there's the [StaticController](
|
34
|
+
https://github.com/AjuntamentdeBarcelona/decidim-barcelona/blob/d47d4a9ae6be26a0c5c4000907dda3c195579636/app/controllers/static_controller.rb) (main accountability section pages). You should inherit your controller from Decidim::ApplicationController.
|
data/docs/development_guide.md
CHANGED
@@ -30,6 +30,55 @@ Once created you are ready to:
|
|
30
30
|
|
31
31
|
- `bin/rails s`
|
32
32
|
|
33
|
+
## GitFlow Branching model
|
34
|
+
|
35
|
+
The Decidim respository follows the GitFlow branching model. There are good documentations on it at:
|
36
|
+
|
37
|
+
- the original post: https://nvie.com/posts/a-successful-git-branching-model/
|
38
|
+
- provided by Atlassian: https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow.
|
39
|
+
|
40
|
+
This model introduces the `develop` branch as a kind of queue for new features to enter into the next release.
|
41
|
+
|
42
|
+
In summary, Decidim developers that work on `feature/...` or `fix/...` branches will branch off from `develop` and must be merged back into `develop`.
|
43
|
+
|
44
|
+
Then, to start a new feature branch off from `develop` in the following way:
|
45
|
+
|
46
|
+
```bash
|
47
|
+
git checkout develop
|
48
|
+
git checkout -b feature/xxx
|
49
|
+
```
|
50
|
+
|
51
|
+
Implement the feature, and open a Pull Request as normal, but against `develop` branch. As this is the most common operation, `develop` is the default branch instead of `master`.
|
52
|
+
|
53
|
+
### Naming Decidim branches
|
54
|
+
|
55
|
+
We would like to have all branches following this namings:
|
56
|
+
|
57
|
+
| Branch prefix | Comment |
|
58
|
+
| -------- | -------- |
|
59
|
+
| chore/ | Internal work. For instance, automatisms, etc. No production code change. |
|
60
|
+
| ci/ | For continous integration related tasks. No production code change. |
|
61
|
+
| deps/ | For dependency management tasks. |
|
62
|
+
| doc/ | For changes to the documentation. |
|
63
|
+
| feature/ | For new features for the users or for the Decidim command. |
|
64
|
+
| fix/ | For feature bugfixing. |
|
65
|
+
| release/ | With MAYOR.MINOR-stable. For instance, release/0.22-stable |
|
66
|
+
| refactor/ | For refactorings related with production code. |
|
67
|
+
| test/ | When adding missing tests, refactoring tests, improving coverage, etc. |
|
68
|
+
| backport/ | We only offer support for the last mayor version. |
|
69
|
+
|
70
|
+
## Git commit messages and Pull Request titles
|
71
|
+
|
72
|
+
We recommend following [this guide](https://chris.beams.io/posts/git-commit/) for making good git commit messages. It also applies to Pull Request titles. The summary is:
|
73
|
+
|
74
|
+
1. Separate subject from body with a blank line
|
75
|
+
1. Limit the subject line to 50 characters
|
76
|
+
1. Capitalize the subject line
|
77
|
+
1. Do not end the subject line with a period
|
78
|
+
1. Use the imperative mood in the subject line
|
79
|
+
1. Wrap the body at 72 characters
|
80
|
+
1. Use the body to explain what and why vs. how
|
81
|
+
|
33
82
|
## During development
|
34
83
|
|
35
84
|
When creating new migrations in Decidim's modules, you will need to "apply" this migrations to your development_app. The way to do this is by copying the migration from your module into the db/migrate dir of your development_app. Luckily we already have a script that automates this: it copies all missing migrations in development_app/db/migrate. The command is:
|
@@ -38,6 +87,8 @@ When creating new migrations in Decidim's modules, you will need to "apply" this
|
|
38
87
|
bin/rails decidim:upgrade
|
39
88
|
```
|
40
89
|
|
90
|
+
Anyway we recommend re-creating your development_app every once in a while.
|
91
|
+
|
41
92
|
## Useful commands
|
42
93
|
|
43
94
|
### erb-lint
|
@@ -63,11 +114,12 @@ bundle exec i18n-tasks normalize --locales en
|
|
63
114
|
|
64
115
|
### JavaScript linter
|
65
116
|
|
66
|
-
|
117
|
+
[eslint](https://eslint.org/docs/user-guide/command-line-interface) and [tslint](https://palantir.github.io/tslint/) are used to ensure homogeneous formatting of JavaScript code.
|
118
|
+
|
119
|
+
To lint and try to fix linting errors, run:
|
67
120
|
|
68
121
|
```console
|
69
|
-
|
70
|
-
yarn run lint --fix
|
122
|
+
npm run lint --fix
|
71
123
|
```
|
72
124
|
|
73
125
|
### Stylelinter
|
@@ -112,43 +164,3 @@ This project uses [markdownlint](https://github.com/markdownlint/markdownlint) t
|
|
112
164
|
## Testing
|
113
165
|
|
114
166
|
Refer to the [testing](advanced/testing.md) guide.
|
115
|
-
|
116
|
-
## Releasing new versions
|
117
|
-
|
118
|
-
In order to release new version you need to be owner of all the gems at RubyGems, ask one of the owners to add you before releasing. (Try `gem owners decidim`).
|
119
|
-
|
120
|
-
Releasing new ***patch versions*** is quite easy, it's the same process whether it's a new version or a patch:
|
121
|
-
|
122
|
-
1. Checkout the branch you want to release: `git checkout -b VERSION-stable`
|
123
|
-
1. Update `.decidim-version` to the new version number.
|
124
|
-
1. Run `bin/rake update_versions`, this will update all references to the new version.
|
125
|
-
1. Run `bin/rake bundle`, this will update all the `Gemfile.lock` files
|
126
|
-
1. Run `bin/rake webpack`, this will update the JavaScript bundle.
|
127
|
-
1. Update `CHANGELOG.MD`. At the top you should have an `Unreleased` header with the `Added`, `Changed`, `Fixed` and `Removed` empty section. After that, the header with the current version and link.
|
128
|
-
1. Commit all the changes: `git add . && git commit -m "Prepare VERSION release"`
|
129
|
-
1. Run `bin/rake release_all`, this will create all the tags, push the commits and tags and release the gems to RubyGems.
|
130
|
-
1. Once all the gems are published you should create a new release at this repository, just go to the [releases page](https://github.com/decidim/decidim/releases) and create a new one.
|
131
|
-
1. Finally, you should update our [Docker repository](https://github.com/decidim/docker) so new images are build for the new release. To do it, just update `DECIDIM_VERSION` at [circle.yml](https://github.com/decidim/docker/blob/master/circle.yml).
|
132
|
-
|
133
|
-
If this was a **major version** release:
|
134
|
-
|
135
|
-
1. Go back to master with `git checkout master`
|
136
|
-
1. Update `.decidim-version` to the new major development version
|
137
|
-
1. Run `bin/rake update_versions`, this will update all references to the new version.
|
138
|
-
1. Run `bin/rake bundle`, this will update all the `Gemfile.lock` files
|
139
|
-
1. Run `bin/rake webpack`, this will update the JavaScript bundle.
|
140
|
-
1. Update `SECURITY.md` and change the supported version to the new version.
|
141
|
-
1. Commit all the changes: `git add . && git commit -m "Bump version" && git push origin master`
|
142
|
-
1. Run `bin/rake release_all`, this will create all the tags, push the commits and tags and release the gems to RubyGems.
|
143
|
-
1. Once all the gems are published you should create a new release at this repository, just go to the [releases page](https://github.com/decidim/decidim/releases) and create a new one.
|
144
|
-
1. Finally, you should update our [Docker repository](https://github.com/decidim/docker) so new images are build for the new release. To do it, just update `DECIDIM_VERSION` at [circle.yml](https://github.com/decidim/docker/blob/master/circle.yml) and create the sibling branch at the Docker repository. NOTE: You should also take into account if the Ruby version has changed, in which case the Dockerfile should also be updated.
|
145
|
-
|
146
|
-
To branch the stable version and let master be the new devel branch again:
|
147
|
-
|
148
|
-
1. Create and push the stable branch from master: `git checkout master && git checkout -b VERSION-stable && git push origin VERSION-stable`
|
149
|
-
1. Update the `CHANGELOG.MD`. At the top you should have an `Unreleased` header with the `Added`, `Changed`, `Fixed` and `Removed` empty section. After that, the header with the current version and link.
|
150
|
-
1. Turn master into the dev branch for the next release:
|
151
|
-
1. Update `.decidim-version` to the new `dev` development version: x.y.z-dev
|
152
|
-
1. Run `bin/rake update_versions`, this will update all references to the new version.
|
153
|
-
1. Run `bin/rake bundle`, this will update all the `Gemfile.lock` files
|
154
|
-
1. Run `bin/rake webpack`, this will update the JavaScript bundle.
|
data/docs/getting_started.md
CHANGED
@@ -67,7 +67,7 @@ Then create a development application
|
|
67
67
|
```console
|
68
68
|
d/bundle install
|
69
69
|
d/rake development_app
|
70
|
-
d/rails server
|
70
|
+
d/rails server -b 0.0.0.0
|
71
71
|
```
|
72
72
|
|
73
73
|
In general, to use the docker development environment, change any instruction in
|
@@ -103,8 +103,16 @@ Visit [http://localhost:3000](http://localhost:3000) to see your app running.
|
|
103
103
|
|
104
104
|
Decidim comes pre-configured with some safe defaults, but can be changed through the `config/initializers/decidim.rb` file in your app. Check the comments there or read the comments in [the source file](https://github.com/decidim/decidim/blob/master/decidim-core/lib/decidim/core.rb) (the part with the `config_accessor` calls) for more up-to-date info.
|
105
105
|
|
106
|
-
|
107
|
-
|
106
|
+
### Scheduled tasks
|
107
|
+
|
108
|
+
For Decidim to function as expected, there are some background tasks that should be scheduled to be executed regularly.
|
109
|
+
|
110
|
+
- Expired *data portability* files should be removed. To do it, write a `crontab -e` line like: `0 0 * * * cd /Users/you/projects/myrailsapp && /usr/local/bin/rake RAILS_ENV=production decidim:delete_data_portability_files`
|
111
|
+
- *Metrics* also require a cron to be computed nightly. Find more information in the [related documentation](https://github.com/decidim/decidim/blob/master/docs/advanced/metrics.md#Configuration).
|
112
|
+
- *Open Data* is also produced nightly via a scheduled job. Find more information in the [open-data documentation](https://github.com/decidim/decidim/blob/master/docs/advanced/open-data.md).
|
113
|
+
- Registration forms for meetings that have ended should be removed for privacy concerns. To do it, write a `crontab -e` line like: `0 0 * * * cd /Users/you/projects/myrailsapp && /usr/local/bin/rake RAILS_ENV=production decidim_meetings:clean_registration_forms`
|
114
|
+
|
115
|
+
### Further configuration
|
108
116
|
|
109
117
|
We also have other guides on how to configure some extra components:
|
110
118
|
|
@@ -159,9 +167,11 @@ You can also make sure new translations are complete for all languages in your
|
|
159
167
|
application with:
|
160
168
|
|
161
169
|
```console
|
162
|
-
bin/rails decidim:check_locales
|
170
|
+
TARGET_BRANCH=release/0.22-stable bin/rails decidim:check_locales
|
163
171
|
```
|
164
172
|
|
173
|
+
Here the `TARGET_BRANCH` must be the same as the `decidim` dependency in your `Gemfile`.
|
174
|
+
|
165
175
|
Be aware that this task might not be able to detect everything, so make sure you
|
166
176
|
also manually check your application before upgrading.
|
167
177
|
|
data/docs/manual-installation.md
CHANGED
@@ -122,6 +122,10 @@ This data won't be created in production environments, if you still want to do i
|
|
122
122
|
SEED=true rails db:setup
|
123
123
|
```
|
124
124
|
|
125
|
+
#### Notes
|
126
|
+
|
127
|
+
When you run `bin/rails db:migrate` you should see a lot of output. If you don't, or if you run into errors seeding your database, try runnning `bin/rake decidim:upgrade` before.
|
128
|
+
|
125
129
|
You can now start your server!
|
126
130
|
|
127
131
|
```bash
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Elections Bulletin Board
|
2
|
+
|
3
|
+
:warning: This is a work in progress and is not fully working yet.
|
4
|
+
|
5
|
+
In order to celebrate [End-to-end auditable votings](https://en.wikipedia.org/wiki/End-to-end_auditable_voting_systems) using the Elections module, you will need to connect your Decidim instance with an instance of the [Decidim Bulletin Board application](https://github.com/decidim/decidim-bulletin-board/), preferably run by an independent organization.
|
6
|
+
|
7
|
+
## Identification pair of keys generation
|
8
|
+
|
9
|
+
The first step needed to setup the connection is to generate an a pair of keys to identify the application against the Bulletin Board. This can be done running the following rake task in your application environment:
|
10
|
+
|
11
|
+
```sh
|
12
|
+
bundle exec rake decidim_elections:generate_identification_keys
|
13
|
+
```
|
14
|
+
|
15
|
+
This task will output the generated private and public keys. You should copy the public key and send it to the Bulletin Board administrator through a secure channel. When copying the key, include the starting and ending lines with the prefix `-----`.
|
16
|
+
|
17
|
+
After that, use one of these methods to make the private key available from your Decidim installation:
|
18
|
+
|
19
|
+
a. Copy the private key, paste in a new file and store its path on the environment variable `BULLETIN_BOARD_IDENTIFICATION_PRIVATE_KEY`.
|
20
|
+
b. Copy the private key and store that value on the environment variable `BULLETIN_BOARD_IDENTIFICATION_PRIVATE_KEY`.
|
21
|
+
|
22
|
+
Regardless of the used method, when copying the private key remember to include the lines prefixed by `-----` and ensure that the private key is not lost between deployments and servers reboots and that only can be accessed by the application.
|
23
|
+
|
24
|
+
## Configuration of the Bulletin Board application
|
25
|
+
|
26
|
+
The Bulletin Board administrator will store the received public key in their server and will send you back an API key. To complete the setup process you should store this API key and the Bulletin Board URL address on the environment variables `BULLETIN_BOARD_API_KEY` and `BULLETIN_BOARD_SERVER`, respectively.
|
27
|
+
|
28
|
+
The following YAML snippet with all the defined environment variables should be used in the `default` block of your application `config/secrets.yml` file. Maybe this is already done, as it was included in the Decidim applications generator during the development of the Elections module.
|
29
|
+
|
30
|
+
```yaml
|
31
|
+
bulletin_board:
|
32
|
+
identification_private_key: |
|
33
|
+
<%= ENV["BULLETIN_BOARD_IDENTIFICATION_PRIVATE_KEY"]&.indent(6) %>
|
34
|
+
server: <%= ENV["BULLETIN_BOARD_SERVER"] %>
|
35
|
+
api_key: <%= ENV["BULLETIN_BOARD_API_KEY"] %>
|
36
|
+
```
|
37
|
+
|
38
|
+
After restarting the Decidim instance, administrator users will be able to create elections on the configured Bulletin Board.
|
data/docs/services/etherpad.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Etherpad
|
2
2
|
|
3
|
-
|
3
|
+
On some cases, users need to have near real time collaborative writing, for instance for having the minutes on a physical meeting.
|
4
|
+
|
5
|
+
To ease online/offline participation, Decidim can be integrated with Etherpad so meetings can have their own pads.
|
6
|
+
|
7
|
+
## Integration
|
4
8
|
|
5
9
|
In order to use it you need to have your own Etherpad deployment, you can do it
|
6
10
|
with the Docker compose using the provided `docker-compose-etherpad.yml`.
|
@@ -13,5 +17,36 @@ docker swarm init # just one time
|
|
13
17
|
docker stack deploy --compose-file docker-compose-etherpad.yml decidim-etherpad
|
14
18
|
```
|
15
19
|
|
16
|
-
After deploying
|
20
|
+
After deploying Etherpad, you should get back to Decidim's server and set the Etherpad host and API Key at
|
17
21
|
`config/initializers/decidim.rb` and `config/secrets.yml`
|
22
|
+
|
23
|
+
An example snippet in `config/initializers/decidim.rb` may be:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
config.etherpad = {
|
27
|
+
server: Rails.application.secrets.etherpad[:server],
|
28
|
+
api_key: Rails.application.secrets.etherpad[:api_key],
|
29
|
+
api_version: Rails.application.secrets.etherpad[:api_version]
|
30
|
+
}
|
31
|
+
```
|
32
|
+
|
33
|
+
and then in `config/secrets.yml`:
|
34
|
+
|
35
|
+
```yaml
|
36
|
+
etherpad:
|
37
|
+
server: <%= ENV["ETHERPAD_SERVER"] %>
|
38
|
+
api_key: <%= ENV["ETHERPAD_API_KEY"] %>
|
39
|
+
api_version: <%= ENV["ETHERPAD_API_VERSION"] %>
|
40
|
+
```
|
41
|
+
|
42
|
+
## How is Etherpad Lite integrated in Meetings?
|
43
|
+
|
44
|
+
To better understand this feature, the final idea is to have the three moments of a meeting covered on Decidim itself by default:
|
45
|
+
|
46
|
+
- **Before the meeting**, you let know that the meeting is going to happen, where, when and what is going to be discussed
|
47
|
+
- **During the meeting**, notes can be taken on a collaborative way
|
48
|
+
- **After the meeting**, you upload the notes, minutes, metadata and/or pictures to have a record on what was discussed
|
49
|
+
|
50
|
+
Pad creation can be enabled by administrators in each `Meetings` component. When enabled, the public view of a Meeting renders an iframe which encapsulates the integrated Pad. This Pad is automatically created before rendering, so there's nothing the user or the administrators has to do to see the Pad.
|
51
|
+
|
52
|
+
The pad iframe is only accessible for 24 hours before and 72 hours after the meeting. After the meeting only the read only URL for this pad is shown.
|
@@ -0,0 +1,362 @@
|
|
1
|
+
# Maps and geocoding
|
2
|
+
|
3
|
+
Decidim has the ability to geocode proposals and meetings and display them on a
|
4
|
+
map. Decidim has built-in support for the following map service providers:
|
5
|
+
|
6
|
+
- [HERE Maps][link-here] (Recommended)
|
7
|
+
- Supports map tiles, static map images, geocoding and geocoding
|
8
|
+
autocompletion
|
9
|
+
- Easy to get started with, comes with a rather generous free plan
|
10
|
+
- [Configuring HERE Maps][anchor-configure-here-maps]
|
11
|
+
- [Open Street Maps based services][link-osm-commercial]
|
12
|
+
- Please pick a service provider that provides all needed services (map tiles,
|
13
|
+
static map images, geocoding and geocoding autocompletion)
|
14
|
+
- We can't use the OSM's own services by their
|
15
|
+
[tile usage policy][link-osm-tile-usage].
|
16
|
+
- In case your service provider does not offer static map images, Decidim will
|
17
|
+
use the dynamic map tiles to generate a similar map element.
|
18
|
+
- As an alternative, you may also want to use your own self-hosted map servers
|
19
|
+
(see [Hosting your own map services][anchor-hosting-osm] for
|
20
|
+
more information)
|
21
|
+
- [Configuring Open Street Maps based service providers][anchor-configure-osm]
|
22
|
+
|
23
|
+
If you want to integrate Decidim to some other map service provider, read how to
|
24
|
+
[write your own integration code][link-docs-custom-maps] for that.
|
25
|
+
|
26
|
+
## Configuring maps and geocoding
|
27
|
+
|
28
|
+
After generating your app, you'll see that your `config/initializers/decidim.rb`
|
29
|
+
file includes commented code about map services:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
# Map and Geocoder configuration
|
33
|
+
# config.maps = {
|
34
|
+
# ...
|
35
|
+
# }
|
36
|
+
```
|
37
|
+
|
38
|
+
The initializer comments provide examples for the services mentioned in this
|
39
|
+
documentation. Please refer to the section below for the service you have
|
40
|
+
registered for the maps functionality.
|
41
|
+
|
42
|
+
If you want to enable geocoding in your app:
|
43
|
+
|
44
|
+
1. Select a service provider for the maps functionality and register an account
|
45
|
+
with that provider
|
46
|
+
1. Uncomment or add the code under the selected service provider in your
|
47
|
+
`config/initializers/decidim.rb`.
|
48
|
+
1. Make sure your `config/secrets.yml` file has the needed section (it should
|
49
|
+
be added by the generator automatically).
|
50
|
+
1. Configure the service provider credentials in `config/secrets.yml` and refer
|
51
|
+
to them from your `config/initializers/decidim.rb`.
|
52
|
+
1. If you had your Rails server running, restart it so the changes apply.
|
53
|
+
|
54
|
+
### Configuring HERE Maps
|
55
|
+
|
56
|
+
Use the following configuration for HERE Maps:
|
57
|
+
|
58
|
+
`config/initializers/decidim.rb`:
|
59
|
+
|
60
|
+
```ruby
|
61
|
+
# Map and Geocoder configuration
|
62
|
+
# == HERE Maps ==
|
63
|
+
config.maps = {
|
64
|
+
provider: :here,
|
65
|
+
api_key: Rails.application.secrets.maps[:api_key],
|
66
|
+
static: { url: "https://image.maps.ls.hereapi.com/mia/1.6/mapview" }
|
67
|
+
}
|
68
|
+
```
|
69
|
+
|
70
|
+
`config/secrets.yml`:
|
71
|
+
|
72
|
+
```yaml
|
73
|
+
default: &default
|
74
|
+
# ...
|
75
|
+
maps:
|
76
|
+
api_key: <%= ENV["MAPS_API_KEY"] %>
|
77
|
+
```
|
78
|
+
|
79
|
+
`.env`:
|
80
|
+
|
81
|
+
```bash
|
82
|
+
MAPS_API_KEY=your_api_key_here
|
83
|
+
```
|
84
|
+
|
85
|
+
### Configuring Open Street Maps based service providers
|
86
|
+
|
87
|
+
Use the following configuration for Open Street Maps based service providers:
|
88
|
+
|
89
|
+
`config/initializers/decidim.rb`:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
# Map and Geocoder configuration
|
93
|
+
# == OpenStreetMap (OSM) services ==
|
94
|
+
config.maps = {
|
95
|
+
provider: :osm,
|
96
|
+
api_key: Rails.application.secrets.maps[:api_key],
|
97
|
+
dynamic: {
|
98
|
+
tile_layer: {
|
99
|
+
url: "https://tiles.example.org/{z}/{x}/{y}.png?key={apiKey}",
|
100
|
+
api_key: true,
|
101
|
+
attribution: %(
|
102
|
+
<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap</a> contributors
|
103
|
+
).strip
|
104
|
+
# Translatable attribution:
|
105
|
+
# attribution: -> { I18n.t("tile_layer_attribution") }
|
106
|
+
}
|
107
|
+
},
|
108
|
+
# static: { url: "https://staticmap.example.org/" }, # optional
|
109
|
+
geocoding: { host: "nominatim.example.org", use_https: true },
|
110
|
+
autocomplete: { url: "https://photon.example.org/api/" }
|
111
|
+
}
|
112
|
+
```
|
113
|
+
|
114
|
+
`config/secrets.yml`:
|
115
|
+
|
116
|
+
```yaml
|
117
|
+
default: &default
|
118
|
+
# ...
|
119
|
+
maps:
|
120
|
+
api_key: <%= ENV["MAPS_API_KEY"] %>
|
121
|
+
```
|
122
|
+
|
123
|
+
`.env`:
|
124
|
+
|
125
|
+
```bash
|
126
|
+
MAPS_API_KEY=your_api_key_here
|
127
|
+
```
|
128
|
+
|
129
|
+
For further information, see the service provider's documentation or take a look
|
130
|
+
at the [Hosting your own map services][anchor-hosting-osm] section.
|
131
|
+
|
132
|
+
### Combining multiple service providers
|
133
|
+
|
134
|
+
It is also possible to combine multiple service providers for the different
|
135
|
+
categories of map services. For instance, if you want to use HERE Maps for
|
136
|
+
the map tiles but host the other services yourself, use the following
|
137
|
+
configuration:
|
138
|
+
|
139
|
+
```ruby
|
140
|
+
# Map and Geocoder configuration
|
141
|
+
# == Combination (OpenStreetMap default + HERE Maps dynamic map tiles) ==
|
142
|
+
config.maps = {
|
143
|
+
provider: :osm,
|
144
|
+
dynamic: {
|
145
|
+
provider: :here,
|
146
|
+
api_key: Rails.application.secrets.maps[:here_api_key]
|
147
|
+
},
|
148
|
+
static: { url: "https://staticmap.example.org/" },
|
149
|
+
geocoding: { host: "nominatim.example.org", use_https: true },
|
150
|
+
autocomplete: { url: "https://photon.example.org/api/" }
|
151
|
+
}
|
152
|
+
```
|
153
|
+
|
154
|
+
`config/secrets.yml`:
|
155
|
+
|
156
|
+
```yaml
|
157
|
+
default: &default
|
158
|
+
# ...
|
159
|
+
maps:
|
160
|
+
here_api_key: <%= ENV["MAPS_HERE_API_KEY"] %>
|
161
|
+
```
|
162
|
+
|
163
|
+
`.env`:
|
164
|
+
|
165
|
+
```bash
|
166
|
+
MAPS_HERE_API_KEY=your_api_key_here
|
167
|
+
```
|
168
|
+
|
169
|
+
### Disabling some of the map services
|
170
|
+
|
171
|
+
When using the maps functionality, you should always aim to provide all the
|
172
|
+
services for the user that are available in Decidim. However, not all service
|
173
|
+
providers provide all these services, so at times you may need to disable some
|
174
|
+
of them.
|
175
|
+
|
176
|
+
The configuration syntax allows you to disable the map services one by one. For
|
177
|
+
example, if you want to use HERE Maps as your default but disable the static map
|
178
|
+
images and geocoding autocompletion functionality, you can use the following
|
179
|
+
configuration:
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
config.maps = {
|
183
|
+
provider: :here,
|
184
|
+
api_key: Rails.application.secrets.maps[:api_key],
|
185
|
+
static: false,
|
186
|
+
autocomplete: false
|
187
|
+
}
|
188
|
+
```
|
189
|
+
|
190
|
+
Decidim works fine when some of the services are disabled individually but
|
191
|
+
obviously, the disabled services are not available for Decidim users.
|
192
|
+
|
193
|
+
### Global geocoder configurations
|
194
|
+
|
195
|
+
In the Dedicim initialiser (`config/initializers/decidim.rb`) you will also see
|
196
|
+
a commented section for the global geocoder configurations commented as follows:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
# Geocoder configurations ...
|
200
|
+
# config.geocoder = {
|
201
|
+
# # geocoding service request timeout, in seconds (default 3):
|
202
|
+
# timeout: 5,
|
203
|
+
# # set default units to kilometers:
|
204
|
+
# units: :km,
|
205
|
+
# # caching (see https://github.com/alexreisner/geocoder#caching for details):
|
206
|
+
# cache: Redis.new,
|
207
|
+
# cache_prefix: "..."
|
208
|
+
# }
|
209
|
+
```
|
210
|
+
|
211
|
+
This will change the global geocoding settings for your application. To learn
|
212
|
+
more about these settings, take a look at the
|
213
|
+
[Geocoder gem's documentation][link-geocoder].
|
214
|
+
|
215
|
+
### Geocoding autocompletion configurations
|
216
|
+
|
217
|
+
Each autocompletion geocoder has their own configurations and this may not apply
|
218
|
+
for all geocoding services. The geocoder autocompletion integrations shipped
|
219
|
+
with Decidim support the configurations shown in this section.
|
220
|
+
|
221
|
+
If you want to customize the address format in the geocoding autocompletion
|
222
|
+
fields, you can apply the following configuration to your geocoder settings:
|
223
|
+
|
224
|
+
```ruby
|
225
|
+
config.maps = {
|
226
|
+
# ... other configs ...
|
227
|
+
autocomplete: {
|
228
|
+
# For HERE:
|
229
|
+
address_format: [%w(street houseNumber), "city", "country"]
|
230
|
+
# For OSM/Photon:
|
231
|
+
# address_format: ["name", %w(street housenumber), "city", "country"]
|
232
|
+
}
|
233
|
+
}
|
234
|
+
```
|
235
|
+
|
236
|
+
### Integrating with a new service provider
|
237
|
+
|
238
|
+
If you want to integrate the map functionality with a new service provider, take
|
239
|
+
a look at the [Custom map providers][link-docs-custom-maps] documentation.
|
240
|
+
|
241
|
+
## Enabling maps and geocoding
|
242
|
+
|
243
|
+
Once the maps functionality is configured, you'll need to activate it. As of
|
244
|
+
April 2017, only proposals and meetings have maps and geocoding.
|
245
|
+
|
246
|
+
### Proposals
|
247
|
+
|
248
|
+
In order to enable geocoding for proposals you'll need to edit the component
|
249
|
+
configuration and turn on "Geocoding enabled" configuration. This works for that
|
250
|
+
specific component, so you can have geocoding enabled for proposals in a
|
251
|
+
participatory process, and disabled for another proposals component in the same
|
252
|
+
participatory process.
|
253
|
+
|
254
|
+
### Meetings
|
255
|
+
|
256
|
+
Meetings do not have a configuration option for geocoding. Instead, if geocoding
|
257
|
+
is configured it will try to geocode the address every time you create or update
|
258
|
+
a meeting. As of April 2017 there is no way to enable or disable geocoding per
|
259
|
+
meetings component.
|
260
|
+
|
261
|
+
## Hosting your own map services
|
262
|
+
|
263
|
+
It is recommended to use a commercial service provider for all the map
|
264
|
+
functionality to get up and running more easily. Hosting all these services
|
265
|
+
yourself and keeping everything up to date is time consuming and rather complex.
|
266
|
+
If the related complexity or the required time is not an issue, feel free to
|
267
|
+
setup the following services on your own servers.
|
268
|
+
|
269
|
+
### Map tiles: Open Street Maps tile server
|
270
|
+
|
271
|
+
You will need a [map tiles][link-wiki-map-tiles] server which is used for the
|
272
|
+
dynamic maps that the user can move themselves.
|
273
|
+
|
274
|
+
Follow these instructions to setup your tiles server:
|
275
|
+
|
276
|
+
https://opentileserver.org/
|
277
|
+
|
278
|
+
In the example configuration, we assume you have used the following domain for
|
279
|
+
the tiles server:
|
280
|
+
|
281
|
+
https://tiles.example.org
|
282
|
+
|
283
|
+
### Static map images: Openstreetmap static maps server (osm-static-maps)
|
284
|
+
|
285
|
+
Some pages in Decidim display static map images which need to be fetched from
|
286
|
+
an external server. The tiles server does not provide such static images by
|
287
|
+
itself because one static map image may need multiple tiles to be combined into
|
288
|
+
one. The static map image is therefore dynamically generated based on the
|
289
|
+
parameters passed for the static map request (such as image dimensions and the
|
290
|
+
geocoordinates of the map image position).
|
291
|
+
|
292
|
+
The Open Street Maps community has made multiple open source
|
293
|
+
[static maps image services][link-wiki-static-maps] from which you can pick
|
294
|
+
freely but Decidim currently supports only
|
295
|
+
[osm-static-maps][link-osm-static-maps] with the Open Street Maps services.
|
296
|
+
|
297
|
+
Follow these instructions to setup your static map images server:
|
298
|
+
|
299
|
+
https://github.com/jperelli/osm-static-maps#3-standalone-sample-server
|
300
|
+
|
301
|
+
In the example configuration, we assume you have used the following domain for
|
302
|
+
the static maps image server:
|
303
|
+
|
304
|
+
https://staticmap.example.org
|
305
|
+
|
306
|
+
Setting up this service is optional. If you do not configure a static map URL
|
307
|
+
for the OSM based map services, Decidim will use the dynamic map tiles to
|
308
|
+
generate a similar map element.
|
309
|
+
|
310
|
+
### Geocoding: Nominatim geocoding server
|
311
|
+
|
312
|
+
[Nominatim][link-osm-nominatim] makes it possible to place points on the Decidim
|
313
|
+
maps based on addresses. This service provides geocoding capabilities by turning
|
314
|
+
human readable addresses to [geographic coordinates][link-wiki-geocoordinates].
|
315
|
+
|
316
|
+
Follow these instructions to setup your geocoding server:
|
317
|
+
|
318
|
+
http://nominatim.org/release-docs/latest/admin/Installation/
|
319
|
+
|
320
|
+
In the example configuration, we assume you have used the following domain for
|
321
|
+
the geocoding server:
|
322
|
+
|
323
|
+
https://nominatim.example.org
|
324
|
+
|
325
|
+
### Geocoding autocompletion: Photon geocoding server
|
326
|
+
|
327
|
+
[Photon][link-osm-photon] makes it possible to provide the autocompletion
|
328
|
+
service for people writing addresses to the address fields available in Decidim.
|
329
|
+
It uses the Open Street Maps data to serve the autocompletion requests. When
|
330
|
+
people select one of the suggested addresses, it will also tell Decidim the map
|
331
|
+
point for that address.
|
332
|
+
|
333
|
+
Follow these instructions to setup your geocoding autocompletion server:
|
334
|
+
|
335
|
+
https://github.com/komoot/photon#installation
|
336
|
+
|
337
|
+
In the example configuration, we assume you have used the following domain for
|
338
|
+
the Photon geocoding server for the autocompletion functionality:
|
339
|
+
|
340
|
+
https://photon.example.org
|
341
|
+
|
342
|
+
### Configure Decidim
|
343
|
+
|
344
|
+
After you have all these services running, change your Decidim configurations
|
345
|
+
to use these services. Read the
|
346
|
+
[Configuring Open Street Maps based service providers][anchor-configure-osm]
|
347
|
+
section for more information.
|
348
|
+
|
349
|
+
[anchor-hosting-osm]: #hosting-your-own-map-services
|
350
|
+
[anchor-configure-here-maps]: #configuring-here-maps
|
351
|
+
[anchor-configure-osm]: #configuring-open-street-maps-based-service-providers
|
352
|
+
[link-docs-custom-maps]: /docs/customization/maps.md
|
353
|
+
[link-here]: http://here.com
|
354
|
+
[link-geocoder]: https://github.com/alexreisner/geocoder
|
355
|
+
[link-osm-commercial]: https://wiki.openstreetmap.org/wiki/Commercial_OSM_Software_and_Services
|
356
|
+
[link-osm-nominatim]: https://wiki.openstreetmap.org/wiki/Nominatim
|
357
|
+
[link-osm-static-maps]: https://github.com/jperelli/osm-static-maps
|
358
|
+
[link-osm-photon]: https://github.com/komoot/photon
|
359
|
+
[link-osm-tile-usage]: https://operations.osmfoundation.org/policies/tiles/
|
360
|
+
[link-wiki-geocoordinates]: https://en.wikipedia.org/wiki/Geographic_coordinate_system
|
361
|
+
[link-wiki-map-tiles]: https://wiki.openstreetmap.org/wiki/Tiles
|
362
|
+
[link-wiki-static-maps]: https://wiki.openstreetmap.org/wiki/Static_map_images
|