A frontend blog-style app that fetches data using the WP REST API.
1 Topic = 1 Commit. Each commit should be attributed to one change.
Never commit half-done work. Commits are made to wrap up something completed, no matter how small the change.
There are two long-term branches - master and develop - that should never be removed. New branches should be merged into develop when complete. Once tested and confirmed to be stable, the develop branch should be merged into master with an updated semantic versioning tag.
Use NPM to bump the version and automatically stage a commit with the new version tag.
npm version [major|minor|patch]
Master contains production-ready code only, and is accessed at parisleaf.com
Develop contains potentially unstable code, and is accessed at staging.parisleaf.com.
These two branches of the frontend are hosted on the same Droplet in Digital Ocean, and deployed via dokku-alt.
Node.js v0.11 (harmony flag enabled)
React.js is rendered server-side and then resumed on the client.
Content is fetched from a REST API endpoint. WP-API generates the JSON data for this endpoint on top of a standard WordPress installation. That project can be found at parisleaf/wp.parisleaf.com.
JavaScript is organized into CommonJS modules and bundled with browserify for the browser.
Routing is handled with react-router. Combined with Browserify and server-side rendering, this enables us to write isomorphic JavaScript. Learn more about isomorphic JavaScript applications.
JavaScript files in src
are compiled with 6to5. This lets us use ES6 features like arrow functions and class syntax in today's JavaScript environments. 6to5 also handles React JSX transformation.
Stylesheets are compiled using the sassc implementation of libsass.
The Dockerfile takes care of installing sassc. You'll probably want to install it on your own machine, too. On OS X: brew install sassc
On Linux, it's a bit more complicated.
- Clone the repository to your development environment
git clone git@github.com:parisleaf/parisleaf.com.git
- Duplicate .env.example and rename it to .env. Open the file and set your environment variables
- Make sure you have XCode developer tools installed
- Switch to the correct version of Node for this project (see package.json)
- Install global NPM packages
npm install -g bower bunyan nodemon svg-sprite
- Install local NPM dependencies
npm install
- Install Bower dependencies
bower install
- Build the application
make build
Running make
again will cause only files with updated dependencies to rebuild.
- Spin up the local dev server.
make watch
This will watch for changes, rebuild, and inject changes in the browser as files are changed. Your site should now be live on your local environment at localhost:3000.
If it's the first build, you can run make fast-build
. This will build the application more quickly, but it won't check for changes — it runs every time. On subsequent builds, use make build
.
In both staging and production, this app is set up to deploy via dokku-alt. Pushing to dokku-alt will automatically build a new container based on whatever git commit you just pushed.
In production, the master
branch is deployed to Travis-CI. Travis will then deploy to dokku-alt if all tests pass:
git push
- Check Travis-CI
In staging, the develop
branch is deployed directly to dokku-alt:
git remote add dokku-staging dokku@parisleaf.com:staging
git push dokku-staging develop:master
Refer to dokku-alt's documentation for more information.
Coming soon.