OpenGovernment is a Ruby on Rails application for aggregating and presenting open government data.
This project powers OpenGovernment.org and was started by the Participatory Politics Foundation.
We hope you'll get involved! Read our Contributors' Guide for details.
- Mailing list: Join our developer list.
- IRC: Find us in chat.freenode.net channel #opengovernment.
- Pivotal Tracker is our day-to-day project management space
- Bugs? Lighthouse is where they go.
Before you install the app, you will need to download and install the following:
- Git
- Ruby Enterprise Edition 1.8.7 recommended (install via RVM)
- Bundler for rubygem installation
- PostgreSQL 8.4
- PostGIS (which requires the proj4 and geos libraries)
- ImageMagick image processing library
- Sphinx is required. Here are the install instructions. You can locate your
pg_sql
include directory usingpg_config --pkgincludedir
- GeoServer, if you want to see vote maps
- MongoDB for page view count support
We could really use some Chef recipes or something that would ease the install process. Can you help with this? Meanwhile...
Pop open a terminal and run the following commands to get started.
These are used by gems like nokogiri or by our install scripts:
sudo apt-get install bison openssl libreadline5 libreadline5-dev curl zlib1g zlib1g-dev libssl-dev libxml2-dev libxslt-dev libxml2-dev
sudo apt-get install git-core
sudo apt-get install libpq-dev libkdb5-4 postgresql-8.4 postgresql-doc-8.4
sudo apt-get install postgis postgresql-8.4-postgis
sudo apt-get install sphinxsearch
sudo apt-get install imagemagick
sudo apt-get install ruby-full rubygems
For the ffi gem, you'll need:
sudo apt-get install libffi-ruby
Then install bundler:
sudo gem install bundler
The bundle executable may not be in your path. If not, run:
sudo ln -s /var/lib/gems/1.8/bin/bundle /usr/local/bin/bundle
For Ubuntu 10.10, add this line to /etc/apt/sources.list
:
deb http://downloads.mongodb.org/distros/ubuntu 10.4 10gen
Then run:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
sudo apt-get update
sudo apt-get install mongodb-stable
That should do it, but other Ubuntus are covered on MongoDB's site.
These are the prerequisites for GeoServer:
sudo apt-get install java-common default-jre-headless tomcat6
This is the tricky part:
sudo -u tomcat6 -s
cd /var/lib/tomcat6/webapps
wget 'http://downloads.sourceforge.net/geoserver/geoserver-2.0.2-war.zip'
unzip geoserver-2.0.2-war.zip && rm geoserver-2.0.2-war.zip
exit
Now, change the JAVA_OPS
line in /etc/default/tomcat6 to:
JAVA_OPS="-jvm server -Djava.awt.headless=true -Xmx256M"
And restart tomcat:
sudo service tomcat restart
GeoServer should now be available at http://localhost:8080/geoserver/web/ Below, there are full instructions on setting up GeoServer to work with OpenGovernment.
Follow the instructions on DocSplit's site for full dependency install instructions. Among the optional items, you will only need tesseract.
Start by installing Xcode Then install Homebrew.
If you're using rvm:
rvm install ree # recommended
rvm --create ree@og
rvm use ree@og
Then run: brew update brew install postgresql
Now initialize the database, specifying the default encoding, like this:
initdb /usr/local/var/postgres -E utf8
Now startup postgres using the commands shown in brew info postgresql
If you're using rvm
gem install bundler
Now install PostGIS and Sphinx:
brew install postgis sphinx
Otherwise:
sudo gem install bundler
brew install mongodb
Then startup MongoDB using the commands shown in the installer.
Download and run the GeoServer Mac installer, then startup GeoServer
GeoServer should now be available at http://localhost:8080/geoserver/web/ Below, there are full instructions on setting up GeoServer to work with OpenGovernment.
Follow the instructions on Docsplit's site for full dependency install instructions. Among the optional items, you will only need tesseract.
Once you've satisfied the prerequisites, this should work on all platforms.
- Get a copy of the code: git clone http://github.com/opengovernment/opengovernment.git cd opengovernment git submodule init git submodule update bundle install
- Set up your config/database.yml and config/api_keys.yml (see api_keys.yml.example)
- Create your database role and give it superuser privileges: psql postgres CREATE ROLE opengovernment WITH SUPERUSER LOGIN CREATEDB; \q
To import the full dataset, run rake install
.
- Rake install will set up the database, install the PostGIS SQL components, install fixtures, and download and install datasets.
- You can provide a comma-separated list of state abbreviations in a LOAD_STATES env variable to rake install. Otherwise, the default "loadable" states will be loaded, as specified in the lib/tasks/fixtures/states.yml file.
Alternatively, you can quickly get up and running with rake install_dev
. This will import YAML fixtures and give you enough of a database to browse the site.
Once the install is complete, build the Sphinx index and start the Sphinx server:
rake ts:rebuild
Then start Rails with bin/rails s
.
OpenGovernment uses subdomains, so to access the site you'll find the 127localhost.com
domain helpful. This is a domain for which all subdomains point to localhost. So if you visit, for example, http://tx.127localhost.com:3000
, you should see the Texas OpenGovernment site.
Once you have GeoServer running, there are further setup steps.
You'll want to sign in to your local GeoServer: GeoServer: http://localhost:8080/geoserver/web/ Default username: admin Default p/w: geoserver
Add a new Store for OpenGovernment. Here are the details: Data Source: PostGIS Workspace: cite Date Source Name: og Database User & PW should match your database.yml
You'll want to add two new Layers to the og
Store as well. You'll only need to set the name and title on these--all other settings can remain default. The layers should be called v_district_people
and v_district_votes
.
To prepare the test database: RAILS_ENV=test rake db:test:prepare
.
Then, to run all tests: rake
.
You can use autotest or spork. To fire up the spork-based drb server, run script/spec_server
Many bill versions and documents in state legislatures have FTP URLs associated with them. Ruby 1.8.7's Net::FTP does not negotiate passive FTP and will hang if you are using iptables without the ip_conntrack_ftp
module.
In /etc/sysconfig/iptables-config
, add it to IPTABLES_MODULES
:
IPTABLES_MODULES="ip_conntrack_netbios_ns ip_conntrack_ftp"