Giter VIP home page Giter VIP logo

gnl-react's Introduction

Detroit Ledger Frontend

This code produces the site you see on the Detroit Ledger

Installation

npm install -g gulp
npm install -g bower
npm install
gem install sass
gem install compass

See .travis.yml for an example of how to fulfill the compass and sass dependencies if they give you trouble.

Development

gulp watch to recompile and run tests on file change

gulp watch-sans-test to recompile without tests on file change

gulp build to build the site for deployment

Installing a new module

Say you need a new third party library like jquery or bootstrap:

  1. Add it to bower.json
  2. gulp install
  3. Add it to package.json -- make sure it's under browser.

Prerender

We use a little proxy server to pre-render pages for SEO.

First, you'll need to get a prerender service running somewhere.

Then, configure this app to use that service:

$ export PRERENDER_SERVICE_URL=<new url>

Or on heroku:

$ heroku config:add PRERENDER_SERVICE_URL=<new url>

You can customize the port the proxy server listens to:

$ export PORT=<8080>

Finally, run the server:

$ node server.js

To test that things are working, vist a URL and change the #! to ?_escaped_fragment_=. If you view source, you should see the full content.

Docker

In your local repo, git remote add live [email protected]:repos/detroitledger.git.

Later on, git push live gh-pages when you want to deploy.

In the background, the following post-receive hook happens:

#!/usr/bin/env bash

. $HOME/.nvm/nvm.sh

export GIT_WORK_TREE="$HOME/repos/detroitledger"
git checkout -f gh-pages

cd $GIT_WORK_TREE

npm install
gulp install
NODE_ENV=production gulp build
docker build -t detroitledger/gnl-frontend:`cd ../detroitledger.git && git log --pretty=format:'%h' -n 1` .
docker stop gnl-frontend
docker rm gnl-frontend
docker run -d --name=gnl-frontend -e PRERENDER_SERVICE_URL=http://`docker inspect --format='{{.NetworkSettings.IPAddress}}' prerender`:3000 detroitledger/gnl-frontend:`cd ../detroitledger.git && git log --pretty=format:'%h' -n 1`

Troubleshooting

Get an error like this when running gulp watch?

[10:39:02] Error: Test server exited prematurely.
    at ChildProcess.handlePrematureExit (/Users/matth/projects/detroit/detroitledger/node_modules/exec-wait/index.js:49:25)
    at ChildProcess.g (events.js:199:16)
    at ChildProcess.emit (events.js:110:17)
    at Process.ChildProcess._handle.onexit (child_process.js:1078:12)

You probably already have something running on port 8080. Run sudo lsof -i :8080 to find it.

gnl-react's People

Contributors

bnchdrff avatar hampelm avatar jessicamcinchak avatar mtiger2k avatar

Watchers

 avatar  avatar  avatar  avatar

gnl-react's Issues

Error handling, page reload speed

I find myself staring at this error or another that looks nearly the same a lot while developing. Sometimes it's because the assets are regenerating, which can take a few seconds, and other times it's because there's an error in my JS.

  • Is there an easy way to get the errors in the browser rather than a separate console window, so it's clear when the site is reloading vs. broken?
  • Possible to do more incremental updates w/ webpack so development is quicker?

screen shot 2018-09-08 at 12 26 09 pm

Heroku build not starting a webserver

