Skip to content
This repository has been archived by the owner on Nov 10, 2020. It is now read-only.

Gatsby explore data page #3106

Merged
merged 95 commits into from Aug 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
ba2baae
test
Jul 2, 2018
ba9dd7c
added deploy directory
Jul 2, 2018
7dda058
updated path prefix
Jul 2, 2018
4146964
added frontmatter
Jul 2, 2018
3487d64
updated about page and layout
Jul 2, 2018
45322e9
added site baseurl to config
Jul 2, 2018
0958d2d
hard coded preview for prefix config, replaced layotu with none
Jul 2, 2018
fcb1b3e
new link update
Jul 3, 2018
9e85d74
disabled preloader
Jul 3, 2018
bfb9b90
remove loader
Jul 3, 2018
cdf51ea
test disabling loader error
Jul 3, 2018
e7a0e4c
Merge branch 'dev' into gatsby-dev
Jul 5, 2018
1eb8167
udpated loader
Jul 5, 2018
f15e157
updated loader
Jul 5, 2018
868c9e5
Merge branch 'dev' into gatsby-dev
Jul 6, 2018
2ccd23d
added glossary term component
Jul 9, 2018
5488577
Merge branch 'dev' into gatsby-dev
Jul 9, 2018
848082c
added store connection to glossary term
Jul 10, 2018
e8b068a
Merge branch 'dev' into gatsby-dev
Jul 10, 2018
56708cf
added toggle
Jul 10, 2018
8671c3a
fully functioning glossary
Jul 10, 2018
6bc190f
added search component, gatsby-plugin-resolve-src and rearrange files
Jul 11, 2018
1a8338f
prefix paths updateed for dev and jekyll build
Jul 11, 2018
f068f90
fixed links and search link
Jul 11, 2018
b9ed415
fixed search link
Jul 11, 2018
0be3d3e
Merge branch 'dev' into gatsby-dev
Jul 12, 2018
3db96dd
Merge branch 'dev' into gatsby-dev
Jul 13, 2018
281a199
updated gatsby
Jul 17, 2018
6f0b435
updated bar chart code
Jul 18, 2018
cfc69d6
EXPLORE DATA page update
Jul 25, 2018
14b2f36
Explore Data Page updated
Jul 26, 2018
7a69941
Merge branch 'dev' into gatsby-dev
Jul 26, 2018
04c38e4
Merge branch 'gatsby-dev' into gatsby-explore-data-page
Jul 26, 2018
00c4a38
added post build process functions
Jul 26, 2018
2ec0d33
Fix build
Jul 26, 2018
0e6baf3
Build Gatsby on Federalist
Jul 26, 2018
5875ef2
Remove gatsby-public from prefix
Jul 26, 2018
7631e71
Remove pages that are provided by Jekyll
Jul 26, 2018
87e6aea
fixup
Jul 26, 2018
8312e19
Copy Gatsby build files to Jekyll build directory
Jul 26, 2018
3478911
Move jekyll build into federalist step
Jul 26, 2018
7c35c95
wip
Jul 26, 2018
3d2b9e4
wip
Jul 26, 2018
07def2e
wip
Jul 26, 2018
95fad89
wip
Jul 26, 2018
af58605
wip
Jul 26, 2018
70e71f6
wip
Jul 26, 2018
eb76434
test build
Jul 26, 2018
2d883cb
Lowercase explore/about pages
Jul 26, 2018
395f920
added gastby link back
Jul 26, 2018
d9ce9e4
Merge branch 'gatsby-federalist' into gatsby-explore-data-page
Jul 26, 2018
7103c01
fix build?
Jul 27, 2018
baa3079
wip
Jul 27, 2018
aabbb27
wip
Jul 27, 2018
2fe6984
wip
Jul 27, 2018
5ad738f
wip
Jul 27, 2018
0b93556
wip
Jul 27, 2018
d0f7cd1
wip
Jul 27, 2018
3ffbc09
wip
Jul 27, 2018
fbd140b
wip
Jul 27, 2018
66c941b
wip
Jul 27, 2018
cc91eb4
added pages array
Jul 27, 2018
9cb07fe
wip
Jul 27, 2018
1d5fde2
creating atomic design pattern for components
Jul 31, 2018
479c353
Merge branch 'dev' into gatsby-explore-data-page
Jul 31, 2018
4b1a260
fixed package.json
Jul 31, 2018
311f853
updated disbursements on explore data page
Aug 3, 2018
b68bcb1
Merge branch 'dev' into gatsby-explore-data-page
Aug 3, 2018
ab844c6
explore data page update to year selector
Aug 3, 2018
7d2b031
updated path prefix
Aug 3, 2018
3c2f221
updated path prefix
Aug 3, 2018
f402784
added gastby-public back to git since we are building locally again
Aug 6, 2018
87bf99c
removing gatsby-pubic and running build script from federalist
Aug 6, 2018
149baec
fixed spelling error
Aug 6, 2018
f74883d
updated based on feedback, sort order fixed, display fund when no dat…
Aug 7, 2018
af7373d
removed ssr since we are not doing server side rendering
Aug 7, 2018
7aa656c
removed gatsby-public again
Aug 7, 2018
15bfe39
Merge branch 'migrate-styleguide' of https://github.com/ONRR/doi-extr…
Aug 8, 2018
f6e6641
added components to pattern library
Aug 13, 2018
eab3d2b
fixed bug in update
Aug 13, 2018
07741f8
removed console.log
Aug 13, 2018
d340c9e
Merge branch 'dev' into gatsby-explore-data-page
Aug 13, 2018
89e276f
updated meta data
Aug 13, 2018
bc5a640
updated styling for icons and updated sort order for data
Aug 13, 2018
19f13ec
fxied spacing issues in navigation menus
Aug 13, 2018
920a2a7
added funded by congress data and moved some data files around
Aug 13, 2018
6f168c4
removed patterns build due to error
Aug 13, 2018
1c1c8b6
added google tag manager and analytics to index page and also fixed t…
Aug 14, 2018
c47b0b2
removed console log
Aug 14, 2018
c31a693
fxied meta data img import
Aug 14, 2018
0e7397f
fix build issue
Aug 14, 2018
6e3f147
fix preview error
Aug 16, 2018
1b5c9b7
Adds gatsby glossary terms for '8(g)' and 'authorization'
Aug 16, 2018
cee4346
remvoed space behind the year
Aug 16, 2018
5c5a269
Merge branch 'gatsby-explore-data-page' of https://github.com/ONRR/do…
Aug 16, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -17,3 +17,5 @@ styleguide
.brackets.json
.clasp.json
.npmrc
/.project
gatsby-public
3 changes: 3 additions & 0 deletions .settings/.gitignore
@@ -0,0 +1,3 @@
/.jsdtscope
/org.eclipse.wst.jsdt.ui.superType.container
/org.eclipse.wst.jsdt.ui.superType.name
2 changes: 2 additions & 0 deletions .settings/com.genuitec.eclipse.code.core.prefs
@@ -0,0 +1,2 @@
codemixBuild=true
eclipse.preferences.version=1
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
Expand Up @@ -164,6 +164,31 @@ If you would like to query the local database instance:

