GitBook: [master] 86 pages and 110 assets modified

This commit is contained in:
consuldocs
2020-07-14 22:51:03 +00:00
committed by gitbook-bot
parent 06fe16d6b4
commit 5ed5960428
196 changed files with 5304 additions and 122 deletions

View File

@@ -0,0 +1,11 @@
# Customization
* [Introduction](introduction.md)
* [Texts & Translations](translations.md)
* [Images](images.md)
* [Views & Styles](views_and_styles.md)
* [Javascript](javascript.md)
* [Models](models.md)
* [Gems](gems.md)
* [Overwritting Application](overwritting.md)

View File

@@ -0,0 +1,10 @@
# Gems
To add new gems \(libraries\) you can edit the `Gemfile_custom` file. For example to add [rails-footnotes](https://github.com/josevalim/rails-footnotes) gem you would just add:
```ruby
gem 'rails-footnotes', '~> 4.0'
```
And then just do the classic Ruby on Rails flow `bundle install` and following any gem specific install steps from it's own documentation.

View File

@@ -0,0 +1,18 @@
# Images
If you want to overwrite any image, firstly you need to findout the filename, and by defaul it will be located under `app/assets/images`. For example if you want to change the header logo \(`app/assets/images/logo_header.png`\) you must create another file with the exact same file name under `app/assets/images/custom` folder. The images and icons that you will most likely want to change are:
* apple-touch-icon-200.png
* icon\_home.png
* logo\_email.png
* logo\_header.png
* map.jpg
* social\_media\_icon.png
* social\_media\_icon\_twitter.png
## City Map
You'll find the city map at [`/app/assets/images/map.jpg`](https://github.com/consul/consul/blob/master/app/assets/images/map.jpg), just replace it with an image of your cities districts \([example](https://github.com/ayuntamientomadrid/consul/blob/master/app/assets/images/map.jpg)\).
Afterwards we recommend you to use an online tool like [http://imagemap-generator.dariodomi.de/](http://imagemap-generator.dariodomi.de/) or [https://www.image-map.net/](https://www.image-map.net/) to generate the html coordinates to be able to generate a [image-map](https://www.w3schools.com/tags/tag_map.asp) for each of the districts. Those coordinates should be introduced on the respective Geozones at the admin geozones panel \(`/admin/geozones`\)

View File

@@ -0,0 +1,110 @@
# Introduction
You can modify your own CONSUL to have your custom visual style, but first you'll have to [create your own fork from](../getting_started/create.md).
We've created an specific structure where you can overwrite and customize the application in a way that will let you keep updating it from CONSUL's main repository, without having conflicts on code merging or risking loosing your customization changes. We try to make CONSUL as vanilla as possible to help other developers onboard the codebase.
## Special Folders and Files
In order to customize your CONSUL fork, you'll make use of some `custom` folders on the following paths:
* `config/locales/custom/`
* `app/assets/images/custom/`
* `app/views/custom/`
* `app/controllers/custom/`
* `app/models/custom/`
Also these are the files where you can apply some customization:
* `app/assets/stylesheets/custom.css`
* `app/assets/stylesheets/_custom_settings.css`
* `app/assets/javascripts/custom.js`
* `Gemfile_custom`
* `config/application.custom.rb`
## Remote translations on demand by the user
The aim of this service is to be able to offer all the dynamic contents of the application \(proposals, debates, budget investments and comments\) in different languages without the need for a user or administrator to have created each one of their translations.
When an user visit a page with a language where there is untranslated content, he will has a button to request the translation of all the content. This content will be sent to an automatic translator \(in this case [Microsoft TranslatorText](https://azure.microsoft.com/en-us/services/cognitive-services/translator-text-api/)\) and as soon as the response is obtained, all these translations will be available to any user.
### Getting started
In order to use this functionality, the following steps are necessary: 1. Have an api key to connect to the translation service. For this we need an [Azure account](https://azure.microsoft.com/en-us/) 1. Once you are logged into the Azure portal, subscribe to the Translator Text API in Microsoft Cognitive Service. 1. Once you have subscribed to the Translator Text service, you will have access to 2 api keys in the section **RESOURCE MANAGEMENT > Keys** that will be necessary for the configuration of the translation service in your application.
### Configuration
To activate the translation service in your application you must complete the following steps:
#### Add api key in the application
In the previous section we have commented that once subscribed to the translation service we have 2 api keys. To configure the service correctly in our application we must add one of the two api keys in the file `secrets.yml` in section `apis:` with the key `microsoft_api_key` as we can see in the following image:
![Add api key to secrets](../../.gitbook/assets/add-api-key-to-secrets.png)
#### Activate module
Once we have the new key in the `secrets.yml` we can now proceed to activate the module. To activate the functionality you must follow 2 steps: 1. Execute the following command `bin/rake settings:create_remote_translations_setting RAILS_ENV=production` 1. Accessing through the administration panel of your application to the section **Configuración > Funcionalidades** and activate module **Traducciones Remotas** as shown below: ![Active remote translations](../../.gitbook/assets/active-remote-translations-en.png)
### Use Cases
Once we have the api key in our `secrets.yml` and the activated module, users will already be able to use the functionality. We attach some screenshots of how the application interacts with our users:
* When a user visits a page in a language without translated content, an informative text will appear at the top of the page and a button to request the translation. \(**Note:** _If user visit page with a language not supported by the translation service, no text or translation button will be displayed. See section: Available languages for remote translation_\) ![Display text and button](../../.gitbook/assets/display-text-and-button-en.png)
* Once the user click the `Translate page` button, the translations are enqueued and the page is reloaded with a notice \(_Informing that the translations have been requested correctly_\) and an informative text in the header \(_explaining when you will be able to see these translations_\). ![Display notice and text after enqueued translations](../../.gitbook/assets/display-notice-and-text-after-enqueued-en.png)
* If an user visit a page that does not have translations but have already been requested by another user. The application will not show you the translate button, but an informative text in the header \(_explaining when you will be able to see these translations_\). ![Display text explaining that translations are pending](../../.gitbook/assets/display-text-translations-pending-en.png)
* The translation request, response processing and data saving are delegated to `Delayed Jobs` and as soon as they are processed, the user will be able to read them after page refresh. ![Display translated content](../../.gitbook/assets/display-translated-content-en.png)
### Available languages for remote translation
Currently these are all the [available languages](https://docs.microsoft.com/en-us/azure/cognitive-services/translator/quickstart-ruby-languages) in the translation service:
```text
["af", "ar", "bg", "bn", "bs", "ca", "cs", "cy", "da", "de", "el", "en", "es", "et", "fa", "fi", "fil", "fj", "fr", "he", "hi", "hr", "ht", "hu", "id", "is", "it", "ja", "ko", "lt", "lv", "mg", "ms", "mt", "mww", "nb", "nl", "otq", "pl", "pt", "ro", "ru", "sk", "sl", "sm", "sr-Cyrl", "sr-Latn", "sv", "sw", "ta", "te", "th", "tlh", "to", "tr", "ty", "uk", "ur", "vi", "yua", "yue", "zh-Hans", "zh-Hant"]
```
Of all the languages that Consul currently has defined\(`available_locales`\) in `config/application.rb` are not included in the above list and no translation service is offered for the following languages:
```text
["val", "gl", "sq"]
```
### Pricing
The translation service used has the [pricing](https://azure.microsoft.com/en-us/pricing/details/cognitive-services/translator-text-api/) the most competitive. The price for each 1 Million characters translated is 8.43 € and there is no fixed cost per month. Google and DeepL have an approximate price of between 16.00 € and 20.00 € for each 1 million characters and a fixed monthly cost.
Although technical measures have been taken to prevent misuse of this service, we recommend the creation of Alerts offered by Azure so that an Administrator can be notified in the event of detecting unusual use of the service.
To create an Alert in Azure we must follow the following steps: 1. Sign in to the **Azure Portal**. 1. Register the resource providers needed to create Alerts 1. On the Azure portal menu, select **All services**. 1. In the **All services** box, enter **subscription**, and then select **Subscriptions**. 1. Select the subscription from the subscription list in order to view it. 1. Select **Resource providers** and check the list of available resource providers. 1. Among the resource providers we must select **microsoft.insights** and click on the button **Register** 1. Create new alert rule: 1. On the Azure portal menu, select **All services**. 1. In the **All services** box, enter **subscription**, and then select **Subscriptions**. 1. Select the subscription from the subscription list in order to view it. 1. Select **Resources** and access the resource created from translations of the type **Cognitive Services** 1. In the **Monitoring** section select **Alerts** and we access **New alert rule** 1. Select the **Resource** that we want to alert on \(if we have followed the previous steps it should already be selected\) 1. Add a **Condition**. In this case the one we are interested is called `Characters Translated`. Once selected we must define the logic of the Alert to suit our needs. Ex: Fill "Operator" field with "Greater than" option, fill "Aggregation type" field with "Total" option and fill "Threshold value" field with the number of characters we consider should be translated before being notified. In this section you can also set the time period and frequency of evaluation. 1. In order to be notified we have to create an **Action Group** and associate it with this Alert we're creating. To do this, access the button **Create** and fill out the form. As you can see there are different types of actions, we must select **Email/SMS/Push/Voice** and configure the option that we consider convenient according to our needs. 1. Once this group of actions has been created, it is directly associated with the rule we are creating. 1. Finally, all you have to do is add a name and click on the **Create new alert rule**
### Add a new translation service
If you want to integrate more translation services for any reason \(new translation service appears, you want to change to include languages that are currently not supported, etc.\) the code is ready to be added. This is made possible by the `RemoteTranslations::Caller` class which is an intermediate layer between untranslated content management and the currently used Microsoft Translation Client. A good solution for adding another translation service would be to replace the call to the `MicrosoftTranslateClient` in the `translations` method of `RemoteTranslations::Caller` with the new service implemented. If you want to coexist with both should only be managed in which case we want to use one or the other, either through specific conditions in the code or through a management in the Settings of the application.
```ruby
class RemoteTranslationsCaller
...
def translations
@translations ||= RemoteTranslations::Microsoft::Client.new.call(fields_values, locale)
# Add new RemoteTranslations Client
# @translations = RemoteTranslations::NewTranslateClient::Client.new.call(fields_values, locale_to)
end
...
end
```
## Translation interface
The aim of this feature is to allow users the introduction of dynamic contents in many languages at the same time. From the administration panel you can activate or deactivate it. If you deactivate this feature \(default configuration\) users will be able to enter one single translation.
### Enable module
To activate this feature you must follow 2 steps: 1. Execute the following command `bin/rake settings:create_translation_interface_setting RAILS_ENV=production` \(This is only required for already existing intallations, for new consul installations this step is not needed\). 2. Accessing as administrator user to the administration panel of your Consul application to the section **Configuration > Features** and activating the feature called **Translation Interface** as you can see next: ![Active interface translations](../../.gitbook/assets/active-interface-translations-en.png)
### Use Cases
* When the translation interface is active: As you can see in the image below translation interface has two selectors, the firt one "Select language" is to switch between enabled languages and the second one "Add language" is to add new languages to the form. Translatable fields appears with a blue background to facilitate users to distinguish between translatable and not translatable fields. Additionally interface provides a link `Remove language` to delete the current language shown at "Select language". If a user accidentally removes a translation he can recover it re-adding it to the form. This feature is visible during creation and edition of translatable resources. ![Translations inteface enabled](../../.gitbook/assets/translations-interface-enabled-en.png)
* When the translation interface is disabled: When this feature is deactivated users will see standard forms without translation interface and without translation highlight. ![Translations inteface enabled](../../.gitbook/assets/translations-interface-disabled-en.png)

View File

@@ -0,0 +1,16 @@
# Javascript
If you want to add some custom Javascript code, `app/assets/javascripts/custom.js` is the file to do it. For example to create a new alert just add:
```javascript
$(function(){
alert('foobar');
});
```
If you work with Coffeescript code you can check it with [coffeelint](http://www.coffeelint.org/) \(install with `npm install -g coffeelint`\) :
```bash
coffeelint .
```

View File

@@ -0,0 +1,76 @@
# Models
If you need to create new models or customize existent ones, you can do it so at the `app/models/custom` folder. Keep in mind that for old models you'll need to firstly require the dependency.
For example for Madrid's City Hall fork its required to check the zip code's format \(it always starts with 280 followed by 2 digits\). That check is at `app/models/custom/verification/residence.rb`:
```ruby
require_dependency Rails.root.join('app', 'models', 'verification', 'residence').to_s
class Verification::Residence
validate :postal_code_in_madrid
validate :residence_in_madrid
def postal_code_in_madrid
errors.add(:postal_code, I18n.t('verification.residence.new.error_not_allowed_postal_code')) unless valid_postal_code?
end
def residence_in_madrid
return if errors.any?
unless residency_valid?
errors.add(:residence_in_madrid, false)
store_failed_attempt
Lock.increase_tries(user)
end
end
private
def valid_postal_code?
postal_code =~ /^280/
end
end
```
Do not forget to cover your changes with a test at the `spec/models/custom` folder. Following the example we could create `spec/models/custom/residence_spec.rb`:
```ruby
require 'rails_helper'
describe Verification::Residence do
let(:residence) { build(:verification_residence, document_number: "12345678Z") }
describe "verification" do
describe "postal code" do
it "should be valid with postal codes starting with 280" do
residence.postal_code = "28012"
residence.valid?
expect(residence.errors[:postal_code].size).to eq(0)
residence.postal_code = "28023"
residence.valid?
expect(residence.errors[:postal_code].size).to eq(0)
end
it "should not be valid with postal codes not starting with 280" do
residence.postal_code = "12345"
residence.valid?
expect(residence.errors[:postal_code].size).to eq(1)
residence.postal_code = "13280"
residence.valid?
expect(residence.errors[:postal_code].size).to eq(1)
expect(residence.errors[:postal_code]).to include("In order to be verified, you must be registered in the municipality of Madrid.")
end
end
end
end
```

View File

@@ -0,0 +1,15 @@
# Overwritting Application
If you need to extend or modify the `config/application.rb` just do it at the `config/application_custom.rb` file. For example if you want to change de default language to English, just add:
```ruby
module Consul
class Application < Rails::Application
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :es]
end
end
```
Remeber that in order to see this changes live you'll need to restart the server.

View File

@@ -0,0 +1,39 @@
# Texts & Translations
## Translations
Currently, CONSUL is totally or partially translated to multiple languages. You can find the translations at the [Crowdin project](https://crowdin.com/project/consul).
Please [join the translators](https://crwd.in/consul) to help us complete existing ones, or contact us through [CONSUL's gitter](https://gitter.im/consul/consul) to become a proofreader and validate translators' contributions.
If your language isn't already present in the Crowdin project, please [open an issue](https://github.com/consul/consul/issues/new?title=New%20language&body=Hello%20I%20would%20like%20to%20have%20my%20language%20INSERT%20YOUR%20LANGUAGE%20NAME%20added%20to%20CONSUL) and we'll set it up in a breeze.
If you want to check existing translations of the user-facing texts you can find them organized in YML files under `config/locales/` folder. Take a look at the official Ruby on Rails [internationalization guide](http://guides.rubyonrails.org/i18n.html) to better understand the translations system.
## Custom Texts
Since CONSUL is always evolving with new features, and in order to make your fork easier to be updated, we strongly recommend translation files not to be modified, but instead "overwritten" with custom translation files in case a text needs to be customized for you.
So if you just want to change some of the existing texts, you can just drop your changes at the `config/locales/custom/` folder. We strongly recommend to include only those texts that you want to change instead of a whole copy of the original file. For example if you want to customize the text "Ayuntamiento de Madrid, 2016" that appears on every page's footer, firstly you want to locate where it's used \(`app/views/layouts/_footer.html.erb`\) and look at the locale identifier inside the code:
```ruby
<%= t("layouts.footer.copyright", year: Time.current.year) %>
```
Then find the file where this identifier will be located \(in that case `config/locales/es/general.yml`\) following this structure \(we're only displaying the relevant parts in the following snippet\):
```text
es:
layouts:
footer:
copyright: Ayuntamiento de Madrid, %{year}
```
In order to customize it, you should create a new file `config/locales/custom/es/general.yml` with just that content, and change "Ayuntamiento de Madrid" with our organization name. We strongly recommend to make copies from `config/locales/` and modify or delete the lines as needed to keep the indentation structure and avoid issues.
## Maintaining your Custom Texts & Languages
CONSUL has the [i18n-tasks](https://github.com/glebm/i18n-tasks) gem, it's an awesome helping tool to manage i18n translations. Just check `i18n-tasks health` for a nice report.
If you have a custom language different than English, you should add it to the [i18n-tasks.yml config file both `base_locale` and `locales`](https://github.com/consul/consul/blob/master/config/i18n-tasks.yml#L4-L7) variables so your language files will be checked as well.

View File

@@ -0,0 +1,34 @@
# Views & Styles
## Views \(HTML\)
If you want to change any page HTML you can just find the correct file under the `app/views` folder and put a copy at `app/views/custom` keeping as well any sub-folder structure, and then apply your customizations. For example if you want to customize `app/views/pages/conditions.html` you'll have to make a copy at `app/views/custom/pages/conditions.html.erb` \(note the `pages` subdirectory\).
## CSS Styles with SASS
In order to make changes to any CSS selector \(custom style sheets\), you can add them directly at `app/assets/stylesheets/custom.scss`. For example to change the header color \(`.top-links`\) you can just add:
```css
.top-links {
background: red;
}
```
If you want to change any [foundation](http://foundation.zurb.com/) variable, you can do it at the `app/assets/stylesheets/_custom_settings.scss` file. For example to change the main application color just add:
```css
$brand: #446336;
```
We use [SASS, with SCSS syntax](http://sass-lang.com/guide) as CSS preprocessor.
Also you can check your scss files syntax with
```bash
scss-lint
```
### Accesibility
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\)

View File

@@ -0,0 +1,8 @@
# Technical Features
* [OAuth](oauth.md)
* [GraphQL](graphql.md)
* [Recommendations](recommendations.md)
* [Configure Census Connection](census_configuration.md)
* [Local Census](local_census.md)

View File

@@ -0,0 +1,149 @@
# Configure Census Connection
The objective of this service is to be able to configure the connection with the Town Hall Census through the Administration panel without having to modify the application code.
It should be noted that to properly configure this connection will require a technical profile that knows the WebService of your City Council.
Currently the application was designed to send only the **document number** and **document type**. With this new feature is enabled the possibility of sending if necessary the fields **date of birth** and **postal code**.
## Activate feature
In the section **Configuration &gt; Global Configuration** a new tab **Remote Census Configuration** has been added.
If we have the feature deactivated we will see an informative text that will indicate us how to activate it: ![Feature disabled](../../.gitbook/assets/feature-disabled-en.png)
To activate the feature you must follow the instructions of the previous image: 1. Access through the administration panel of your application to the section **Settings &gt; Features** and activate the module **Configure connection to the remote census \(SOAP\)** as shown below: ![Feature enabled](../../.gitbook/assets/feature-enabled-en.png)
## Configuration
Once the feature is activated, we can access the section **Settings &gt; Global Settings** and click on the tab **Remote Census Configuration**. In this screen you will be able to fill in all the necessary information to be able to configure the connection with the Census of each Town Hall.
The information to be filled in is divided into three sections:
1. **General Information**
* **Endpoint**: Host name where the census service is available \(wsdl\).
![General information - Endpoint](../../.gitbook/assets/general-information-endpoint-en.png)
2. **Request Data**
In this section we will fill in all the necessary fields to be able to make a request to verify a user through the Census of the City council.
![Request Data](../../.gitbook/assets/request-data-en.png)
To help you understand how to fill in each of the fields, we will rely on a supposed WebService that receives a method called `:get_habita_datos` with the following structure:
```text
{
request: {
codigo_institucion: 12, # Static Value
codigo_portal: 5, # Static Value
codigo_usuario: 10, # Static Value
documento: 12345678Z, # Dynamic value related to Document Number
tipo_documento: 1, # Dynamic value related to Document Type
nivel: 3 # Static Value
}
}
```
Required fields for the request:
* **Request method name**: Request method name accepted by the City Census WebService.
Example: ![Request Data - Method name](../../.gitbook/assets/request-data-method-name-en.png)
* **Request Structure**: Structure of the request received by the WebService of the Census of the City Council. The "static" values of this request should be reported. The "dynamic" values related to Document Type, Document Number, Date of Birth and Postal Code should be filled with null value.
Example: ![Request Data - Structure](../../.gitbook/assets/request-data-structure-en.png) ![Request Data - Structure](../../.gitbook/assets/request-data-structure-info-en.png)
* **Path for document type**: Path in the request structure that sends the Document Type.
_NOTE: DO NOT FILL IN if the WebService does not require the Document Type to verify a user._
Example: ![Request Data - Path document type](../../.gitbook/assets/request-data-path-document-type-en.png)
* **Path for document number**: Path in the request structure that sends the Document Number.
_NOTE: DO NOT FILL IN if the WebService does not require the Document Number to verify a user._
Example: ![Request Data - Path document number](../../.gitbook/assets/request-data-path-document-number-en.png)
* **Path for date of birth**: Path in the request structure that sends the Date of Birth.
_NOTE: DO NOT FILL IN if the WebService does not require the Date of Birth to verify a user._
In the case of _Example_ we will fill it in blank, since it is not necessary to send the date of birth to verify a user.
Example: ![Request Data - Path date of birth](../../.gitbook/assets/request-data-path-date-of-birth-en.png)
* **Path for Postal Code**: Path in the request structure that sends the Postal Code.
_NOTE: DO NOT FILL IN if the WebService does not require the Postal Code to verify a user._
En el caso del _Example_ lo dejaríamos en blanco, ya que no se necesita enviar el código postal para verificar a un usuario.
Example: ![Request Data - Path postal code](../../.gitbook/assets/request-data-path-postal-code-en.png)
3. **Response data**
In this section we will configure all the necessary fields to be able to receive the answer of the WebService and to verify a user in the application.
![Response Data](../../.gitbook/assets/response-data-en.png)
As in the previous section we will define an example answer, to help you understand how to fill in each of the fields in this section.
```text
{
get_habita_datos_response: {
get_habita_datos_return: {
datos_habitante: {
item: {
fecha_nacimiento_string: "31-12-1980",
identificador_documento: "12345678Z",
descripcion_sexo: "Varón",
nombre: "José",
apellido1: "García"
}
},
datos_vivienda: {
item: {
codigo_postal: "28013",
codigo_distrito: "01"
}
}
}
}
}
```
Required fields to parse the response:
* **Path for Date of Birth**: In what path of the response is the user's Date of Birth?.
Example: ![Response Data - Path date of birth](../../.gitbook/assets/response-data-path-date-of-birth-en.png)
* **Path for Postal Code**: In what path of the response is the user's Postal Code?.
Example: ![Response Data - Path postal code](../../.gitbook/assets/response-data-path-postal-code-en.png)
* **Path for District**: In what path of the response is the user's District?.
Example: ![Response Data - Path district](../../.gitbook/assets/response-data-path-district-en.png)
* **Path for Gender**: In what path of response is the user's Gender?.
Example: ![Response Data - Path Gender](../../.gitbook/assets/response-data-path-gender-en.png)
* **Path for Name**: In what path of the response is the user's Name?.
Example: ![Response Data - Path Name](../../.gitbook/assets/response-data-path-name-en.png)
* **Path for the Last Name**: In what path of the response is the user's Last Name?.
Example: ![Response Data - Path Last Name](../../.gitbook/assets/response-data-path-last-name-en.png)
* **Condition for detecting a valid response**: What response path has to come informed to be considered a valid response and user verified.
Example: ![Response Data - Path valid response](../../.gitbook/assets/response-data-path-valid-response-en.png)
Once the general data, the necessary fields of the request and "all" fields to validate the response have been filled in correctly, the application will be able to verify any user through the defined WebService.

View File

@@ -0,0 +1,431 @@
# GraphQL
* [Characteristics](graphql.md#characteristics)
* [GraphQL](graphql.md#graphql)
* [Making API requests](graphql.md#making-api-requests)
* [Supported clients](graphql.md#supported-clients)
* [GraphiQL](graphql.md#graphiql)
* [Postman](graphql.md#postman)
* [HTTP libraries](graphql.md#http-libraries)
* [Available information](graphql.md#available-information)
* [Examples of queries](graphql.md#examples-of-queries)
* [Request a single record from a collection](graphql.md#request-a-single-record-from-a-collection)
* [Request a complete collection](graphql.md#request-a-complete-collection)
* [Pagination](graphql.md#pagination)
* [Accessing several resources in a single request](graphql.md#accessing-several-resources-in-a-single-request)
* [Security limitations](graphql.md#security-limitations)
* [Example of too deep query](graphql.md#example-of-too-deep-query)
* [Example of too complex query](graphql.md#example-of-too-complex-query)
* [Code examples](graphql.md#code-examples)
## Characteristics
* Read-only API
* Public access, no authentication needed
* Uses GraphQL technology:
* Maximum page size \(and the default\) is 25 records
* Maximum query depth is set at 8 levels
* A maximum of two collections can be requested within the same query
* Support for GET requests \(query must be inside the _query string_\) and POST requests \(query must be within the _body_, encoded as `application/json` or `application/graphql`\)
## GraphQL
The CONSUL API uses GraphQL [http://graphql.org](http://graphql.org), the [Ruby implementation](http://graphql-ruby.org/), to be specific. If you're not familiar with this kind of APIs, it's recommended to make some research about GraphQL before.
One of the characteristics that differentiates a REST API from a GraphQL one is that with the last one it's possible for the client to build its own _custom queries_, so the server will only return information in which we're interested.
GraphQL queries are written following a standard which ressembles to JSON, for example:
```text
{
proposal(id: 1) {
id,
title,
public_author {
id,
username
}
}
}
```
Responses are formatted in JSON:
```javascript
{
"data": {
"proposal": {
"id": 1,
"title": "Hacer las calles del centro de Madrid peatonales",
"public_author": {
"id": 2,
"username": "electrocronopio"
}
}
}
}
```
## Making API requests
Following [the official recommendations](http://graphql.org/learn/serving-over-http/), the CONSUL API supports the following kind of requests:
* GET requests, with the query inside the _query string_.
* POST requests
* With the query inside the _body_, with `Content-Type: application/json`
* With the query inside the _body_, with `Content-Type: application/graphql`
### Supported clients
Because it's an API that works through HTTP, any tool capable of making this kind of requests is capable of querying the API.
This section presents a few examples about how to make requests using:
* GraphiQL
* Chrome extensions like Postman
* Any HTTP library
#### GraphiQL
[GraphiQL](https://github.com/graphql/graphiql) is a browser interface for making queries against a GraphQL API. It's also an additional source of documentation. It's deployed in the route `/graphiql` and it's the best way to get familiar with GraphQL-based APIs.
![GraphiQL](../../.gitbook/assets/graphiql.png)
It has three main panels:
* The left panel is used to write the query.
* The central panel shows the result of the request.
* The right panel \(occultable\) shows a documentation autogenerated from the models and fields exposed in the API.
#### Postman
Example of `GET` request, with the query as part of the _query string_:
![Postman GET](../../.gitbook/assets/graphql-postman-get.png)
Example of `POST` request, with the query as part of the _body_ and encoded as `application/json`:
![Postman POST](../../.gitbook/assets/graphql-postman-post-headers.png)
The query must be located inside a valid JSON document, as the value of the `"query"` key:
![Postman POST](../../.gitbook/assets/graphql-postman-post-body.png)
#### HTTP libraries
Sure you can use any HTTP library available for most programming languages.
**IMPORTANT**: Due to security protocols from the Madrid City Council servers, it's necessary to include a _User Agent_ header from a web browser so the request is not rejected. For example:
`User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36`
## Available information:
The [config/api.yml](https://github.com/consul/docs/tree/b4ff5e1fdec31baa3e732562392eba3d2805505c/config/api.yml) file contains a complete list of all the models \(and their attributes\) which are currently being exposed in the API.
The models are the following:
| Model | Description |
| :--- | :--- |
| `User` | Users |
| `Debate` | Debates |
| `Proposal` | Proposals |
| `Comment` | Comments on debates, proposals and other comments |
| `Geozone` | Geozones \(districts\) |
| `ProposalNotification` | Notifications related to proposals |
| `Tag` | Tags on debates and proposals |
| `Vote` | Information related to votes |
## Examples of queries
### Request a single record from a collection
```text
{
proposal(id: 2) {
id,
title,
comments_count
}
}
```
Response:
```javascript
{
"data": {
"proposal": {
"id": 2,
"title": "Crear una zona cercada para perros en Las Tablas",
"comments_count": 10
}
}
}
```
### Request a complete collection
```text
{
proposals {
edges {
node {
title
}
}
}
}
```
Response:
```javascript
{
"data": {
"proposals": {
"edges": [
{
"node": {
"title": "ELIMINACION DE ZONA APARCAMIENTO EXCLUSIVO FUNCIONARIOS EN MADRID"
}
},
{
"node": {
"title": "iluminación de zonas deportivas"
}
}
]
}
}
}
```
#### Pagination
The maximum \(and default\) number of records that each page contains is set to 25. For navigating through the different pages it's necessary to request also information relative to the `endCursor`:
```text
{
proposals(first: 25) {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
title
}
}
}
}
```
The response:
```javascript
{
"data": {
"proposals": {
"pageInfo": {
"hasNextPage": true,
"endCursor": "NQ=="
},
"edges": [
# ...
]
}
}
}
```
To retrieve the next page, you have to pass as a parameter the cursor received in the previous request, and so on:
```text
{
proposals(first: 25, after: "NQ==") {
pageInfo {
hasNextPage
endCursor
}
edges {
node {
title
}
}
}
}
```
### Accessing several resources in a single request
This query requests information about several models in a single request: `Proposal`,`User`, `Geozone` and`Comment`:
```text
{
proposal(id: 15262) {
id,
title,
public_author {
username
},
geozone {
name
},
comments(first: 2) {
edges {
node {
body
}
}
}
}
}
```
## Security limitations
Allowing a client to customize queries is a major risk factor. If too complex queries were allowed, it would be possible to perform a DoS attack against the server.
There are three main mechanisms to prevent such abuses:
* Pagination of results
* Limit the maximum depth of the queries
* Limit the amount of information that is possible to request in a query
### Example of too deep query
The maximum depth of queries is currently set at 8. Deeper queries \(such as the following\) will be rejected:
```text
{
user(id: 1) {
public_proposals {
edges {
node {
id,
title,
comments {
edges {
node {
body,
public_author {
username
}
}
}
}
}
}
}
}
}
```
The response will look something like this:
```javascript
{
"errors": [
{
"message": "Query has depth of 9, which exceeds max depth of 8"
}
]
}
```
### Example of too complex query
The main risk factor is when multiple collections of resources are requested in the same query. The maximum number of collections that can appear in the same query is limited to 2. The following query requests information from the `users`,`debates` and `proposals` collections, so it will be rejected:
```text
{
users {
edges {
node {
public_debates {
edges {
node {
title
}
}
},
public_proposals {
edges {
node {
title
}
}
}
}
}
}
}
```
The response will look something like this:
```javascript
{
"errors": [
{
"message": "Query has complexity of 3008, which exceeds max complexity of 2500"
},
{
"message": "Query has complexity of 3008, which exceeds max complexity of 2500"
},
{
"message": "Query has complexity of 3008, which exceeds max complexity of 2500"
}
]
}
```
However, it is possible to request information belonging to more than two models in a single query, as long as you do not try to access the entire collection. For example, the following query that accesses the `User`,`Proposal` and `Geozone` models is valid:
```text
{
user(id: 468501) {
id
public_proposals {
edges {
node {
title
geozone {
name
}
}
}
}
}
}
```
The response:
```javascript
{
"data": {
"user": {
"id": 468501,
"public_proposals": {
"edges": [
{
"node": {
"title": "Empadronamiento necesario para la admisión en GoFit Vallehermoso",
"geozone": {
"name": "Chamberí"
}
}
}
]
}
}
}
}
```
## Code examples
The [doc/api/examples](https://github.com/consul/consul/tree/master/doc/api/examples/ruby) directory contains examples of code to access the API.

View File

@@ -0,0 +1,33 @@
# Local Census
To provide to administrator users a way to manage the local census database through the administration panel **Settings &gt; Manage local census**. Currently the only way to manipulate this table records is through the rails console.
Allow adiministrators users to manage this table in two different ways:
* **Manually**: one by one through a CRUD interface.
* **Automatically**: through an importation process.
## Manually
Provide a way to manage local census records to administrator users through administration interface.
* Local Census Page
![Manage local census](../../.gitbook/assets/manage-local-census-en.png)
* Add new record
![Create local census record](../../.gitbook/assets/add-local-census-record-en.png)
Features:
1. Search by document\_number: As local\_census\_records could contain a lot of records we have added a search feature to allow administrators to find existing records by document\_number.
2. Avoid the introduction of duplicated records: A model validation has been added to the following attributes pair \[:document\_number, :document\_type\]
## Automatically
Allow administrator users to import local census records though CSV file.
* Local Census Page ![Manage local census csv](../../.gitbook/assets/manage-local-census-csv-en%20%281%29.png)
* Import CSV ![Create local census records csv](../../.gitbook/assets/add-local-census-records-csv-en.png)

View File

@@ -0,0 +1,33 @@
# OAuth
You can configure authentication services with external OAuth suppliers, right now Twitter, Facebook and Google are supported.
## 1. Create an App on the platform
For each platform, go to their developers section and follow their guides to create an app.
## 2. Set your CONSUL's url
They'll ask you for your CONSUL's auth URL, and as you can see running `rake routes` at your CONSUL repo locally:
```bash
user_omniauth_authorize GET|POST /users/auth/:provider(.:format) users/omniauth_callbacks#passthru {:provider=>/twitter|facebook|google_oauth2/}
```
So for example the URL for facebook application would be `yourdomain.com/users/auth/facebook/callback`
## 3. Set key & secret values
When you complete the application registration you'll get a _key_ and _secret_ values, those need to be stored at your `config/secrets.yml` file:
```text
twitter_key: ""
twitter_secret: ""
facebook_key: ""
facebook_secret: ""
google_oauth2_key: ""
google_oauth2_secret: ""
```
_NOTE:_ Also in the case of Google, verify that the APIs _Contacts API_ and _Google+ API_ are enabled for the application.

View File

@@ -0,0 +1,26 @@
# Recommendations
Logged in users can see recommended Debates or Proposals listed with the ordering option "recommendations".
The list shows, ordered by votes descending, those elements that: 1. Have tags that interests the user. Being those tags the ones on the proposals that the user follows. 2. The user isn't the author. 3. In the case of proposals: only those that haven't reached the required threshold of votes, hiding as well those that the user is already following.
## How to try it
In our local installation, if we haven't logged in, we can check at [http://localhost:3000/proposals](http://localhost:3000/proposals) that the "recommendations" ordering isn't present:
![Recommendations not logged in](../../.gitbook/assets/recommendations_not_logged_in%20%281%29.jpg)
Once we log in we see the menu, but because we don't aren't following any proposals we get the message "Follow proposals so we can give you recommendations" at [http://localhost:3000/proposals?locale=en&order=recommendations&page=1](http://localhost:3000/proposals?locale=en&order=recommendations&page=1)
![Recommendations no follows](../../.gitbook/assets/recommendations_no_follows%20%281%29.jpg)
After following any proposal with the "Follow citizen proposal" on the side menu:
![Recommendations follow button](../../.gitbook/assets/recommendations_follow_button%20%281%29.jpg)
We can finally see some recommendations:
![Recommendations with follows](../../.gitbook/assets/recommendations_with_follows%20%281%29.jpg)
The feature works the same for debates

View File

@@ -0,0 +1,7 @@
# Getting started
* [Fork Consul](create.md)
* [Configure your fork](configuration.md)
* [Keep your fork updated](update.md)
* [Communication](communication.md)

View File

@@ -0,0 +1,14 @@
# Communication
The prefered way to report any missing piece of information is [opening an issue in the project's Github repo](https://github.com/consul/docs/issues/new).
For more informal communication, chat with us at [consul's gitter](https://gitter.im/consul/consul)
Before doing it, **please take some time to check the** [**existing issues**](https://github.com/consul/consul/issues) **and make sure what you are about to report isn't already reported** by another person. In case someone else reported the same problem before or a similar one, and you have more details about it, you can write a comment in the issue page... a little more help can make a huge difference!
In order to write a new issue, take into account these few tips to make it easy to read and comprehend:
* Try to use a descriptive and to-the-point title.
* It's a good idea to include some sections -in case they're needed- such as: steps to reproduce the bug, expected behaviour/response, actual response or screenshots.
* Also it could be helpful to provide your operating system, browser version and installed plugins.

View File

@@ -0,0 +1,13 @@
# Configure your fork
## Travis CI
[Travis](https://travis-ci.org/) is a Continuous Integration service, free for OpenSource projects \(like Consul and it's forks\). It will help you check on each Pull Request if the test suite is allright.
1. Visit [https://github.com/marketplace/travis-ci](https://github.com/marketplace/travis-ci) and click the "**Install it for free**" green button at the bottom of the page.
2. Click on the "**Complete order and begin installation**" green button
3. If you are asked to Authorize Travis CI to access your Github account, check the organization or user where you have your consul fork at the bottom and click the "**Authorize travis-ci**" button.
4. Visit your [Travis profile](https://travis-ci.org/profile/) and enable Travis for your Consul fork in the list of repositories.
5. Click on the sprocket icon to the right of the repository to see the builds.
6. Check that everything is well configured by creating a test Pull Request \(editing a simple .md file could help\).

View File

@@ -0,0 +1,20 @@
# Fork Consul
Consul git repo is hosted at Github.com, we recommend using it for your fork's repo to make things easier. But you can use any other service like Bitbucket or Gitlab if you want to, just don't forget to put a reference link back to CONSUL on the footer to comply with project's license \(GPL Affero 3\).
1. [Register an user account on Github](https://github.com/join) if you don't have one
2. [Create an Organization](https://help.github.com/articles/creating-a-new-organization-from-scratch/) on Github with the name of your city or the organization that's going to use Consul. **This is not mandatory**, but it will help undertand the fork's purpose and future contributions by other users.
3. [Fork Consul](https://help.github.com/articles/fork-a-repo/) using the **fork** button on the top right corner at [https://github.com/consul/consul](https://github.com/consul/consul)
4. [Clone your fork repository](https://help.github.com/articles/cloning-a-repository/) on to your computer
**\*\*IMPORTANT NOTICE**: Do not fork `https://github.com/AyuntamientoMadrid/consul`, its a common mistake that leads to multiple and grave problems
## Why make code public?
We strongly recommend making code public for multiple reasons:
* **Transparency**: It should be part of the culture of public entities that adopt Consul, as well as any organization or group.
* **Support**: If you need technical help, both community and Consul core team will be able to understand and advice by easily seeing involved code.
* **Collaboration**: By other professionals, citizens, etc...
* Last but not least, Consul is distributed under the [**AGPLv3**](https://github.com/consul/consul/blob/master/LICENSE-AGPLv3.txt) **license** that commands to publish source code.

View File

@@ -0,0 +1,70 @@
# Keep your fork updated
## Configuring your git remotes
If you created your fork correctly and cloned it locally, running:
```bash
git remote -v
```
it should output something alike:
> origin git@github.com:your\_user\_name/consul.git \(fetch\)
> origin git@github.com:your\_user\_name/consul.git \(push\)
Now we have to add CONSUL's github as upstream remote with:
```bash
git remote add upstream git@github.com:consul/consul.git
```
and to check everything is fine with
```bash
git remote -v
```
again you should get:
> upstream git@github.com:consul/consul.git \(fetch\)
> upstream git@github.com:consul/consul.git \(push\)
> origin git@github.com:your\_user\_name/consul.git \(fetch\)
> origin git@github.com:your\_user\_name/consul.git \(push\)
## Pulling changes from CONSUL
Start by creating a branch named **upstream** from your **master** branch to apply CONSUL changes:
```bash
git checkout master
git pull
git checkout -b upstream
```
Then we can fetch all changes from **consul** remote server with:
```bash
git fetch upstream
```
And then you can choose to either:
A. Get all the latest changes on CONSUL's **master** branch with `git merge upstream/master`
B. Just update up to an specific release tag \(so you can do incremental updates if you're more than one release behind\). For example to update up to [v0.9](https://github.com/consul/consul/releases/tag/v0.9) release just: `git merge v0.9`
## Merging changes
After the previous section `merge` command, there are three possible outcomes:
A. You get a nice `Already up-to-date.` response. That means your fork is up to date with consul 😊👌
B. You get a screen on your git configured editor showing the commit message `Merge remote-tracking branch 'upstream/master' into upstream`. That means git was able to grab latest changes from CONSUL's master branch, and it can merge them without code change conflicts. Finish the commit.
C. You get some git errors along with a `Automatic merge failed; fix conflicts and then commit the result.` message. That means there are conflicts between the code changes you did and the ones done on CONSUL repository since the last time you update it. That's the main reason we strongly recommend often updates of your fork \(think at least monthly\). Resolve merge conflicts carefully and commit them.
Now you can just simply push your **upstream** branch to github and create a Pull Request so you can easily check all changes going into your repo, and see your tests suite runs.
Remember you can always quickly check changes that will come from CONSUL to your fork by replacing **your\_org\_name** on the url: [https://github.com/your\_org\_name/consul/compare/master...consul:master](https://github.com/your_org_name/consul/compare/master...consul:master)

View File

@@ -0,0 +1,9 @@
# Installation
These are our recommendations for the different environments and purposes:
* To setup CONSUL for a production environment we recommend using the [installer](https://github.com/consul/installer).
* For developers working on a CONSUL fork we recommend using a UNIX based system \(Linux or Mac\) and installing CONSUL [locally system wide](local_installation/).
* If you run into problems configuring CONSUL locally system wide and would like to show CONSUL for demo purposes we recommend using [Docker](servers/docker.md) in a local machine.
* We also have a [Heroku guide](../../spanish-documentation/introduction/servers/deploying-on-heroku.md) which can be used for demo purposes in a remote server.

View File

@@ -0,0 +1,81 @@
# Basic configuration
Once you have CONSUL running on the server, there are some basic configuration options that you probably want to define in order to start using it. To do this you will need to open your CONSUL installation through any internet browser and log in with the administration user \(initially it is the `admin@consul.dev` user with the password `12345678`\).
Once you have logged in you will see on the top right of the screen the "Admin" link that will take you to the administration interface. From this interface you can configure the following basic options:
## Global configuration parameters
In the side menu you will find the option "Settings" and then the submenu "Global Settings". Here you will find many interesting parameters, but at the moment we recommend you to define some of the most basic ones. Later, when you are more familiar with the tool, you will be able to reconfigure other parameters:
* Site name. This name will appear in the subject of emails, help pages...
* Sender email name. This name will appear as the name of the sender in the emails sent from the application. As for example the email that the users receive to confirm that they have created their account.
* Sender email address. This email address will appear in the emails sent from the application.
* Main URL. Main URL of your website
* Minimum age needed to participate. If you use a user verification system this will be the minimum age that users will be required to be. The user verification system will be discussed in more detail later.
* Number of supports necessary for approval of a Proposal. If you use the citizen proposals section, you can define a minimum number of supports that the proposals need in order to be considered. Any user will be able to create proposals but only those that reach that value will be taken into account.
* Level x public official . CONSUL allows some user accounts to be marked as "official accounts" and their interventions on the platform are highlighted. This for example is used in a city if you want to define accounts for the Mayor, Councillors, etc. This public official option will allow you to define the official label that appears next to the user names of these accounts from most important \(level 1\) to least \(level 5\).
## Categories of proposals
When users create proposals on the platform, a few general categories are suggested to help organize the proposals. To define these categories you can go to the "Global Settings" menu and then to the "Proposal Topics" submenu. At the top you can write topics and create them with the button below.
## Definition of Geozones
Geozones are smaller territorial areas than the area in which you use CONSUL \(e.g. districts in a city in which CONSUL is used\). If the geozones are activated, it will allow for example that the citizen proposals are assigned to a specific area, or that the votings are restricted to people living in some area.
In the side menu you will find the option "Settings" and then the submenu "Manage geozones". To the right the button "Create geozone" will allow you to create new geozones. Only the name is necessary to define them, but you can add other data that are useful in certain sections. Initially we recommend that you start by defining only the names of the zones.
Once defined if you create a citizen proposal you will see how one of the options in the proposal creation form allows you to choose if your proposal refers to a specific geozone.
If you activate the geozones you can also display an image that represents the area with the zones. You can change this image in the "Global settings" menu in the "Customize images" submenu. The default image you can change is the one titled "map".
## Map to geolocate proposals
You can allow users to place proposals on a map when creating proposals. To do this you have to define which map you want to show.
First go to the "Settings" menu and to the "Global Settings" submenu. There you will find three parameters that you will have to fill in:
* Latitude. Latitude to show the map position
* Length. Length to show the map position
* Zoom. Zoom to show the position of the map. You can try an initial value and then change it later.
At the top of this page you will find three tabs: "Configuration settings", "Features", "Map configuration". Now go to the second tab "Features".
On this page you will find one of the functionalities titled "Proposals and budget investments geolocation ". The message "Functionality enabled" should appear on your right. If not, click on the "Enable" button.
Then, at the top of this page, go to the "Map configuration" tab. If everything has been configured correctly you will see here the map centered on the latitude and longitude you entered before. You can correctly center the map and change the zoom level directly on the map by clicking on the "Update" button below it.
## Emails to users
CONSUL sends a series of emails to users by default. For example when creating a user account, trying to recover a password, receiving a message from another user, etc.
All emails sent can be viewed in the menu "Messages to users" in the submenu "System Emails". There you will be able to preview each email and see the file where the content of the email is in case you want to change it.
## Basic information pages
CONSUL has a number of basic information pages that will be shown to users, e.g. "Privacy Policy", "Frequently Asked Questions", "Congratulations you have just created your user account", etc.
You can see the pages that exist by default and modify them in the menu "Site Content" in the submenu "Custom Pages".
## Main page of the site
When users open your CONSUL installation they will see the home page of the platform. This page is fully configurable, so that you can show the content that seems most relevant to you. You can modify it from the menu "Site content" in the submenu "Homepage".
Try creating "Headers" and "Cards" and activating the different functionalities you will find below to see the effect they have on your homepage.
## Platform texts
If you access the menu "Site content" and the submenu "Custom information texts" you will see different tabs with a series of texts. These are all the texts displayed on the platform. By default you can use the existing ones, but at any time you can access this section to modify any of the texts.
For more information on how to add new translations to your version of CONSUL access the "Texts and translations" section of this documentation.
## Channels of participation
By default you will find in CONSUL different ways of participation for users. To begin with and familiarise yourself with the tool, we recommend that you have all of them activated, but you can deactivate the ones that do not seem necessary to you. To do this, go to the "Settings" menu and then to the "Global Settings" submenu. At the top of this page you will find three tabs: "Configuration settings", "Features", "Map configuration". Go to the second tab "Features".
You will find different functionalities with the names of the different participation channels "Debates", "Proposals", "Voting", "Collaborative Legislation" and "Participatory Budgets". You can deactivate any of the functionalities and it will no longer be shown in your CONSUL installation.
### More information and detailed documentation
These options above will allow you to have a basic version of CONSUL to start using. We recommend that you access the [CONSUL Documentation and Guides](documentation_and_guides.md) section where you can find more detailed documentation.

View File

@@ -0,0 +1,10 @@
# CONSUL Documentation and guides
There are several guides where you can read very detailed information about CONSUL and its possibilities. You can find them all at: [http://consulproject.org/en/\#documentation](http://consulproject.org/en/#documentation)
* **CONSUL Use Guide**. In this guide you can see different ways to use CONSUL and examples of participation processes.
* **CONSUL Administration Guide**. This guide contains detailed information on the administration and management of CONSUL.
* **CONSUL Communication Guide**. This guide can give you an initial idea of how to plan communication campaigns to invite people to use your CONSUL platform. Communication is a key issue in getting relevant participation and engagement.
In addition to these guides you can access the [CONSUL Community](http://community.consulproject.org/), a discussion space to share more documentation, questions, learning, etc.

View File

@@ -0,0 +1,74 @@
# Local installation
Before installing Consul and having it up and running make sure you all [prerequisites](prerequisites.md) installed.
1. First, clone the [Consul Github repository](https://github.com/consul/consul/) and enter the project folder:
```bash
git clone https://github.com/consul/consul.git
cd consul
```
1. Install the Ruby version we need with your Ruby version manager. Here are some examples:
```bash
rvm install `cat .ruby-version` # If you're using RVM
rbenv install `cat .ruby-version` # If you're using rbenv
asdf install ruby `cat .ruby-version` # If you're using asdf
```
1. Check we're using the Ruby version we've just installed:
```bash
ruby -v
=> # (it should be the same as the version in the .ruby-version file)
```
1. Install [Bundler](http://bundler.io/):
```bash
gem install bundler --version 1.17.1
```
1. Install the required gems using Bundler:
```bash
bundle
```
1. Copy the environment example configuration files inside new readable ones:
```bash
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml
```
And setup database credentials with your `consul` user in your new `database.yml` file.
1. Run the following [Rake tasks](https://github.com/ruby/rake) to create and fill your local database with the minimum data needed to run the application:
```bash
rake db:create
rake db:setup
rake db:dev_seed
rake db:test:prepare
```
1. Check everything is fine by running the test suite \(beware it might take more than an hour\):
```bash
bin/rspec
```
1. Now you have all set, run the application:
```bash
bin/rails s
```
Congratulations! Your local Consul application will be running now at `http://localhost:3000`.
In case you want to access the local application as admin, a default user verified and with admin permissions was created by the seed files with **username** `admin@consul.dev` and **password** `12345678`.
If you need an specific user to perform actions such as voting without admin permissions, a default verified user is also available with **username** `verified@consul.dev` and **password** `12345678`.

View File

@@ -0,0 +1,167 @@
# Debian Linux
## Configuration for development and test environments \(Debian GNU/Linux 9.8\)
## Superuser
Note that 'sudo' is not installed by default in Debian. It's possible to install and configure it, you can find information [here](https://wiki.debian.org/sudo). But we don't recommend it cause you may have other problems. We recommend running the following commands as a superuser, so make sure the very first command you run is:
```text
su
```
> For [Vagrant](vagrant.md) run:
>
> ```text
> sudo su -
> ```
## System update
Run a general system update:
```bash
apt-get update
```
## Git
Git is officially maintained in Debian:
```text
apt-get install git
```
## Curl
Curl is officially maintained in Debian:
```text
apt-get install curl
```
## Ruby version manager
Ruby versions packaged in official repositories are not suitable to work with consul, so we'll have to install it manually.
One possible tool is rvm:
### As a local user
```text
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -L https://get.rvm.io | bash -s stable
```
then add rvm script source to user's bash \(~/.bashrc\) \(this step is only necessary if you can't execute the rvm command\)
```text
[[ -s /usr/local/rvm/scripts/rvm ]] && source /usr/local/rvm/scripts/rvm
```
and finally, reload .bashrc to be able to run RVM
```text
source ~/.bashrc
```
## Node.js
To compile the assets, you'll need a JavaScript runtime. Node.js is the preferred option. As with Ruby, we don't recommend installing Node from your distro's repositories.
To install it, you can use [n](https://github.com/tj/n)
Run the following command on your terminal:
```text
curl -L https://git.io/n-install | bash -s -- -y lts
```
And it will install the latest LTS \(Long Term Support\) Node version on your `$HOME` folder automatically \(This makes use of [n-install](https://github.com/mklement0/n-install)\)
Reload .bashrc to be able to run node
```text
source /root/.bashrc
```
Check it's correctly installed by running:
```text
node -v
```
## PostgreSQL \(&gt;=9.4\)
PostgreSQL version 9.4 is not official in debian 9.
So you have to add a repository, the official postgresql works fine.
Add the repository to apt, for example creating file _/etc/apt/sources.list.d/pgdg.list_ with:
```text
deb http://security.debian.org/debian-security jessie/updates main
```
afterwards you'll have to download the key, and install it, by:
```text
wget https://www.postgresql.org/media/keys/ACCC4CF8.asc
apt-key add ACCC4CF8.asc
```
and install postgresql
```text
apt-get update
apt-get install postgresql-9.4 postgresql-server-dev-9.4 postgresql-contrib-9.4
```
You also need to configure a user for your database. As an example, we'll choose the username "consul":
```text
su - postgres
createuser consul --createdb --superuser --pwprompt
exit
```
## Imagemagick
Install Imagemagick:
```bash
apt-get install imagemagick
```
## ChromeDriver
To run E2E integration tests, we use Selenium along with Headless Chrome.
To get it working, install the chromedriver package:
```bash
apt-get install chromedriver
ln -s /usr/lib/chromedriver /usr/local/bin/
```
Make sure it's working as expected by running the following command:
```bash
chromedriver --version
```
You should receive an output with the latest version of ChromeDriver. If that's the case, you're good to go!
If you are using an Arch-based distro, installing `chromium` from the `extra` repository should be sufficient.
You also have the option of just installing ChromeDriver from AUR. If you use `pacaur`, run the following command:
```bash
pacaur -S chromedriver
```
Now you're ready to go get Consul [installed](./)!!

View File

@@ -0,0 +1,104 @@
# MacOS
## Homebrew
Homebrew is a very popular package manager for OS X. It's advised to use it since it makes the installation of some of the dependencies much easier.
You can find the installation instructions at: [brew.sh](http://brew.sh)
## XCode and XCode Command Line Tools
To install _git_ you'll first need to install _Xcode_ \(download it from the Mac App Store\) and its _Xcode Command Line Tools_ \(you can install them from the Xcode's app menu\)
## Git and Github
You can download git from: [git-scm.com/download/mac](https://git-scm.com/download/mac)
## Ruby version manager
OS X already comes with a preinstalled Ruby version, but it's quite old and we need a newer one. One of the multiple ways of installing Ruby in OS X is through _rbenv_. The installation instructions are in its GitHub repository and are pretty straight-forward:
[github.com/rbenv/rbenv](https://github.com/rbenv/rbenv)
## Node.js
To compile the assets, you'll need a JavaScript runtime. OS X comes with an integrated runtime called `Apple JavaScriptCore` but Node.js is the preferred option.
To install it, you can use [n](https://github.com/tj/n)
Run the following command on your terminal:
```text
curl -L https://git.io/n-install | bash -s -- -y lts
```
And it will install the latest LTS \(Long Term Support\) Node version on your `$HOME` folder automatically \(This makes use of [n-install](https://github.com/mklement0/n-install)\)
## PostgreSQL \(&gt;=9.4\)
```text
brew install postgres
```
Once installed, we need to _initialize_ it:
```text
initdb /usr/local/var/postgres
```
Now we're going to configure some things related to the _default user_. First we start postgres server with:
```text
postgres -D /usr/local/var/postgres
```
At this point we're supposed to have postgres correctly installed and a default user will automatically be created \(whose name will match our username\). This user hasn't got a password yet.
If we run `psql` we'll login into the postgres console with the default user. Probably it will fail since its required that a default database exists for that user. We can create it by typing:
```text
createdb 'your_username'
```
If we run `psql` again we should now get access to postgres console. With `\du` you can see the current users list.
In case you want to set a password for your user you can make it throught postgres console by:
```text
ALTER USER your_username WITH PASSWORD 'your_password';
```
Now we'll create the _consul_ user, the one the application is using. Run in postgres console:
```text
CREATE ROLE consul WITH PASSWORD '000';
ALTER ROLE consul WITH SUPERUSER;
ALTER ROLE consul WITH login;
```
If at any point during PostgreSQL installation you feel you have messed things up, you can uninstall it and start again by running:
```text
brew uninstall postgres
```
You'll have to delete also this directory \(otherwise the new installation will generate conflicts, source: [gist.github.com/lxneng/741932](https://gist.github.com/lxneng/741932)\):
```text
rm -rf /usr/local/var/postgres
```
## ChromeDriver
```text
brew install chromedriver
```
## Imagemagick
```text
brew install imagemagick
```
Now that we have all the dependencies installed we can go ahead and [install Consul](./).

View File

@@ -0,0 +1,7 @@
# Prerequisites
* [Ubuntu Linux](ubuntu.md)
* [Debian Linux](debian.md)
* [MacOS](macos.md)
* [Windows](windows.md)

View File

@@ -0,0 +1,114 @@
# Ubuntu Linux
## Configuration for development and test environments \(Ubuntu 18.04\)
## System update
Run a general system update:
```bash
sudo apt update
```
## Git
Git is officially maintained in Ubuntu:
```bash
sudo apt install git
```
## Ruby version manager
Ruby versions packaged in official repositories are not suitable to work with CONSUL, so we'll have to install it manually.
First, we need to install Ruby's development dependencies:
```bash
sudo apt install libssl-dev autoconf bison build-essential libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev
```
The next step is installing a Ruby version manager, like rbenv:
```bash
wget -q https://github.com/rbenv/rbenv-installer/raw/master/bin/rbenv-installer -O- | bash
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
source ~/.bashrc
```
## Node.js
To compile the assets, you'll need a JavaScript runtime. Node.js is the preferred option.
Run the following command on your terminal:
```bash
sudo apt install nodejs
```
## PostgreSQL
Install postgresql and its development dependencies with:
```bash
sudo apt install postgresql libpq-dev
```
You also need to configure a user for your database. As an example, we'll choose the username "consul":
```bash
sudo -u postgres createuser consul --createdb --superuser --pwprompt
```
To make sure the UTF-8 enconding is used, create a file:
```text
sudo nano /etc/profile.d/lang.sh
```
Add the following:
```text
export LANGUAGE="en_US.UTF-8"
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"
```
Reconfigure Postgres to use the UTF-8 encoding:
```text
sudo su - postgres
psql
update pg_database set datistemplate=false where datname='template1';
drop database Template1;
create database template1 with owner=postgres encoding='UTF-8'
lc_collate='en_US.utf8' lc_ctype='en_US.utf8' template template0;
update pg_database set datistemplate=true where datname='template1';
\q
exit
```
## Imagemagick
Install Imagemagick:
```bash
sudo apt install imagemagick
```
## ChromeDriver
To run E2E integration tests, we use Selenium along with Headless Chrome.
To get it working, install the chromium-chromedriver package and make sure it's available on your shell's PATH:
```bash
sudo apt install chromium-chromedriver
sudo ln -s /usr/lib/chromium-browser/chromedriver /usr/local/bin/
```
Now you're ready to go [get CONSUL installed](./)!

View File

@@ -0,0 +1,48 @@
# Vagrant
## Vagrant
Install [Vagrant](https://www.vagrantup.com/) and setup a virtual machine with [Linux](prerequisites.md)
Vagrant is compatible for [Debian](debian.md) and [Ubuntu](ubuntu.md).
### Browser configuration
To access the application through the brower at `localhost:3000` we must forward a port and run the rails server with a binding option:
### Port forwarding
Open the Vagrant configuration file:
```text
nano Vagranfile
```
Find this line:
```text
# config.vm.network "forwarded_port", guest: 80, host: 8080
```
And change it for this configuration:
```text
config.vm.network "forwarded_port", guest: 3000, host: 3000
```
Reload your virtual machine:
```text
vagrant reload
```
## Running the rails server
In your virtual machine, run the application server, binding to your local ip address:
```text
bin/rails s -b 0.0.0.0
```
Now you should be able to see the application running in your browser at url `localhost:3000`! :tada:

View File

@@ -0,0 +1,4 @@
# Windows
Windows is not yet officially supported. Please install [Virtual Box](https://www.virtualbox.org/) to setup a virtual machine in [Linux](prerequisites.md).

View File

@@ -0,0 +1,22 @@
# Production and Staging servers
## Recommended Minimum System Requirements:
### 1. Production Server:
* Distribution: Ubuntu 16.04.X
* RAM: 32GB
* Processor: Quad core
* Hard Drive: 20 GB
* Database: Postgres
### 2. Staging Server:
* Distribution: Ubuntu 16.04.X
* RAM: 16GB
* Processor: Dual core
* Hard Drive: 20 GB
* Database: Postgres
If your city has a population of over 1.000.000, consider balancing your load using 2-3 production servers and a separate server for the database.

View File

@@ -0,0 +1,81 @@
# Create a deploy user
[The installer](https://github.com/consul/installer) by default connects as the `root` user only to create a `deploy` user. This `deploy` user is the one who installs all libraries. If you do not have `root` access, please ask your system administrator to follow these instructions to create a user manually.
You could create a user called `deploy` or any other name. As as example, we are going to create a user named `jupiter`.
```text
adduser jupiter
```
I'm using jupiter as the user name, you should change that for whatever makes sense to you. Input a password when prompted, and just leave empty the rest of the options.
Let's create a `wheel` group and add the user `jupiter` to this group.
```text
sudo groupadd wheel
sudo usermod -a -G wheel jupiter
```
Now let's give sudo privileges to the `wheel` group and allow it to not use a password, this is important so that the installer doesn't get stalled waiting for a password.
First we open the sudoers file:
```text
sudo visudo -f /etc/sudoers
```
And we add this line at the end:
```text
%wheel ALL=(ALL) NOPASSWD: ALL
```
Now we need to give the keys of the server to the new user. Dont close the server terminal window, because you can lock yourself out of your server if there is a mistake.
Let's create the necessary directory in the server to upload the public key:
```text
su jupiter
cd ~
mkdir .ssh
cd .ssh
nano authorized_keys
```
Make sure you have [generated a public key](generating_ssh_key.md) in your local terminal.
Open another local terminal window \(not in the server\) and type:
```text
cat ~/.ssh/id_rsa.pub
```
Copy the content of your public key to the file authorized\_keys that should still be open in the server.
Test that your user can log in by typing:
```text
ssh jupiter@your-copied-ip-address
```
You should see the server welcome page and a prompt like this:
```text
jupiter@consulserver:~$
```
Note the username at the prompt is not "root", but your username. So everything is fine and we can now block the root account from outside access and also stop allowing password access so only people with SSH keys can log in.
Type the following command to edit the SSH config file of the server:
```text
sudo nano /etc/ssh/sshd_config
```
Look for the "PasswordAuthentication yes" line and change it to "PasswordAuthentication no". Type Control-K to close the nano editor and type:
```text
sudo service ssh restart
```

View File

@@ -0,0 +1,53 @@
# Development Mail Server
This is a example to how integrate a mailing service with a development environment of Consul.
In this example we used [Mailgun](https://www.mailgun.com/).
## Create an account in Mailgun
![Creating an account in Mailgun](../../../.gitbook/assets/mailgun-create-account%20%281%29.png)
* Skip the credit card form
* And activate your account with the link sent by email
## Domain configuration
* Go to the Domains section: ![Mailgun domain section](../../../.gitbook/assets/mailgun-domains%20%281%29.png)
* Since you don't have a domain yet, you should click in the sandbox that is already created;
* Remember the next credentials:
![Mailgun sandbox](../../../.gitbook/assets/mailgun-sandbox%20%281%29.png)
## Consul mailing configuration for development environment
* Go to `config/environments/development.rb` file;
* Add the lines on the file to configure the mail server:
```ruby
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
:address => '',
:port => 2525,
:domain => '',
:user_name => '',
:password => '',
:authentication => :plain,
:enable_starttls_auto => true,
:ssl => false
}
```
* Fill, `address`, `domain`, `user_name`, `password` with your information. The file would look like:
![development.rb file](../../../.gitbook/assets/development.rb%20%281%29.png)
## Consul mailing configuration for production environment
* Go to `config/environments/production.rb` file.
* Add the same **action mailer settings** configuration, but now with your production mail server information.
* Pay attention because you will need to change the **port** number to **587**.
You can also use Mailgun to production, adding your custom domain. Mailguns logs sent and delivered emails.

View File

@@ -0,0 +1,60 @@
# Digital Ocean
These instructions will help you register and buy a server in Digital Ocean to install CONSUL.
First you need to [sign up](https://cloud.digitalocean.com/registrations/new) and provide your personal information.
Once you are logged in, you need to create a Droplet \(thats the name that Digital Ocean uses for a Virtual Server\). Click on the “Create” green button at the top of the page and select "Droplets":
![Digital Ocean Droplets](../../../.gitbook/assets/droplets%20%281%29.png)
In the next page, you need to select Ubuntu \(it should be pre-selected\) and change the version **from 18.04 x64 to 16.04 x64**.
![Digital Ocean Choose an image](../../../.gitbook/assets/image%20%281%29.png)
In the "Choose a size" section select the **$80/mo 16GB/6CPUs** option if this is going to be a production server. If you are just setting up a test system with a few users the cheapest $5/mo option can be enough.
![Digital Ocean Choose a size](../../../.gitbook/assets/size%20%281%29.png)
Leave the rest of the options with their defaults until “Choose a datacenter”. Select the one that will be geographically closer to your users. If you are in the EU, select either Frankfurt or Amsterdam data centers.
![Digital Ocean Choose a region](../../../.gitbook/assets/region%20%281%29.png)
In the "Add you SSH keys" section click "New SSH Key" button.
![Digital Ocean Add your SSH Keys](../../../.gitbook/assets/ssh_keys%20%281%29.png)
In the pop up window that appears you need to copy and paste the public key that we [generated in the previous step](generating_ssh_key.md). To see the content of this key in the terminal window type:
```text
cat ~/.ssh/id_rsa.pub
```
You should see a text like this:
```text
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDy/BXU0OsK8KLLXpd7tVnqDU+d4ZS2RHQmH+hv0BFFdP6PmUbKdBDigRqG6W3QBexB2DpVcb/bmHlfhzDlIHJn/oki+SmUYLSWWTWuSeF/1N7kWf9Ebisk6hiBkh5+i0oIJYvAUsNm9wCayQ+i3U3NjuB25HbgtyjR3jDPIhmg1xv0KZ8yeVcU+WJth0pIvwq+t4vlZbwhm/t2ah8O7hWnbaGV/MZUcj0/wFuiad98yk2MLGciV6XIIq+MMIEWjrrt933wAgzEB8vgn9acrDloJNvqx25uNMpDbmoNXJ8+/P3UDkp465jmejVd/6bRaObXplu2zTv9wDO48ZpsaACP your_username@your_computer_name
```
Select and copy all the text and paste it in the pop-up window like this:
![Digital Ocean New SSH Key](../../../.gitbook/assets/new_ssh%20%281%29.png)
Please note that there will be two little green checks. If they are not there, retry copying the text because you probably left something out. Give your key a meaningful name, like **CONSUL\_key** and click "Add SSH Key" button.
By using an SSH key instead of a user/password combination to access your server, it will be much more secure, as only someone with the private SSH key can access the server.
Now in the "Choose a hostname" section change the default for something more meaningful, like **consulserver** for example.
![Digital Ocean hostname](../../../.gitbook/assets/hostname%20%281%29.png)
At the bottom of the page youll see a summary of your options. Check that everything is OK and click the big green "Create" button.
![Digital Ocean create](../../../.gitbook/assets/create%20%281%29.png)
It will take a few minutes, and at the end you will have a shiny new server. It will look like this in the Digital Ocean page:
![Digital Ocean server](../../../.gitbook/assets/server%20%281%29.png)
Next to setup CONSUL in the server check the [installer's README](https://github.com/consul/installer)

View File

@@ -0,0 +1,152 @@
# Docker
You can use Docker to have a local CONSUL installation for development if:
* You're having troubles having [prerequisites](../local_installation/prerequisites.md) installed.
* You want to do a quick local installation just to try CONSUL or make a demo.
* You prefer not to interfer with other rails installations.
## Prerequisites
You should have installed Docker and Docker Compose in your machine:
### macOS
You can follow the [official docker install](https://docs.docker.com/docker-for-mac/install/)
Or if you have [homebrew](http://brew.sh) and [cask](https://caskroom.github.io/) installed you can just:
```bash
brew install docker
brew install docker-compose
brew cask install docker
open -a docker
```
You'll be asked to give Docker app permissions and type your password, then you're set.
### Linux
1. Install Docker:
```bash
sudo apt-get update
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
sudo apt-add-repository 'deb https://apt.dockerproject.org/repo ubuntu-xenial main'
sudo apt-get update
apt-cache policy docker-engine
sudo apt-get install -y docker-engine
```
2. Install Docker Compose
```bash
sudo curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/1.15.0/docker-compose-$(uname -s)-$(uname -m)"
sudo chmod +x /usr/local/bin/docker-compose
```
### Windows
Pending to be completed... Contributions Welcome!
## Installation
Clone the repo on your computer and enter the folder:
```bash
git clone git@github.com:consul/consul.git
cd consul
```
### macOS & Linux
Then lets create our secrets and database config files based on examples:
```bash
cp config/secrets.yml.example config/secrets.yml
cp config/database-docker.yml.example config/database.yml
```
Then you'll have to build the container with:
```bash
docker build -t consul .
```
Create your app database images:
```bash
docker-compose up -d database
```
Once built you can initialize your development DB and populate it with:
```text
docker-compose run app rake db:create
docker-compose run app rake db:migrate
docker-compose run app rake db:seed
docker-compose run app rake db:dev_seed
```
### Windows
Pending to be completed... Contributions Welcome!
## Running local CONSUL with Docker
### macOS & Linux
Now we can finally run the application with:
```bash
docker-compose up
```
And you'll be able to access it at your browser visiting [http://localhost:3000](http://localhost:3000)
Additionally, if you want to run the rails console just run in another terminal:
```bash
docker-compose run app rails console
```
To verify the containers are up execute:
```bash
docker ps .
```
You should see output similar to this: ![docker ps](https://i.imgur.com/ASvzXrd.png)
### Windows
Pending to be completed... Contributions Welcome!
## Having trouble?
Run these commands at **Consul's directory**, to erase all your previous Consul's Docker images and containers. Then restart the Docker [installation process](docker.md#installation):
1. Remove all CONSUL images:
```bash
docker-compose down --rmi all -v --remove-orphans
```
2. Remove all CONSUL containers
```bash
docker-compose rm -f -s -v
```
3. Verify if there is some container yet:
```bash
docker ps -a
```
Case positive, remove each one manually:
```bash
docker container rm <container_id>
```

View File

@@ -0,0 +1,19 @@
# Generating SSH Key
These instructions will help you generate a public key with which you can connect to the server without using a password.
In the terminal window, type:
```text
ssh-keygen
```
When prompted for the file in which to save the key just press ENTER to leave the default. When prompted for a passphrase, just press ENTER again to leave this empty. At the end you should see a message like this:
```text
Your identification has been saved in /your_home/.ssh/id_rsa.
Your public key has been saved in /your_home/.ssh/id_rsa.pub.
```
Take note of the **id\_rsa.pub** file location, because youll need the content of this file later.

View File

@@ -0,0 +1,6 @@
# Installer
## Installation notes for Production and Staging servers
Check out the [installer's README](https://github.com/consul/installer)

View File

@@ -0,0 +1,5 @@
# Open Source project
* [Code of conduct](code_of_conduct.md)
* [Contributing](contributing.md)

View File

@@ -0,0 +1,44 @@
# Code of conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language.
* Being respectful of differing viewpoints and experiences.
* Gracefully accepting constructive criticism.
* Focusing on what is best for the community.
* Showing empathy towards other community members.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances.
* Trolling, insulting/derogatory comments, and personal or political attacks.
* Public or private harassment.
* Publishing others' private information, such as a physical or electronic address, without explicit permission.
* Other conduct which could reasonably be considered inappropriate in a professional setting.
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [consul@madrid.es](mailto:consul@madrid.es). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.4, available at [http://contributor-covenant.org/version/1/4](http://contributor-covenant.org/version/1/4/).

View File

@@ -0,0 +1,40 @@
# Contributing
We appreciate you want to help us by contributing to Consul. Here's a guide we made describing how to contribute changes to the project.
## Reporting an issue
If you have seen anything wrong in the platform performance or directly in the code, we encourage you to [open an issue in the Consul Github repository](https://github.com/consul/consul/issues/new).
Before doing it, **please take some time to check the** [**existing issues**](https://github.com/consul/consul/issues) **and make sure what you are about to report isn't already reported** by another person. In case someone else reported the same problem before, if you have more details about it you can write a comment in the issue page -a little more help can make a huge difference!
In order to write a new issue, take into account these few tips to make it easy to read and comprehend:
* Try to use a descriptive and to-the-point title.
* It's a good idea to include some sections -in case they're needed- such as: steps to reproduce the bug, expected behaviour/response, actual response or screenshots.
* Also it could be helpful to provide your operating system, browser version and installed plugins.
## Resolving an issue
[Issues in Consul](https://github.com/consul/consul/issues) labeled with `PRs-welcome` are well defined features ready to be implemented by whoever wants to do it. In the other hand, the `not-ready` label marks features or changes not well defined yet or subject to an internal decision, so we recommend not to try to resolve them until the admins come to a resolution.
We suggest to follow these steps to keep a good track of the changes you're about to make:
* First of all, add a comment to the issue to make everyone know you are going to work on it. If the issue has someone assigned it means that person is already solving it.
* Fork the project.
* Create a feature branch based on the `master` branch. To make it easier to identify, you can name it with the issue number followed by a concise and descriptive name \(e.g. `123-fix_proposals_link`\).
* Work in your branch committing there your changes.
* Make sure all tests are passing. In case you're extending or creating a new feature, consider adding its own specs.
* Once you've finished, send a **pull request** to the [Consul repository](https://github.com/consul/consul/) describing your solution to help us understand it. It's also important to tell what issue you're addressing, so specify it in the pull request description's first line \(e.g. `Fixes #123`\).
* Our core team will review your PR and suggest changes if necessary. If everything looks good, your changes will be merged :\)
> **Working on your first Pull Request?** You can learn how from this _free_ series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github).
## Other ways of contributing
We'll appreciate any kind of contribution to Consul. Even if you can't contribute to it coding, you still can:
* Create issues about any problem or error you've encountered.
* Help translate the platform to other languages you master at [Consul's Crowdin](https://crwd.in/consul).
* Help with [Consul's documentation](https://github.com/consul/docs).

View File

@@ -0,0 +1,249 @@
# License
```text
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (c) 2015 Ayuntamiento de Madrid
```
Copyright \(C\) 2007 Free Software Foundation, Inc. [http://fsf.org/](http://fsf.org/) Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
```text
Preamble
```
The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software \(and charge for them if you wish\), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights with two steps: \(1\) assert copyright on the software, and \(2\) offer you this License which gives you legal permission to copy, distribute and/or modify the software.
A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public.
The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version.
An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license.
The precise terms and conditions for copying, distribution and modification follow.
```text
TERMS AND CONDITIONS
```
1. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based on the Program.
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution \(with or without modification\), making available to the public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that \(1\) displays an appropriate copyright notice, and \(2\) tells the user that there is no warranty for the work \(except to the extent that warranties are provided\), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
2. Source Code.
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work.
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other than the work as a whole, that \(a\) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and \(b\) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component \(kernel, window system, and so on\) of the specific operating system \(if any\) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and \(for an executable work\) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
The Corresponding Source for a work in source code form is that same work.
3. Basic Permissions.
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
4. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
5. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
6. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
a\) The work must carry prominent notices stating that you modified it, and giving a relevant date.
b\) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices".
c\) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
d\) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
7. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
a\) Convey the object code in, or embodied in, a physical product \(including a physical distribution medium\), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
b\) Convey the object code in, or embodied in, a physical product \(including a physical distribution medium\), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either \(1\) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or \(2\) access to copy the Corresponding Source from a network server at no charge.
c\) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
d\) Convey the object code by offering access from a designated place \(gratis or for a charge\), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server \(operated by you or a third party\) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
e\) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
A "User Product" is either \(1\) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or \(2\) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term \(regardless of how the transaction is characterized\), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product \(for example, the work has been installed in ROM\).
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented \(and with an implementation available to the public in source code form\), and must require no special password or key for unpacking, reading or copying.
8. Additional Terms.
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. \(Additional permissions may be written to require their own removal in certain cases when you modify the work.\) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you add to a covered work, you may \(if authorized by the copyright holders of that material\) supplement the terms of this License with terms:
a\) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
b\) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
c\) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
d\) Limiting the use for publicity purposes of names of licensors or authors of the material; or
e\) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
f\) Requiring indemnification of licensors and authors of that material by anyone who conveys the material \(or modified versions of it\) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
9. Termination.
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License \(including any patent licenses granted under the third paragraph of section 11\).
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated \(a\) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and \(b\) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License \(for any work\) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
10. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
11. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation \(including a cross-claim or counterclaim in a lawsuit\) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
12. Patents.
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent \(such as an express permission to practice a patent or covenant not to sue for patent infringement\). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either \(1\) cause the Corresponding Source to be so available, or \(2\) arrange to deprive yourself of the benefit of the patent license for this particular work, or \(3\) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license \(a\) in connection with copies of the covered work conveyed by you \(or copies made from those copies\), or \(b\) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
13. No Surrender of Others' Freedom.
If conditions are imposed on you \(whether by court order, agreement or otherwise\) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
14. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network \(if your version supports such interaction\) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph.
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License.
15. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation.
If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
16. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
17. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM \(INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS\), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
18. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
```text
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
```
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found.
&lt;one line to give the program's name and a brief idea of what it does.&gt; Copyright \(C\)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or \(at your option\) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements.
You should also get your employer \(if you work as a programmer\) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see [http://www.gnu.org/licenses/](http://www.gnu.org/licenses/).