What is Global Forest Watch?
Global Forest Watch (GFW) is a dynamic online forest monitoring and alert system that empowers people everywhere to better manage forests. This repository contains the GFW web app.
Installing the app
Place required environment settings in the
dev.env file, and then run:
GFW should then be accessible at localhost:5000/map, note, it may take around 2 mins to load due to large number of requests.
Local setup (>= OS X Yosemite 10.10)
Next install Homebrew, the OS X package manager, and imagemagick:
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" $ brew update $ brew install imagemagick@6
We recommend managing your Ruby installation through rvm. It's just an easy way to run multiple Ruby versions for different applications:
$ \curl -sSL https://get.rvm.io | bash -s stable
Next clone the gfw repo:
$ git clone https://github.com/Vizzuality/gfw.git
Using rbenv, install and set Ruby 2.4.0 in the main app directory:
$ cd gfw $ rvm install 2.4.0 $ rvm use 2.4.0
Now let's install Ruby on Rails:
$ gem install rails
Aaaaand now use Bundler, a rubygem manager, to install all the gem depenencies for the app:
$ bundle install
It is possible if you are using OS Sierra or greater you will experience errors when running
bundle install and
rmagick. There is a fix for this forcing symlinks with
imagemagick. You need to run the following command. Details can be found on this thread.
$ brew install imagemagick@6 --force && brew link imagemagick@6 --force
Installing front end dependencies:
$ yarn install
Almost there! Final steps are to copy the
.env, and start the server:
$ yarn start
The app should now be accessible on http://0.0.0.0:5000.
We have a local redis server for caching in production. We dont run this locally by default but if you want to test or develop on this feature you will need to install redis and run it:
$ brew install redis $ yarn redis
We follow a Gitflow Worklow for development and deployment. Our
master branch goes to production,
develop goes to
master. We also have a staging branch which is detached from the workflow that can be used to merge multiple branches for deployment to the staging site. Additionally you can deploy
develop or feature branches to staging if desired.
Clear Redis cache
If you need to clear the Redis cache after deploy, run these commands on your local terminal:
$ heroku redis:cli -a MY_APP_ID --confirm MY_APP_ID $ flushall
We are using github releases to record changes to the app. To help us manage this we are using Zeit Releases, an npm package for handling github releases, tagging commits (major, minor, patch), and automating semantic release logs. For a more detailed explantion of semantic changelogs see this post.
Managing commits for a release
When developing, you can tag your commits as follows:
fix some excellent bug (patch) where
patch can be
(major/minor/patch/ignore). This commit title will automatically be grouped into the correct section for the release. Otherwise you will be prompted during the release to assign (or ignore) each of your commits. You will have to do this for every commit so don't forget to squash!
So how do you make a release on GFW?
- Checkout master and merge in develop (not compulsory but advised for consistency).
npx release [type]where type can be
pre(see zeit docs for more details).
- Follow the prompts to manage commits.
- You will be taken to github draft release editor with all your commits grouped and ready to go.
- Enter your title and include any extra info you want.
Map layers, somewhat unsurprisingly, are an important part of GFW. As
such, the config and code supporting them can be a bit complex. Check
out the layer documentation for more information. If the
component you're working on isn't in there, please write some
documentation when you're done!
Google Custom Search API
Global Forest Watch uses the Google Custom Search API to power it's site-wide search.
The search requests are handled inside:
And depend on two config variables that you'll need to setup as ENV vars on
.env file locally or in the Heroku environment settings.
Currently the API being used was generated by
and the custom search context is owned by Alyssa Barrett on the Google Custom
Search Engine control panel.
We are using
RSpec for backend view and Rails testing, and Cypress for the front end. We have some legacy tests in
jstest/ which can also be run if needed. TravisCI handles our continuous integration for running tests. This calls both our backend and front end tests using
npm run ci.
We have tried to make developing tests for GFW as simple as possible. If you are working with an older part of the site like
my-gfw then you might need to write tests inside the
spec/ folder. However, you are most likely wanting to be writing JS tests for components or integration tests for features. You can develop these in the
cypress/ folder. To run these you can execute
npm run test. Cypress provides some great dev tools for building and debugging tests. You can access these with
npm run test:open. When writing tests please checkout the cypress docs for help with writing tests.
We use BrowserStack to find and fix cross-browser issues.
RW API Documentation for GFW
The schema used to style these layers, their legends, and define their interactions are specific to the Global Forest Watch platform.
When creating or modifying layers/datasets for GFW, follow the schema and syntax outlined in the API Documentation markdown file.
To view GFW-specific layers and datasets use the following endpoint:
The MIT License (MIT)
Copyright (c) 2015 Vizzuality
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.