Remove documentation already at consul/docs and reference to it on README files

This commit is contained in:
Bertocq
2017-09-13 14:43:36 +02:00
parent e573ab72f7
commit 392d633d24
10 changed files with 6 additions and 1150 deletions

View File

@@ -1,221 +0,0 @@
# Customization
You can modify your own CONSUL to have your custom visual style, but first you'll have to create a fork from [https://github.com/consul/consul](https://github.com/consul/consul) using Github's "fork" button on top right corner. You can use any other service like Gitlab, but don't forget to put a reference link back to CONSUL on the footer to comply with project's license (GPL Affero 3).
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`
### Internationalization
If you want to add a new language translation 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.
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 text 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`), we can see code is:
```ruby
<%= t("layouts.footer.copyright", year: Time.current.year) %>
```
And that the text its located at the file `config/locales/es/general.yml` following this structure (we're only displaying in the following snippet the relevant parts):
```yml
es:
layouts:
footer:
copyright: Ayuntamiento de Madrid, %{year}
```
So in order to customize it, we would create a new file `config/locales/custom/es/general.yml` with just that content, and change "Ayuntamiento de Madrid" for 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.
### 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
### 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
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.
### 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:
```js
$(function(){
alert('foobar');
});
```
### 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
```
### Controllers
TODO!
### Gemfile
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.
### application.rb
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.
### lib/
TODO
### public/
TODO
### Seeds
TODO
## Updating
We recommend you to add CONSUL as remote:
```
git remote add consul https://github.com/consul/consul
```
And then just grab lastest changes on to a branch of your own repo with:
```
git checkout -b consul_update
git pull consul master
```

View File

@@ -1,221 +0,0 @@
# Personalización
Puedes modificar CONSUL y ponerle tu propia imagen, para esto debes primero hacer un fork de [https://github.com/consul/consul](https://github.com/consul/consul) creando un repositorio nuevo en Github. Puedes usar otro servicio como Gitlab, pero no te olvides de poner el enlace en el footer a tu repositorio en cumplimiento con la licencia de este proyecto (GPL Affero 3).
Hemos creado una estructura específica donde puedes sobreescribir y personalizar la aplicación para que puedas actualizar sin que tengas problemas al hacer merge y se sobreescriban por error tus cambios. Intentamos que CONSUL sea una aplicación Ruby on Rails lo más plain vanilla posible para facilitar el acceso de nuevas desarrolladoras.
## Ficheros y directorios especiales
Para adaptar tu fork de CONSUL puedes utilizar alguno de los directorios `custom` que están en las rutas:
* `config/locales/custom/`
* `app/assets/images/custom/`
* `app/views/custom/`
* `app/controllers/custom/`
* `app/models/custom/`
Aparte de estos directorios también cuentas con ciertos ficheros para:
* `app/assets/stylesheets/custom.css`
* `app/assets/stylesheets/_custom_settings.css`
* `app/assets/javascripts/custom.js`
* `Gemfile_custom`
* `config/application.custom.rb`
### Internacionalización
Si quieres modificar algún texto de la web deberías encontrarlos en los ficheros formato YML disponibles en `config/locales/`. Puedes leer la [guía de internacionalización](http://guides.rubyonrails.org/i18n.html) de Ruby on Rails sobre como funciona este sistema.
Las adaptaciones los debes poner en el directorio `config/locales/custom/`, recomendamos poner solo los textos que quieras personalizar. Por ejemplo si quieres personalizar el texto de "Ayuntamiento de Madrid, 2016" que se encuentra en el footer en todas las páginas, primero debemos ubicar en que plantilla se encuentra (`app/views/layouts/_footer.html.erb`), vemos que en el código pone lo siguiente:
```ruby
<%= t("layouts.footer.copyright", year: Time.current.year) %>
```
Y que en el fichero `config/locales/es/general.yml` sigue esta estructura (solo ponemos lo relevante para este caso):
```yml
es:
layouts:
footer:
copyright: Ayuntamiento de Madrid, %{year}
```
Si creamos el fichero `config/locales/custom/es/general.yml` y modificamos "Ayuntamiento de Madrid" por el nombre de la organización que se este haciendo la modificación. Recomendamos directamente copiar los ficheros `config/locales/` e ir revisando y corrigiendo las que querramos, borrando las líneas que no querramos traducir.
### Imágenes
Si quieres sobreescribir alguna imagen debes primero fijarte el nombre que tiene, por defecto se encuentran en `app/assets/images`. Por ejemplo si quieres modificar `app/assets/images/logo_header.png` debes poner otra con ese mismo nombre en el directorio `app/assets/images/custom`. Los iconos que seguramente quieras modificar son:
* 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
### Vistas (HTML)
Si quieres modificar el HTML de alguna página puedes hacerlo copiando el HTML de `app/views` y poniendolo en `app/views/custom` respetando los subdirectorios que encuentres ahí. Por ejemplo si quieres modificar `app/views/pages/conditions.html` debes copiarlo y modificarla en `app/views/custom/pages/conditions.html.erb`
### CSS
Si quieres cambiar algun selector CSS (de las hojas de estilo) puedes hacerlo en el fichero `app/assets/stylesheets/custom.scss`. Por ejemplo si quieres cambiar el color del header (`.top-links`) puedes hacerlo agregando:
```css
.top-links {
background: red;
}
```
Si quieres cambiar alguna variable de [foundation](http://foundation.zurb.com/) puedes hacerlo en el fichero `app/assets/stylesheets/_custom_settings.scss`. Por ejemplo para cambiar el color general de la aplicación puedes hacerlo agregando:
```css
$brand: #446336;
```
Usamos un preprocesador de CSS, [SASS, con la sintaxis SCSS](http://sass-lang.com/guide).
### Javascript
Si quieres agregar código Javascript puedes hacerlo en el fichero `app/assets/javascripts/custom.js`. Por ejemplo si quieres que salga una alerta puedes poner lo siguiente:
```js
$(function(){
alert('foobar');
});
```
### Modelos
Si quieres agregar modelos nuevos, o modificar o agregar métodos a uno ya existente puedes hacerlo en `app/models/custom`. En el caso de los modelos antiguos debes primero hacer un require de la dependencia.
Por ejemplo en el caso del Ayuntamiento de Madrid se requiere comprobar que el código postal durante la verificación sigue un cierto formato (empieza con 280). Esto se realiza creando este fichero en `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
```
No olvides poner los tests relevantes en `spec/models/custom`, siguiendo con el ejemplo pondriamos lo siguiente en `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
```
### Controladores
TODO
### Gemfile
Para agregar librerías (gems) nuevas puedes hacerlo en el fichero `Gemfile_custom`. Por ejemplo si quieres agregar la gema [rails-footnotes](https://github.com/josevalim/rails-footnotes) debes hacerlo agregandole
```ruby
gem 'rails-footnotes', '~> 4.0'
```
Y siguiendo el flujo clásico en Ruby on Rails (`bundle install` y seguir con los pasos específicos de la gema en la documentación)
### application.rb
Cuando necesites extender o modificar el `config/application.rb` puedes hacerlo a través del fichero `config/application_custom.rb`. Por ejemplo si quieres modificar el idioma por defecto al inglés pondrías lo siguiente:
```ruby
module Consul
class Application < Rails::Application
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :es]
end
end
```
Recuerda que para ver reflejado estos cambios debes reiniciar el servidor de desarrollo.
### lib/
TODO
### public/
TODO
### Seeds
TODO
## Actualizar
Te recomendamos que agregues el remote de CONSUL para facilitar este proceso de merge:
```
git remote add consul https://github.com/consul/consul
```
Con esto puedes actualizarte con
```
git checkout -b consul_update
git pull consul master
```

View File

@@ -23,79 +23,9 @@ This is the opensource code repository of the eParticipation website CONSUL, ori
Development started on [2015 July 15th](https://github.com/consul/consul/commit/8db36308379accd44b5de4f680a54c41a0cc6fc6). Code was deployed to production on 2015 september 7th to [decide.madrid.es](https://decide.madrid.es). Since then new features are added often. You can take a look at the current features in [features]( http://www.decide.es/en/) or [docs](https://github.com/consul/consul/tree/master/doc) and future features in the [open issues list](https://github.com/consul/consul/issues). For current status on upcoming features go to [Roadmap](https://github.com/consul/consul/projects/6) Development started on [2015 July 15th](https://github.com/consul/consul/commit/8db36308379accd44b5de4f680a54c41a0cc6fc6). Code was deployed to production on 2015 september 7th to [decide.madrid.es](https://decide.madrid.es). Since then new features are added often. You can take a look at the current features in [features]( http://www.decide.es/en/) or [docs](https://github.com/consul/consul/tree/master/doc) and future features in the [open issues list](https://github.com/consul/consul/issues). For current status on upcoming features go to [Roadmap](https://github.com/consul/consul/projects/6)
## Tech stack ## Documentation
The application backend is written in the [Ruby language](https://www.ruby-lang.org/) using the [Ruby on Rails](http://rubyonrails.org/) framework. Please check the ongoing documentation at https://consul_docs.gitbooks.io/docs/content/ to learn more about how to start your own CONSUL fork, install it, customize it and learn to use it from an administrator/maintainer perspective. You can contribute to it at https://github.com/consul/docs
Frontend tools used include [SCSS](http://sass-lang.com/) over [Foundation](http://foundation.zurb.com/) for the styles.
## Configuration for development and test environments
**NOTE**: For more detailed instructions check the [docs](https://github.com/consul/consul/tree/master/doc/en/dev_test_setup.md)
Prerequisites: install git, Ruby 2.3.2, bundler gem, and PostgreSQL (>=9.4).
```
git clone https://github.com/consul/consul.git
cd consul
bundle install
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml
bin/rake db:setup
bin/rake db:dev_seed
RAILS_ENV=test rake db:setup
```
Run the app locally:
```
bin/rails s
```
Prerequisites for testing: install PhantomJS >= 2.1.1
Run the tests with:
```
bin/rspec
```
If you add SCSS code you can check it with:
```
scss-lint
```
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)
If you work on Coffeescript code you can check it with [coffeelint](http://www.coffeelint.org/) (install with `npm install -g coffeelint`) :
```
coffeelint .
```
You can use the default admin user from the seeds file:
**user:** admin@consul.dev
**pass:** 12345678
But for some actions like voting, you will need a verified user, the seeds file also includes one:
**user:** verified@consul.dev
**pass:** 12345678
### Customization
Read more on documentation:
* English: [CUSTOMIZE_EN.md](CUSTOMIZE_EN.md)
* Spanish: [CUSTOMIZE_ES.md](CUSTOMIZE_ES.md)
### OAuth
To test authentication services with external OAuth suppliers - right now Twitter, Facebook and Google - you'll need to create an "application" in each of the supported platforms and set the *key* and *secret* provided in your *secrets.yml*
In the case of Google, verify that the APIs *Contacts API* and *Google+ API* are enabled for the application.
## License ## License

View File

@@ -23,76 +23,9 @@ Este es el repositorio de código abierto de la Aplicación de Participación Ci
El desarrollo de esta aplicación comenzó el [15 de Julio de 2015](https://github.com/consul/consul/commit/8db36308379accd44b5de4f680a54c41a0cc6fc6) y el código fue puesto en producción el día 7 de Septiembre de 2015 en [decide.madrid.es](https://decide.madrid.es). Desde entonces se le añaden mejoras y funcionalidades constantemente. Las funcionalidades actuales se pueden consultar en [características](http://www.decide.es/es/) o en la [documentación](https://github.com/consul/consul/tree/master/doc) y las siguientes funcionaliades en la lista de [tareas por hacer](https://github.com/consul/consul/issues). Para conocer el estado actual de las próximas caracteristicas, vaya a [Roadmap](https://github.com/consul/consul/projects/6) El desarrollo de esta aplicación comenzó el [15 de Julio de 2015](https://github.com/consul/consul/commit/8db36308379accd44b5de4f680a54c41a0cc6fc6) y el código fue puesto en producción el día 7 de Septiembre de 2015 en [decide.madrid.es](https://decide.madrid.es). Desde entonces se le añaden mejoras y funcionalidades constantemente. Las funcionalidades actuales se pueden consultar en [características](http://www.decide.es/es/) o en la [documentación](https://github.com/consul/consul/tree/master/doc) y las siguientes funcionaliades en la lista de [tareas por hacer](https://github.com/consul/consul/issues). Para conocer el estado actual de las próximas caracteristicas, vaya a [Roadmap](https://github.com/consul/consul/projects/6)
## Tecnología ## Documentación
El backend de esta aplicación se desarrolla con el lenguaje de programación [Ruby](https://www.ruby-lang.org/) sobre el *framework* [Ruby on Rails](http://rubyonrails.org/). Por favor visita la documentación que está siendo completada en https://consul_docs.gitbooks.io/docs/content/ para conocer más sobre este proyecto, como comenzar tu propio fork, instalarlo, customizarlo y usarlo como administrador/mantenedor. Puedes colaborar en ella en https://github.com/consul/docs
Las herramientas utilizadas para el frontend no están cerradas aún. Los estilos de la página usan [SCSS](http://sass-lang.com/) sobre [Foundation](http://foundation.zurb.com/)
## Configuración para desarrollo y tests
**NOTA**: para unas instrucciones más detalladas consulta la [documentación](https://github.com/consul/consul/tree/master/doc/es/dev_test_setup.md)
Prerequisitos: tener instalado git, Ruby 2.3.2, la gema `bundler` y PostgreSQL (9.4 o superior).
```
git clone https://github.com/consul/consul.git
cd consul
bundle install
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml
bin/rake db:setup
bin/rake db:dev_seed
RAILS_ENV=test rake db:setup
```
Para ejecutar la aplicación en local:
```
bin/rails s
```
Prerequisitos para los tests: tener instalado PhantomJS >= 2.1.1
Para ejecutar los tests:
```
bin/rspec
```
Si añades código SCSS puedes revisarlo con:
```
scss-lint
```
Para mantener el nivel de accesibilidad, si añades colores nuevos utiliza un [Comprobador de contraste de color](http://webaim.org/resources/contrastchecker/) (WCAG AA es obligatorio, WCAG AAA es recomendable)
Si trabajas en código coffeescript puedes revisarlo con [coffeelint](http://www.coffeelint.org/) (instalalo con `npm install -g coffeelint`) :
```
coffeelint .
```
Puedes usar el usuario administrador por defecto del fichero seeds:
**user:** admin@consul.dev
**pass:** 12345678
Pero para ciertas acciones, como apoyar, necesitarás un usuario verificado, el fichero seeds proporciona uno:
**user:** verified@consul.dev
**pass:** 12345678
### Customización
Ver fichero [CUSTOMIZE_ES.md](CUSTOMIZE_ES.md)
### OAuth
Para probar los servicios de autenticación mediante proveedores externos OAuth — en este momento Twitter, Facebook y Google —, necesitas crear una "aplicación" en cada una de las plataformas soportadas y configurar la *key* y el *secret* proporcionados en tu *secrets.yml*
En el caso de Google, comprueba que las APIs *Contacts API* y *Google+ API* están habilitadas para la aplicación.
## Licencia ## Licencia

View File

@@ -1,11 +0,0 @@
# Configuration for development and test environments (Mac OS X)
## Linux
See [here](dev_test_setup_linux.md)
## Mac OS X
See [here](dev_test_setup_osx.md)
## Windows

View File

@@ -1,146 +0,0 @@
# Configuration for development and test environments (GNU/Linux)
## Git
Git is officially maintained in Debian/Ubuntu:
```
sudo apt-get install git
```
## Ruby
Ruby versions packaged in official repositories are not suitable to work with consul (at least Debian 7 and 8), so we'll have to install it manually.
The preferred method is via rvm:
(only the multi user option installs all dependencies automatically, as we use 'sudo'.)
### As local user
```
curl -L https://get.rvm.io | bash -s stable
```
### For all system users
```
curl -L https://get.rvm.io | sudo bash -s stable
```
and then add your user to rvm group
```
sudo usermod -a -G rvm <user>
```
and finally, add rvm script source to user's bash (~/.bashrc) (this step it's only necessary if you still can't execute rvm command)
```
[[ -s /usr/local/rvm/scripts/rvm ]] && source /usr/local/rvm/scripts/rvm
```
with all this, you are suppose to be able to install a ruby version from rvm, as for example version 2.3.0:
```
sudo rvm install 2.3.0
```
## Bundler
with
```
gem install bundler
```
or there is more methods [here](https://rvm.io/integration/bundler) that should be better as:
```
gem install rubygems-bundler
```
## PostgreSQL (>=9.4)
PostgreSQL version 9.4 is not official in debian 7 (wheezy), in 8 it seems to be officially maintained.
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:
```
deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main
```
afterwards you'll have to download the key, and install it, by:
```
wget https://www.postgresql.org/media/keys/ACCC4CF8.asc
apt-key add ACCC4CF8.asc
```
and install postgresql
```
apt-get update
apt-get install postgresql-9.4
```
Besides, you will also need the dev libraries and headers so that pg gem can be compiled when running `bundle install`. Also, you will need the postgresql postGIS scripts. You can install them by running a single command:
```
apt-get install postgresql-server-dev-9.4 postgresql-9.4-postgis-scripts
```
## Cloning the repository
Now, with all the dependencies installed, clone the CONSUL repository:
```
git clone https://github.com/consul/consul.git
cd consul
bundle install
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml
```
Perhaps it's needed to create a superuser rol with password in postgresql, and write it in */config/database.yml* 'user:' and 'password:' fields.
Also, it seems that postgresql use as default an unix socket for localhost communications. If we encounter problems creating database (connection problems) we can change in */config/database.yml* the line:
```
host: localhost
```
for:
```
host: /var/run/postgresql
```
After this:
```
rake db:create
rake db:setup
rake db:dev_seed
RAILS_ENV=test bin/rake db:setup
```
If you get the following error message when running `rake db:create`:
```
PG::InvalidParameterValue: ERROR: new encoding (UTF8) is incompatible with the encoding of the template database (SQL_ASCII)
HINT: Use the same encoding as in the template database, or use template0 as template.
```
you probably have template1 using `SQL_ASCII` encoding instead of `UTF8`, to correct this run the following sequence of commands within the postgresql client to recreate the template1 with `UTF8` encoding:
```
UPDATE pg_database SET datistemplate = FALSE WHERE datname = 'template1';
DROP DATABASE template1;
CREATE DATABASE template1 WITH TEMPLATE = template0 ENCODING = 'UNICODE';
UPDATE pg_database SET datistemplate = TRUE WHERE datname = 'template1';
\c template1
VACUUM FREEZE;
```

View File

@@ -1,128 +0,0 @@
# Configuration for development and test environments (Mac OS X)
## 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
You can download git from: [git-scm.com/download/mac](https://git-scm.com/download/mac)
## Ruby y rbenv
OS X already comes with a preinstalled Ruby version, but it's quite old and we need a newer one (2.3.2). 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)
## Bundler
```
gem install bundler
```
## PostgreSQL (>=9.4)
```
brew install postgres
```
Once installed, we need to *initialize* it:
```
initdb /usr/local/var/postgres
```
Now we're going to configure some things related to the *default user*. First we start postgres server with:
```
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:
```
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:
```
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:
```
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:
```
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)):
```
rm -rf /usr/local/var/postgres
```
## Postgis
```
brew install postgis
```
## PhantomJS
```
brew install phantomjs
```
## Imagemagick
```
brew install imagemagick
```
## Cloning the repository
Now that we have all the dependencies installed we can download the repository:
```
git clone https://github.com/consul/consul.git
cd consul
bundle install
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml
```
Now copy in `database.yml` the database user and password you used for *consul*.
After this:
```
rake db:create
rake db:setup
rake db:dev_seed
RAILS_ENV=test bin/rake db:setup
```
To run the tests:
```
bundle exec rspec
```