To update site data, run `make site-data`.


### Gatsby gotchas

[Gatsby](https://www.gatsbyjs.org/) is a JavaScript framework for building
static websites. We're currently migrating from Jekyll to Gatsby. The migration
is over a long time span, and there are some gotchas about making Jekyll and
Gatsby work together.

Our approach is to replace Jekyll pages with Gatsby pages in batches. Since
Jekyll is happy to take static pages and assets and copy them over to the
`_site` build directory, Gatsby can output compiled pages and then we just drop
them in the right location in the Jekyll source. E.g. for the about page, after
Gatsby builds it, we copy the about.html to the Jekyll source directory and then
the Jekyll build will pick it up.

Gatsby expects to own the entire website, so ...


#### Path prefix

Gatsby supports a [path prefix](https://www.gatsbyjs.org/docs/path-prefix/)
which we use for the Federalist build previews. Gatsby expects to be the entire
site.


### Deployment

This site is deployed on [Federalist](https://federalist.fr.cloud.gov/) whenever a commit it pushed to GitHub. Changes are deployed automatically to the production site when commits are pushed to the `master` branch.
Expand Down
35 changes: 35 additions & 0 deletions _bin/federalist-build.sh
@@ -0,0 +1,35 @@
#!/bin/bash
#
# Sets up the Federalist build for Jekyll
# Federalist already does this, but not until right before running jekyll. we
# need to run jekyll as part of the npm setup because gatsby has to be built
# after the jekyll build

project_dir=$(dirname $(dirname $0))

# Setup RVM for ruby
source /usr/local/rvm/scripts/rvm

# Set these after rvm to avoid them applying to the rvm function
set -o errexit
set -o pipefail
set -o nounset
set -x

# Install the correct version of ruby
read ruby_version < "$project_dir/.ruby-version"
rvm install "$ruby_version"

ruby -v

# Install ruby dependencies
gem install bundler
bundle install

# Append Federalist configuration to Jekyll config
cat <<EOF >> "$project_dir/_config.yml"
baseurl: "$BASEURL"
branch: "$BRANCH"
EOF

bundle exec jekyll build
3 changes: 3 additions & 0 deletions _config.noop.yml
@@ -0,0 +1,3 @@
# A jekyll config that only copies from one directory to another
source: _stage
destination: _site
2 changes: 2 additions & 0 deletions _config.yml
Expand Up @@ -146,3 +146,5 @@ shruggie:
- 009f8804ce5413a0d2a604e9938dba635c6c6222
- cc20376993abd596768c9c60ff456ad9f4fe8e7c
- 7f39b8e0a432747338ce075c50c19d2323da0e14

destination: _site
1 change: 1 addition & 0 deletions _layouts/gatsby.html
@@ -0,0 +1 @@
{{ content }}
13 changes: 2 additions & 11 deletions explore/index.html
@@ -1,16 +1,7 @@
---
layout: default
permalink: /explore/
redirect_from:
- /explore/exports/
- /explore/gdp/
- /explore/jobs/
- /explore/all-lands-production/
- /explore/federal-production/
- /explore/disbursements/
- /explore/federal-revenue-by-location/

id: US
title: Explore data

national_page: true
selector: location
nav_items:
Expand Down
50 changes: 48 additions & 2 deletions gatsby-site/README.md
@@ -1,6 +1,6 @@
# gatsby-starter-default

Minimalistic starter template for Gatsby with Redux and Emotion to get you started.
Minimalistic starter template for Gatsby with Redux to get you started.

## Demo

Expand All @@ -25,4 +25,50 @@ gatsby new your-project-name https://github.com/caki0915/gatsby-starter-redux

## Deploy

[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/caki0915/gatsby-starter-redux)
Steps:
1. Update gatsby-config.js to include the appropriate path-prefix
2. Run gatsby build --prefix-paths
3. Update the generated pages with the related frontmatter.
# About Page Frontmatter

---
title: About
layout: none
permalink: /about/
redirect_from: /about/whats-new/
---
# Explore Data Page Frontmatter

---
title: Explore data
layout: none
permalink: /explore/
redirect_from:
- /explore/exports/
- /explore/gdp/
- /explore/jobs/
- /explore/all-lands-production/
- /explore/federal-production/
- /explore/disbursements/
- /explore/federal-revenue-by-location/
---

4. Delete all contents of gatsby-public
5. Copy contents in the gatsby-site/public to gatsby-public

## Leveraging Atomic Design Methodology
Our React component code is organized by leveraging the Atomic Design Methodology approach. This helps us in organizing our code in logical way that is not bound by our current site design.

## D3 and React Integration Approach
Since both React and D3 want to control the DOM we had to decide on a approach to leverage the best of both worlds. We wanted to leverage React for its Virtual DOM, Redux for its data management and D3 for its charting/math capabilties. So in order for us to maximize what we wanted from all libraries we decide on a "React Lifecycle Methods" approach. Here is a great article that summarizes the various approaches we reviewed.

https://www.smashingmagazine.com/2018/02/react-d3-ecosystem/

More about the React Lifecycle Method approach

http://nicolashery.com/integrating-d3js-visualizations-in-a-react-app/

https://medium.com/@sxywu/on-d3-react-and-a-little-bit-of-flux-88a226f328f3



74 changes: 74 additions & 0 deletions gatsby-site/builds/maps/Makefile
@@ -0,0 +1,74 @@
node_bin ?= ../node_modules/.bin/
svgo ?= $(node_bin)svgo --disable=cleanupIDs
svgeo ?= $(node_bin)svgeo --projection ../lib/albers-custom.js --mesh --
topojson ?= $(node_nin)topojson
raster_scale ?= 4
states = AL AK AZ AR CA CO CT DE DC FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VT VA WA WV WI WY

all: \
state-maps \
viewboxes \
land/combined.gif

state-maps: \
$(foreach state,$(states),states/$(state).svg) \
states/all.svg

viewboxes: ../_data/viewboxes.yml

optimize-svg:
$(svgo) -f states

land/combined.gif: land/federal.gif land/tribal.gif
composite $^ $@

land/%.gif: land/%.png
convert -posterize 2 -transparent-color white $^ $@

land/%.png: land/%.json
./bin/rasterize.js --scale $(raster_scale) $^ > $@

land/federal.json: data/shp/fedlanp010g.shp
$(topojson) -p FEATURE1 federal=$^ > $@.tmp
$(topojson)-merge --io federal --oo federal \
-k d.properties.FEATURE1 -- $@.tmp > $@
rm $@.tmp

land/tribal.json: data/shp/indlanp010g.shp
$(topojson) tribal=$^ > $@

data/shp/%.shp:
mkdir -p $(dir $@)
cd $(dir $@); \
curl -s "ftp://rockyftp.cr.usgs.gov/vdelivery/Datasets/Staged/SmallScale/Data/Boundaries/$*.shp_nt00966.tar.gz" \
| tar -xzvf -

states/all.svg: data/us-topology.json
./bin/state-map.js $^ | $(svgo) -i - -o $@

states/%.svg: data/us-topology.json
./bin/state-map.js --state $* --counties -- $^ \
| $(svgo) -i - -o $@

offshore/all.svg: data/offshore.json
mkdir -p $(dir $@)
$(svgeo) $^ > $@

../_data/viewboxes.yml:
echo "# viewboxes:" > $@
for state in all $(states); do \
echo "$${state}: \c" >> $@; \
xpath states/$${state}.svg '//@viewBox' \
| perl -p -e 's/^.*="([^"]+)"/"$$1"\n/' >> $@; \
done

clean:
rm -f states/*.svg
rm -f land/*.png land/*.gif

distclean:
rm -f data/shp

.PHONY: \
state-maps \
viewboxes