Skip to content

1. Install guide and requirements

J. Pablo Pérez Trabucco edited this page Mar 13, 2015 · 1 revision

Dependencies

Make sure you're using ruby 2.0 or above (we highly recommend using rvm), and that bundler is installed.

Legislative uses the following Poplus components: Pop-it, Write-it and Bill-it. You should create an instance of the services, or have your own installation in order for all features to be available.

System requirements

The following system requirements are also needed, for image manipulation:

Red Hat / Fedora / CentOS

sudo yum install sqlite-devel community-mysql-devel ImageMagick-devel

Debian / Ubuntu (for 13.04 and Wheezy also install libmagickwand-dev)

sudo apt-get install imagemagick libmagickwand-dev

Ubuntu (14.04) need install sqlite3 and sqlite3-dev

sudo apt-get install sqlite3 sqlite3-dev

OS X

brew update
brew install ImageMagick
gem install rmagick

Quick start

Clone the git repo - git clone https://github.com/ciudadanointeligente/legislative.git - or download it

Go to your legislative folder and run install

sh setup.sh

Install the required ruby gems

bundle install

Create the config files

cp config/database.yml.example config/database.yml

Then run your server

rails s

Check at http://localhost:3000

You can try loggin in with [email protected] / benito

Bill-it

Legislative need you have an instances of Bill-it for store all yours bills, for more information visits Github Bill-it page

Pop-it

Legislative need you have an instance of Popit for store your congressmen personal data, for more information please visits Github Project Page or Popit website

Enable / Disable Display Agenda

in Chile, an Agenda is the roadmap of a congressman when works out of the congress, then, the agenda is a recopilation of what are they doing in is own District that represent. for default the config of display this section is disabled and if you wanna enable this one, only need add the following line on your private_legislative.yml with the url pointing to an API, like Morph.io, to consume this information if you dont use Morph.io just forget the line 'morph_io_api_key'

morph_io_api_key: ~
agendas_url: ~
agendas_enabled: ~

the API response need an Array of bills, here is an example

Picture profile of a congressman

if you need adjust the crop size of the thumbnails, only need setup a few values on private_legislative.yml adding the following values

congressman_pic_x: '15'
congressman_pic_y: '15'
congressman_pic_w: '160'
congressman_pic_h: '150'

for default the values are: 15,15,160,150 wich represents x, y, width and heigth

Deploying to production

This section will not be relevant to most people. It will however be relevant if you're deploying to a production server.

Production environment

Create the follow config files, and edit them with your project's specific values.

cp config/newrelic.yml.example config/newrelic.yml
cp config/schedule.rb.example config/schedule.rb
cp config/private_legislative.yml.example config/private_legislative.yml

The private_legislative.yml is the file that holds all your private config values. While legislative.yml gets synced to your github repo, private_legislativeyml does not.

Deploy

We recommend the follow commands in the job for automatic deploy and the use of phusion passenger as web server and application server with apache or nginx in production.

bundle install
rake db:migrate
rake tmp:cache:clear
rake assets:clean
rake assets:precompile

Tasks using cron

To run tasks like send notifications emails of changes in bills the project use whenever, this tool generate cron jobs from the config/schedule.rb file.

Add the jobs to crontab:

bundle exec whenever --update-crontab legislative

Clear the jobs associated with a app name:

bundle exec whenever --clear-crontab legislative

MariaDB

For improve the performance in production is a good idea change the db engine from sqlite3 to mariaDB or postgreSQL. To use mariaDB you need edit config/database.yml config file.

Red Hat / Fedora / CentOS

yum install mariadb-server mariadb-devel

Debian / Ubuntu

apt-get install mariadb-server libmariadbd-dev

OS X

brew install mariadb

Features

  • Security Authentication system
  • Remember me
  • Users CRUD

Databases support

  • SQLite (Default)
  • MySQL / MariaDB

Best practices


Change the cookie secret token at config/initializers/secret_token.rb

# Be sure to restart your server when you modify this file.

# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
Legislative::Application.config.secret_token = 'YOUR-NEW-TOKEN-HERE'

To run the RSpec tests

rspec