diff options
-rw-r--r-- | README.pod | 304 | ||||
-rwxr-xr-x | bin/make_css | 4 | ||||
-rw-r--r-- | conf/general-example | 74 | ||||
-rw-r--r-- | conf/general-example.yml | 60 | ||||
-rw-r--r-- | conf/packages | 2 | ||||
-rw-r--r-- | notes/glossary.txt | 7 | ||||
-rw-r--r-- | perllib/FixMyStreet.pm | 24 | ||||
-rw-r--r-- | perllib/FixMyStreet/App.pm | 2 |
8 files changed, 370 insertions, 107 deletions
diff --git a/README.pod b/README.pod index f6041e286..b020a81e2 100644 --- a/README.pod +++ b/README.pod @@ -1,19 +1,305 @@ - =head1 NAME FixMyStreet -=head1 DESCRIPTION +=head1 ABOUT FixMyStreet is a project that allows anyone to report an issue such as potholes, broken street lights, severe littering, water leaks. These issues are then -routed to the correct body who can arrange to have them fixed. +routed to the correct body who can arrange to have them fixed. By default it +supports routing problems via email or using an Open311 WebService. + +It's written in Perl and uses the Catalyst web framework. + +=head1 QUICKSTART + +=over + +=item * + +Download latest version from [THIS BIT TODO] + +=item * + +Untar this in the vhost location [TODO - more detail here] + +=item * + +Create a new PostGIS enabled database + +=item * + +Run db/schema.sql and the db/alert_types.sql + +=item * + +Run ./bin/cron-wrapper ./perl-external/bin/module-manage.pl setup + +=item * + +Create a new Apache vhost based on conf/httpd-conf.example + +=item * + +Copy conf/general-example.yml to conf/general.yml and update accordingly [FIXME!] + +=item * + +Generate the CSS by running bin/make_css + +=item * + +Restart the webserver + +=back + +=head1 DOWNLOADING + +Download from [URL GOES HERE] + +or get the latest version from L<github|http://github.com/mysociety/fixmystreet> + +=head1 REQUIREMENTS + +On the server you are installing FixMyStreet on you will need the following things: + +=over + +=item * + +PostgreSQL and the PostGis extension + +=item * + +Perl 5.8 or above + +=item * + +ImageMagick and the perl bindings. + +=item * + +A webserver that supports FastCGI + +=item * + +gettext + +=item * + +The CSS for FixMyStreet is generated from SCSS sources so you will need a SCSS +to CSS convertor. You can get one from http://sass-lang.com/ + +=back + +For most uses of FixMyStreet you'll also need access to a MaPit server with +data for the types of bodies you are reporting issues to. For more details on +how to install MaPit see the L<mapit pypi page|http://pypi.python.org/pypi/django-mapit/> + +If you're expecting a lot of traffic it's recommended that you install L<memcached|http://memcached.org/> + +If you are using a Debian based linux distribution there is a list of relevant +packages in conf/packages. + +=head1 DETAILED INSTALLATION INSTRUCTIONS + +=head2 Unpacking the Code + +Once you've downloaded the code you should unpack it. The best place to do this +is in the location you want the web server vhost to be. + +=head2 Creating the database + +The default settings file assumes the database is called fms and the user the same. +You can change these if you like. + +The database you create for FixMyStreet should be a PostGis enabled one. The best way +to do this is to use a PostGIS template database. There are good instructions on how +to create one L<on the django site|https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/#spatialdb-template> +as well as some bash scripts that automate the process. + +=head2 Set up the database + +Once you've created the database you can use the sql in db/schema.sql to create the required +tables, triggers and stored procedures. You will also need to run db/alert_types.sql which +populates the alert_types table. + +=head2 Install Perl modules + +FixMyStreet uses a number of CPAN modules which can be installed using +module-manage.pl which takes care of fetching specific versions of packages +from CPAN and building them. To install all the CPAN packages needed: + + eval `./setenv.pl` + module-manage.pl setup + +Note that unless you have already installed the DBD::Pg module then you will need +the postgresql source available, most likely through your distributions postgresql-dev +package. You will also need a development toolchain in place ( make, gcc etc ) for +some modules. + +Look in the perl-external directory for details. Notably the following are important: + +=over + +=item urls.txt + +url to the specific packages to fetch + +=item modules.txt + +list of all modules that need to be built + +=item minicpan/ + +local subset of cpan - used as source for all packages + +=item local-lib + +where the cpan modules get built to + +=item lib + +some initial modules needed for bootstrap + +=item bin + +scripts to make it all work + +=back + +Read the perl-external/bin/module-manage.pl code to see how it all works. It is +basically a wrapper around cpanm (which builds the packages) and dpan (which +helps maintain the fake cpan subset). + +If you need to add a module do it using: + + module-manage.pl add Module::To::Add + +and it will update all the relevant bits. + +=head2 Set up Webserver + +It is recommended that you run FixMyStreet using FastCGI. It should also be +possible to run it using Plack/PSGI. + +There is an example Apache vhost configuration file on conf/httpd.conf-example +which you can copy and update the paths in if you are running FixMyStreet under +FastCGI. + +If you are using Apache and the sample configuration you will need the following +modules enabled: + +=over + +=item * + +mod_rewrite + +=item * + +mod_proxy + +=item * + +mod_expires + +=item * + +mod_fastcgi + +=over + +=head1 SETTINGS + +The settings for FixMyStreet are defined in conf/general.yml using the YAML +markup language. There are some defaults in conf/general-example.yml which +you should copy to conf/general.yml. + +The bare minimum of settings you will need to fill in or update are: + +=over + +=item FMS_DB_PASS + +This is the password for the database. + +=item BASE_URL + +The URL for the homepage of your FixMyStreet install. + +=item EMAIL_DOMAIN + +The email domain that emails will be sent from + +=item CONTACT_EMAIL + +The email address to be used on the site for the contact us form. + +=item STAGING_SITE + +If this is 1 then all email ( alerts and reports ) will be sent to the +contact email address. Use this for development sites. + +=item UPLOAD_CACHE + +This is the location where imaged will be stored as they are being uploaded. +It should be accessible by and writeable by the FixMyStreet process. + +=item GEO_CACHE + +This is the location where Geolocation data will be cached. +It should be accessible by and writeable by the FixMyStreet process. + +=back + +If you are using Bing or Google maps you should also set one of +BING_MAPS_API_KEY or GOOGLE_MAPS_API_KEY. + +If you are using a MaPit install you should update MAPIT_URL. + +=head2 Generate CSS + +There is a script, bin/make_css, that uses L<sass|http://sass-lang.com/> to +convert the SCSS files to CSS files. + +=head2 Restart the webserver + +At this point you be able to restart the webserver and see your FixMyStreet +installation at the configured URL. + +=head1 COMMON PROBLEMS + +=head2 CPAN MODULE PROBLEMS + +Currently, you probably need to add EncodedColumn manually: + + module-manage.pl add DBIx::Class::EncodedColumn + +...because it's explicitly overridden in the code, which is fooling the installer. + +If a module won't build (Test::WWW::Mechanize and HTTP::Server::Simple fail +tests for me but the failures are not pertinent) then the module-manage script +will bail out. Look in ~/.cpanm/build_log to see what went wrong. You can force +an install if the test failures are not important by running cpanm directly: + + cpanm \ + --mirror /absolute/path/to/perl-external/minicpan \ + --mirror-only \ + --force \ + Test::WWW::Mechanize + +=head2 locale + +By default FixMyStreet used the en_GB.UTF-8 locale. If it is not installed then +it may not start + +=head2 Template caching -=head1 INSTALLING +FixMyStreet caches compiled templates alongside the source files so the templates +directory needs to be writable by the process that is running FixMyStreet. -Installing from scratch can be a bit daunting but is fully documented in the -notes/INSTALL file. +=head2 Image::Magick -We are hoping to make it much easier for you to try the code by letting you -start a fully installed system with test data pre-loaded on Amazon's servers. -More details will follow soon. +If your OS has a way to install a binary version of Image::Magick then it's recommended +that you do that rather than install via CPAN. diff --git a/bin/make_css b/bin/make_css index 59acdb984..96c768acc 100755 --- a/bin/make_css +++ b/bin/make_css @@ -2,8 +2,8 @@ # # make_css: # Generate CSS files from SCSS files. -# Curerntly the CSS files are also in version control, though I guess -# in future they don't need to be, and compressed style could then be used. +# +# Requires sass which you can get from http://sass-lang.com/ # # Copyright (c) 2011 UK Citizens Online Democracy. All rights reserved. # Email: matthew@mysociety.org. WWW: http://www.mysociety.org diff --git a/conf/general-example b/conf/general-example deleted file mode 100644 index 65e192b4d..000000000 --- a/conf/general-example +++ /dev/null @@ -1,74 +0,0 @@ -<?php -/* - * general-example: - * Example values for the "general" config file. - * - * Configuration parameters, in PHP syntax. Configuration parameters are set - * using the PHP define('OPTION_...', '...') function. Both perl and PHP code - * parse this properly, so you can use comments and conditionals and whatnot, - * but unless essential it's better to keep it simple.... - * - * Copy this file to one called "general" in the same directory. Or - * have multiple config files and use a symlink to change between them. - * - * Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved. - * Email: francis@mysociety.org; WWW: http://www.mysociety.org - * - * $Id: general-example,v 1.23 2010-01-06 14:59:34 louise Exp $ - * - */ - -// PostgreSQL database for BCI -define('OPTION_BCI_DB_HOST', 'localhost'); -define('OPTION_BCI_DB_PORT', '5432'); -define('OPTION_BCI_DB_NAME', 'bci'); -define('OPTION_BCI_DB_USER', 'bci'); -define('OPTION_BCI_DB_PASS', ''); - -define('OPTION_BASE_URL', 'http://www.example.org'); - -define('OPTION_EMAIL_DOMAIN', 'example.org'); -define('OPTION_CONTACT_EMAIL', 'team@'.OPTION_EMAIL_DOMAIN); -define('OPTION_TEST_EMAIL_PREFIX', null); - -define('OPTION_CONTACT_NAME', 'FixMyStreet'); -define('OPTION_STAGING_SITE', 1); - -define('OPTION_UPLOAD_CACHE', '/upload/'); -define('OPTION_GEO_CACHE', '/cache/'); -define('OPTION_GOOGLE_MAPS_API_KEY', ''); -define('OPTION_BING_MAPS_API_KEY', ''); - -define('OPTION_LONDON_REPORTIT_URL', ''); -define('OPTION_LONDON_REPORTIT_KEY', ''); -define('OPTION_LONDON_REPORTIT_SECRET', ''); - -define('OPTION_MAPIT_URL', 'http://mapit.mysociety.org/'); -define('OPTION_MAP_TYPE', 'OSM'); -define('OPTION_EVEL_URL', 'http://services.mysociety.org/evel'); -define('OPTION_GAZE_URL', 'http://gaze.mysociety.org/gaze'); - -// Tracking -define('OPTION_TRACKING', 0); // off by default -define('OPTION_TRACKING_URL', 'http://path/to/web/bug'); -define('OPTION_TRACKING_SECRET', 'really-secret-value'); - -define('OPTION_AUTH_SHARED_SECRET', ''); -define('OPTION_HEARFROMYOURMP_BASE_URL', ''); - -define('OPTION_SMTP_SMARTHOST', 'localhost'); - -define('OPTION_IPHONE_URL', ''); - -// Log file (used in test harness, and later in admin scripts) -define('OPTION_HTTPD_ERROR_LOG', '/var/log/apache/error.log'); - -define('OPTION_ALLOWED_COBRANDS', 'cobrand_one|cobrand_two'); - -// How many items are returned in the GeoRSS feeds by default -define('OPTION_RSS_LIMIT', '20'); - -// Should problem reports link to the council summary pages? -define('OPTION_AREA_LINKS_FROM_PROBLEMS', '0'); - -?> diff --git a/conf/general-example.yml b/conf/general-example.yml new file mode 100644 index 000000000..efdb5d007 --- /dev/null +++ b/conf/general-example.yml @@ -0,0 +1,60 @@ +# general-example.yml: +# Example values for the "general" config file. +# +# Configuration parameters, in YAML syntax. +# +# Copy this file to one called "general.yml" in the same directory. Or +# have multiple config files and use a symlink to change between them. + +# PostgreSQL database for FMS +FMS_DB_HOST: 'localhost' +FMS_DB_PORT: '5432' +FMS_DB_NAME: 'fms' +FMS_DB_USER: 'fms' +FMS_DB_PASS: '' + +BASE_URL: 'http://www.example.org' + +EMAIL_DOMAIN: 'example.org' +CONTACT_EMAIL: 'team@example.org' +TEST_EMAIL_PREFIX: '' + +CONTACT_NAME: 'FixMyStreet' +STAGING_SITE: 1 + +UPLOAD_CACHE: '/upload/' +GEO_CACHE: '/cache/' +GOOGLE_MAPS_API_KEY: '' +BING_MAPS_API_KEY: '' + +LONDON_REPORTIT_URL: '' +LONDON_REPORTIT_KEY: '' +LONDON_REPORTIT_SECRET: '' + +MAPIT_URL: 'http://mapit.mysociety.org/' +MAP_TYPE: 'OSM' +EVEL_URL: 'http://services.mysociety.org/evel' +GAZE_URL: 'http://gaze.mysociety.org/gaze' + +# Tracking +TRACKING: 0 # off by default +TRACKING_URL: 'http://path/to/web/bug' +TRACKING_SECRET: 'really-secret-value' + +AUTH_SHARED_SECRET: '' +HEARFROMYOURMP_BASE_URL: '' + +SMTP_SMARTHOST: 'localhost' + +IPHONE_URL: '' + +# Log file (used in test harness, and later in admin scripts) +HTTPD_ERROR_LOG: '/var/log/apache/error.log' + +ALLOWED_COBRANDS: 'cobrand_one|cobrand_two' + +# How many items are returned in the GeoRSS feeds by default +RSS_LIMIT: '20' + +# Should problem reports link to the council summary pages? +AREA_LINKS_FROM_PROBLEMS: '0' diff --git a/conf/packages b/conf/packages index 5fa3cf77e..15fb8dca3 100644 --- a/conf/packages +++ b/conf/packages @@ -16,7 +16,6 @@ libsoap-lite-perl libstatistics-distributions-perl liburi-perl libwww-perl -libwww-perl libxml-rss-perl memcached perl @@ -26,7 +25,6 @@ perlmagick libjson-perl libimage-size-perl libmath-bigint-gmp-perl -libtext-template-perl gettext libtest-exception-perl libipc-run3-perl diff --git a/notes/glossary.txt b/notes/glossary.txt index 0c533a944..5a86e5a63 100644 --- a/notes/glossary.txt +++ b/notes/glossary.txt @@ -1,12 +1,5 @@ Unfamiliar terms that you may come across in the code: - -BCI: Broken Civic Infrastructure - project name before it became FixMyStreet - -still to be found used in some config variable names - MaPit: The mySociety database and web service that maps postcodes and points to current or past administrative area information and polygons for all the United Kingdom. http://mapit.mysociety.org/ - -EvEl: A generic email sending and mailing list functionality, with bounce -detection: https://secure.mysociety.org/cvstrac/dir?d=mysociety/services/EvEl diff --git a/perllib/FixMyStreet.pm b/perllib/FixMyStreet.pm index d63f708d2..2d8f462d5 100644 --- a/perllib/FixMyStreet.pm +++ b/perllib/FixMyStreet.pm @@ -107,15 +107,15 @@ sub dbic_connect_info { my $class = shift; my $config = $class->config; - my $dsn = "dbi:Pg:dbname=" . $config->{BCI_DB_NAME}; - $dsn .= ";host=$config->{BCI_DB_HOST}" - if $config->{BCI_DB_HOST}; - $dsn .= ";port=$config->{BCI_DB_PORT}" - if $config->{BCI_DB_PORT}; + my $dsn = "dbi:Pg:dbname=" . $config->{FMS_DB_NAME}; + $dsn .= ";host=$config->{FMS_DB_HOST}" + if $config->{FMS_DB_HOST}; + $dsn .= ";port=$config->{FMS_DB_PORT}" + if $config->{FMS_DB_PORT}; $dsn .= ";sslmode=allow"; - my $user = $config->{BCI_DB_USER} || undef; - my $password = $config->{BCI_DB_PASS} || undef; + my $user = $config->{FMS_DB_USER} || undef; + my $password = $config->{FMS_DB_PASS} || undef; my $dbi_args = { AutoCommit => 1, @@ -146,11 +146,11 @@ sub configure_mysociety_dbhandle { my $config = $class->config; mySociety::DBHandle::configure( - Name => $config->{BCI_DB_NAME}, - User => $config->{BCI_DB_USER}, - Password => $config->{BCI_DB_PASS}, - Host => $config->{BCI_DB_HOST} || undef, - Port => $config->{BCI_DB_PORT} || undef, + Name => $config->{FMS_DB_NAME}, + User => $config->{FMS_DB_USER}, + Password => $config->{FMS_DB_PASS}, + Host => $config->{FMS_DB_HOST} || undef, + Port => $config->{FMS_DB_PORT} || undef, ); } diff --git a/perllib/FixMyStreet/App.pm b/perllib/FixMyStreet/App.pm index beea8bb11..21552a066 100644 --- a/perllib/FixMyStreet/App.pm +++ b/perllib/FixMyStreet/App.pm @@ -178,7 +178,7 @@ sub setup_request { $c->model('DB::Problem')->set_restriction( $cobrand->site_restriction() ); - Memcached::set_namespace( FixMyStreet->config('BCI_DB_NAME') . ":" ); + Memcached::set_namespace( FixMyStreet->config('FMS_DB_NAME') . ":" ); my $map = $host =~ /^osm\./ ? 'OSM' : $c->req->param('map_override'); #if ($c->sessionid) { |