View File

@@ -1,11 +0,0 @@
# Configuración para los entornos de desarrollo y pruebas
## Linux
Consultar [aqui](dev_test_setup_linux.md)
## Mac OS X
Consultar [aquí](dev_test_setup_osx.md)
## Windows

View File

@@ -1,141 +0,0 @@
# Configuración para los entornos de desarrollo y pruebas (GNU/Linux)
## Git
Git es mantenido oficialmente en Debian/Ubuntu:
```
sudo apt-get install git
```
## Ruby
Las versiones de Ruby versions empaquetadas en repositorios oficiales no son aptas para trabajar con consul (al menos Debian 7 y 8), así que debemos instalar manualmente.
El método recomendado es via rvm:
(sólo la opción multiusuario instala todas las dependencias automáticamente, al usar 'sudo'.)
### Como usuario local
```
curl -L https://get.rvm.io | bash -s stable
```
### Para todos los usuarios del sistema
```
curl -L https://get.rvm.io | sudo bash -s stable
```
añadismos nuestro usuario al grupo de rvm
```
sudo usermod -a -G rvm <user>
```
y finalmente, añadimos el script rvm a nuestro bash (~/.bashrc) (este paso sólo es necesario si no puedes ejecutar el comando rvm)
```
[[ -s /usr/local/rvm/scripts/rvm ]] && source /usr/local/rvm/scripts/rvm
```
con todo esto, deberías poder instalar la versión de ruby con rvm, por ejemplo la 2.3.2:
```
sudo rvm install 2.3.2
```
## Bundler
usando
```
gem install bundler
```
hay varios métodos alternativos [aquí](https://rvm.io/integration/bundler) que podrían ser mejores como:
```
gem install rubygems-bundler
```
## PostgreSQL (>=9.4)
La versión 9.4 de PostgreSQL no es oficial en Debian 7 (wheezy), pero en Debian 8 parece ser mantenida oficialmente.
Así que debemos añadir el respositorio oficial de postgresql a apt, por ejemplo creando el fichero */etc/apt/sources.list.d/pgdg.list* con:
```
deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main
```
después deberás descargar la key e instalarla:
```
wget https://www.postgresql.org/media/keys/ACCC4CF8.asc
apt-key add ACCC4CF8.asc
```
y finalmente instalar postgresql
```
apt-get update
apt-get install postgresql-9.4
```
## Clonar el repositorio
Ahora que ya tenemos todas las dependencias instalado podemos bajarnos el proyecto:
```
git clone https://github.com/consul/consul.git
cd consul
bundle install
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml
```
Ahora copia en `database.yml` el usuario y la contraseña que pusiste para *consul*. Cuando ya lo hayas hecho:
```
rake db:create
rake db:setup
rake db:dev_seed
RAILS_ENV=test bin/rake db:setup
```
Para ejecutar los tests:
```
bundle exec rspec
```
Quizás necesites crear un rol de superusuario en postgresql, y completar en el fichero*/config/database.yml* los campos 'user:' y 'password:'.
Además, parece que postgresql usa un socket unix por defecto para las comunicaciones en local. Si te encuentras este problema creando la base de datos, cambia en */config/database.yml* la linea:
```
host: localhost
```
por:
```
host: /var/run/postgresql
```
Tras esto en el terminal ejecutaremos:
```
rake db:create
rake db:setup
rake db:dev_seed
RAILS_ENV=test bin/rake db:setup
```
Y por último para comprobar que todo esta bien, lanza los tests:
```
bundle exec rspec
```

View File

@@ -1,128 +0,0 @@
# Configuración para los entornos de desarrollo y pruebas (Mac OS X)
## Homebrew
Homebrew es un gestor de paquetes para OS X muy popular. Es recomendable usarlo pues facilita enormemente la instalación de algunos de los paquetes necesarios.
Puedes encontrar las instrucciones de instalación en: [brew.sh](http://brew.sh)
## XCode y XCode Command Line Tools
Para utilizar git necesitarás instalar *Xcode* (está en la Mac App Store) y las *Xcode Command Line Tools* (se instalan desde el menú de Xcode).
## Git y Github
Puedes descargar git desde: [git-scm.com/download/mac](https://git-scm.com/download/mac)
## Ruby y rbenv
OS X ya viene con una versión preinstalada de ruby, pero es bastante vieja y en nuestro caso no nos sirve. Una de las formas de instalar Ruby es a través de rbenv. Las instrucciones de instalación están en su GitHub y son bastante claras:
[github.com/rbenv/rbenv](https://github.com/rbenv/rbenv)
Después instala la versión de Ruby 2.3.2
## Bundler
```
gem install bundler
```
## PostgreSQL (>=9.4)
```
brew install postgres
```
Una vez instalado es necesario *inicializar* la instalación:
```
initdb /usr/local/var/postgres
```
Ahora vamos a configurar algunos aspectos del usuario por defecto. Primero iniciamos el servidor de postgres con:
```
postgres -D /usr/local/var/postgres
```
Llegados a este punto se supone que tenemos postgres correctamente instalado y se nos habrá creado un usuario por defecto (cuyo nombre es nuestro nombre de usuario), y que (todavía) no tiene contraseña.
Si ejecutamos `psql` accederemos a la consola de postgres con el usuario por defecto. Probablemente fallará porque es necesario que de antemano exista una base de datos por defecto para dicho usuario. Podemos crearla ejecutando sobre la terminal:
```
createdb 'tu_nombre_de_usuario'
```
Si ahora ejecutamos `psql` de nuevo deberíamos poder acceder correctamente a la consola de postgres. Si sobre la consola de postgres ejecutas `\du` puede ver la lista de usuarios actual.
En el caso de que quieras asignarte una contraseña puedes hacerlo desde la consola de postgres con:
```
ALTER USER tu_nombre_usuario WITH PASSWORD 'tu_contraseña';
```
Ahora vamos a crear el usuario *consul*, que es el que utiliza la aplicación. Ejecuta sobre la consola de postgres:
```
CREATE ROLE consul WITH PASSWORD '000';
ALTER ROLE consul WITH SUPERUSER;
ALTER ROLE consul WITH login;
```
Si en algún momento durante la instalación de PostgreSQL y postgis sospechas que te has equivocado y deseas desinstalarlo y volver a empezar desde cero:
```
brew uninstall postgres
```
También tendrás que borrar el siguiente directorio para que no de conflictos cuando intentes volver a instalarlo (fuente: [gist.github.com/lxneng/741932](https://gist.github.com/lxneng/741932)):
```
rm -rf /usr/local/var/postgres
```
## Postgis
```
brew install postgis
```
## PhantomJS
```
brew install phantomjs
```
## Imagemagick
```
brew install imagemagick
```
## Clonar el repositorio
Ahora que ya tenemos todas las dependencias instalado podemos bajarnos el proyecto:
```
git clone https://github.com/consul/consul.git
cd consul
bundle install
cp config/database.yml.example config/database.yml
cp config/secrets.yml.example config/secrets.yml
```
Ahora copia en `database.yml` el usuario y la contraseña que pusiste para *consul*. Cuando ya lo hayas hecho:
```
rake db:create
rake db:setup
rake db:dev_seed
RAILS_ENV=test bin/rake db:setup
```
Para ejecutar los tests:
```
bundle exec rspec
```