> heroku restart --app gnl-react
> heroku logs --app gnl-react --tail
...
2019-05-04T15:19:22.607775+00:00 app[web.1]: [./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html] 717 bytes {0} [built]
2019-05-04T15:19:22.607776+00:00 app[web.1]: [./node_modules/lodash/lodash.js] 527 KiB {0} [built]
2019-05-04T15:19:22.607778+00:00 app[web.1]: [./node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 472 bytes {0} [built]
2019-05-04T15:19:22.607780+00:00 app[web.1]: [./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {0} [built]
2019-05-04T15:19:22.608159+00:00 app[web.1]: ℹ 「wdm」: Compiled successfully.
2019-05-04T15:20:02.214391+00:00 heroku[web.1]: State changed from starting to crashed
2019-05-04T15:20:02.027912+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2019-05-04T15:20:02.027912+00:00 heroku[web.1]: Stopping process with SIGKILL
2019-05-04T15:20:02.193305+00:00 heroku[web.1]: Process exited with status 137

debug jest snapshot testing

Working on testing our React components using Jest's Snapshot and the react-test-renderer npm package.

Issue: When running npm test, a file (like IrsData.test.js.snap) should be created and committed to code. But it's never being created.

Things I've unsuccessfully tried so far:

  • Alternating between putting my test file in a __tests__ folder and directly in the components directory. In each place, the file is recognized and the test passes, but the snapshot is never created.
  • Installing jest globally to be able to run jest -u and/or jest --updateSnapshot which should prompt an updated or new snapshot

GrantsTable improvements

Since updating to render all grants, a few ideas for improving display & performance:

  • Define a custom merge function for InMemoryCache (see console error on Org page)
  • Eliminate re-fetch on "showGrantsSide" prop change
  • Sort table rows by organization totals desc
  • Limit rows shown in table by default. Paginate instead of scroll? Or something like react-virtualized?

Some orgs don't load

Eg http://localhost:8080/organizations/us-department-of-housing-and-urban-development-hud/25b7c32d-07c1-4932-975f-ed454e19640c

Organization.js:176 Error: GraphQL error: The loader.load() function must be called with a value,but got: null.
    at new ApolloError (ApolloError.js:40)
    at ObservableQuery.currentResult (ObservableQuery.js:101)
    at Query._this.getQueryResult (react-apollo.browser.umd.js:349)
    at finish (react-apollo.browser.umd.js:469)
    at Query.render (react-apollo.browser.umd.js:473)
    at finishClassComponent (react-dom.development.js:14301)
    at updateClassComponent (react-dom.development.js:14264)
    at beginWork (react-dom.development.js:15082)
    at performUnitOfWork (react-dom.development.js:17820)
    at workLoop (react-dom.development.js:17860)
    at renderRoot (react-dom.development.js:17946)
    at performWorkOnRoot (react-dom.development.js:18837)
    at performWork (react-dom.development.js:18749)
    at performSyncWork (react-dom.development.js:18723)
    at requestWork (react-dom.development.js:18592)
    at scheduleWork (react-dom.development.js:18401)
    at Object.enqueueForceUpdate (react-dom.development.js:12352)
    at Query.Component.forceUpdate (react.development.js:390)
    at Query._this.updateCurrentData (react-apollo.browser.umd.js:340)
    at Object.error (react-apollo.browser.umd.js:328)
    at notifySubscription (Observable.js:134)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.error (Observable.js:224)
    at eval (ObservableQuery.js:340)
    at Array.forEach (<anonymous>)
    at Object.error (ObservableQuery.js:340)
    at eval (QueryManager.js:356)
    at eval (QueryManager.js:724)
    at Array.forEach (<anonymous>)
    at eval (QueryManager.js:723)
    at Map.forEach (<anonymous>)
    at QueryManager.broadcastQueries (QueryManager.js:718)
    at Object.next (QueryManager.js:775)
    at notifySubscription (Observable.js:130)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.next (Observable.js:219)
    at eval (dedupLink.js:63)
    at Array.forEach (<anonymous>)
    at Object.next (dedupLink.js:63)
    at notifySubscription (Observable.js:130)
    at onNotify (Observable.js:165)
    at SubscriptionObserver.next (Observable.js:219)
    at eval (httpLink.js:128)

Front-end launch checklist

  • Work over the styles
  • Fancy fonts
  • Filters on an organization page: (backend detroitledger/gnl-graphql#32)
    • name
    • description
    • type
  • Create static pages (about, data & methods, etc)
    • Quick content refresh?
  • Finish News endpoints (b) detroitledger/gnl-graphql#12
  • News component should load news #43
  • Homepage: (j)
  • CSV exports (b) detroitledger/gnl-graphql#19
  • NTEE code pages (client + server)
    • Highcharts or similar nice-looking graphs
  • Add trigger to update materialized view totals (server) detroitledger/gnl-graphql#25
  • Re-add chat support (Olark)
    • Include "report missing or inaccurate data" feature
  • Mailchimp subscription box
  • Pages for individual grants with related grants table #42
  • Redirects for old URLs
  • Add search bar to the top
  • Update IRS data!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.