This is the code of LaPrimaire's individual candidate page as well as the citizens and candidates admin page. It uses the Sinatra lightweight framework and rely on a PostgreSQL database. Pages are served through the unicorn web server.
To install LaPrimaire's pages on your local computer, first clone the repo locally and install the dependencies:
$ git clone git://github.com/democratech/pages.git
$ cd pages
$ bundle installIf you don't have the bundle command, make sure you have the latest version of ruby (brew update && brew install ruby) and then install the bundle command with gem install bundler.
Then, you need to setup your PostgreSQL database. You will need PostgreSQL 9.4 or above. If you are using Ubuntu 14.04 as your dev environment, postgresql-9.4 is not included by default so you should use postgresql apt repository to install it easily.
Once PostgreSQL is up and running, go ahead and create a new database role called 'laprimaire' and a new database called 'laprimaire_sandbox' :
$ sudo -s
# su postgres
$ psql
postgres=# CREATE USER laprimaire WITH PASSWORD 'yourpassword';
postgres=# CREATE DATABASE laprimaire_sandbox;
postgres=# GRANT ALL PRIVILEGES ON DATABASE laprimaire_sandbox TO laprimaire;Verify you are able to connect to your newly created database :
$ psql -h localhost -W -U laprimaire laprimaire_sandbox
Password for user laprimaire:
psql (9.5.3, server 9.5.1)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
laprimaire_sandbox=>Now you are ready to import the sample data that you will find in the democratech/tools repository :
$ tar xvfz laprimaire_sandbox.sql.tgz
$ psql -h localhost -W -U laprimaire laprimaire_sandbox < laprimaire_sandbox.sqlCheck that the data has been correctly imported :
$ psql -h localhost -W -U laprimaire laprimaire_sandbox
Password for user laprimaire:
psql (9.5.3, server 9.5.1)
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
laprimaire_sandbox=> \d
List of relations
Schema | Name | Type | Owner
--------+---------------------------+----------+------------
public | candidates | table | laprimaire
public | candidates_views | table | laprimaire
public | cities | table | laprimaire
public | cities_city_id_seq | sequence | laprimaire
public | citizens | table | laprimaire
public | countries | table | laprimaire
public | donateurs | table | laprimaire
public | donateurs_donateur_id_seq | sequence | laprimaire
public | supporters | table | laprimaire
public | toutes_candidates | table | laprimaire
public | users | table | laprimaire
(11 rows)
laprimaire_sandbox=>With the database setup, you can copy the example configuration file and adapt it to your local settings :
$ cp config/key.rb config/keys.local.rb
$ cat config/keys.local.rb
PGHOST="127.0.0.1"
PGPORT="5432"
PGPWD="yourpassword"
PGNAME="laprimaire_sandbox"
PGUSER="laprimaire"
AWS_S3_BUCKET_URL="https://s3.eu-central-1.amazonaws.com/laprimaire/"
ABANDONS=[] # You can leave this variable as isYou are now ready to launch the app and test that everything works fine :
$ bundle exec unicorn -c config/unicorn.conf.rbPoint your web browser to http://localhost:9293/candidat/205289674457 and you should see a candidate page.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
So far, pages is being developed and maintained by
- Thibauld Favre
- Feel free to contribute by checking the issues opened... we're waiting for you :)
Love our work and community? Help us keep it alive by donating funds to cover project expenses!
[Become a backer]
- democratech website is released under the Apache 2 license
- sinatra is released under an Open Source license.
- bootstrap is released under the MIT license.
