Global Forest Watch: An online, global, near-real time forest monitoring tool
edbrett Merge pull request #3672 from Vizzuality/feature/widget-map-integration
Feature/move widget selectors to parent level
Latest commit 8d8226b Dec 13, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Adds pull request template Oct 19, 2017
app Merge pull request #3672 from Vizzuality/feature/widget-map-integration Dec 13, 2018
bin update server config Sep 12, 2018
config compile assets Nov 14, 2018
cypress ignore screenshots and videos Apr 18, 2018
db First version May 16, 2012
docs Move to docs Aug 17, 2018
jstest Adds loss by driver to analysis Aug 31, 2018
layerspec_data https fetches for layers and requests Apr 5, 2018
lib remove snippet collectors checking Nov 23, 2018
log rails 4, first commit Jan 23, 2014
public fix favicon error in 422 file Nov 23, 2018
spec add meta component in rails and react based on url params Sep 15, 2018
vendor/assets remove pre-commit changes May 8, 2018
.babelrc disable tree mapping webpack plugin Sep 10, 2018
.bowerrc added bower Jun 30, 2014
.editorconfig editor config Sep 4, 2014
.env.prod.sample remove old deps Nov 12, 2018
.env.sample updates for readme Nov 2, 2018
.eslintignore first basic test Apr 12, 2018
.eslintrc.yml polygon analysis styles Jul 18, 2018
.gitignore Tree loss widget working with tooltip, missing map layer integration Nov 27, 2018
.lintstagedrc Improve tooling Feb 9, 2018
.nvmrc upgrade node Aug 30, 2018
.postcssrc app rendering through webpack 4 Sep 9, 2018
.rbenv-gemsets Fix country overview tree cover query Mar 17, 2017
.rspec Upgraded rspec-rails configuration files Nov 21, 2017
.sass-lint.yml include loaders Oct 19, 2017
.slugignore Adds .slugignore to ignore files and directories on Heroku deploy Oct 19, 2017
.stylelintrc Modal content Feb 9, 2018
.travis.yml upgrade react and add updated map component Jul 13, 2018
Dockerfile dockerised gfw functioning Apr 10, 2017
Gemfile [Security] Bump rails from 5.2.1 to 5.2.1.1 Nov 27, 2018
Gemfile.lock [Security] Bump rails from 5.2.1 to 5.2.1.1 Nov 27, 2018
Gruntfile.js Use different port for tests (8000 is used by the GFW API) Feb 12, 2016
LICENSE update readme Feb 21, 2014
Procfile revert Procfile changes May 16, 2018
Procfile.dev allow local connection from dev server Oct 24, 2018
README.md Update readme Nov 2, 2018
Rakefile Updates Rakefile to match Rails 5.1 syntax Nov 21, 2017
bower.json allow updated version of underscore Apr 20, 2018
config.ru update env file sample to be consistent with live Jun 14, 2018
cypress.json base url for testing Apr 17, 2018
docker-compose-develop.yml switched to existing environment file Apr 11, 2017
docker-compose-test.yml switched to existing environment file Apr 11, 2017
docker-compose.yml Dockerizing the GFW app. WIP Apr 7, 2017
entrypoint.sh change to RAILS_ENV for heroku Jun 19, 2018
gfw.sh dockerised gfw functioning Apr 10, 2017
git New Layer: Sabah Protected Areas Jul 7, 2016
package.json revert redux tools Dec 8, 2018
testem.yml enabling testem command Jul 10, 2014
yarn.lock revert redux tools Dec 8, 2018

README.md

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.

Global forest watch map

Developing

The GFW web app rides on Ruby on Rails, Backbone and React with Redux.

Installing the app

Docker

Place required environment settings in the dev.env file, and then run:

./gfw.sh develop

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)

First make sure you have Xcode and Command Line Tools installed.

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.sample to .env, and start the server:

$ yarn start

The app should now be accessible on http://0.0.0.0:5000.

REDIS

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

Deployment

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.

gitflow workflow

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

Releases

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?

  1. Checkout master and merge in develop (not compulsory but advised for consistency).
  2. Run npx release [type] where type can be major, minor, patch, or pre (see zeit docs for more details).
  3. Follow the prompts to manage commits.
  4. You will be taken to github draft release editor with all your commits grouped and ready to go.
  5. Enter your title and include any extra info you want.
  6. Publish!

Layers

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: app/controllers/search_controller.rb And depend on two config variables that you'll need to setup as ENV vars on your .env file locally or in the Heroku environment settings.

GOOGLE_SEARCH_API_KEY
GOOGLE_CUSTOM_SEARCH_CX

Currently the API being used was generated by simao.belchior@vizzuality.com and the custom search context is owned by Alyssa Barrett on the Google Custom Search Engine control panel.

Testing

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.

Development

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 stories or 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.

BrowserStack

We use BrowserStack to find and fix cross-browser issues.

RW API Documentation for GFW

Map layers and relevent datasets are stored in the RW-API and the globalforestwatch.org/map utilises the layer-manager to render them.

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:

https://api.resourcewatch.org/v1/dataset?app=gfw&includes=layer,vocabulary,metadata&page[size]=200

License

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.