Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: faceyspacey/redux-first-router-demo
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: hedgepigdaniel/gnomocracy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Can’t automatically merge. Don’t worry, you can still create the pull request.

Commits on Sep 18, 2017

  1. Simplify README

    hedgepigdaniel committed Sep 18, 2017
    Copy the full SHA
    b4bb6ec View commit details
  2. Copy the full SHA
    4a9a438 View commit details
  3. Update yarn

    hedgepigdaniel committed Sep 18, 2017
    Copy the full SHA
    fe8dcde View commit details
  4. Remove screenshot

    hedgepigdaniel committed Sep 18, 2017
    Copy the full SHA
    4b3c822 View commit details
  5. Copy the full SHA
    ec2d810 View commit details
  6. Copy the full SHA
    90412ab View commit details
  7. Copy the full SHA
    e7f7e94 View commit details

Commits on Sep 26, 2017

  1. Add web3

    hedgepigdaniel committed Sep 26, 2017
    Copy the full SHA
    e92a786 View commit details
  2. Copy the full SHA
    d258672 View commit details
  3. Copy the full SHA
    4de05ad View commit details
  4. Copy the full SHA
    48a6cab View commit details

Commits on Sep 29, 2017

  1. WIP - Added inital files for decision making UI

    anish authored and anish committed Sep 29, 2017
    Copy the full SHA
    f3ef709 View commit details

Commits on Sep 30, 2017

  1. Merge pull request #2 from hedgepigdaniel/decision-making

    WIP - Added inital files for decision making UI
    hedgepigdaniel authored Sep 30, 2017
    Copy the full SHA
    41e52dc View commit details

Commits on Oct 2, 2017

  1. Copy the full SHA
    e2234a8 View commit details
  2. Copy the full SHA
    aabed5a View commit details
  3. Copy the full SHA
    1f11e0e View commit details

Commits on Oct 9, 2017

  1. Addding gnome logo

    anish authored and anish committed Oct 9, 2017
    Copy the full SHA
    739620e View commit details

Commits on Oct 10, 2017

  1. Copy the full SHA
    4129a66 View commit details
  2. Add issues page

    hedgepigdaniel committed Oct 10, 2017
    Copy the full SHA
    599f2fe View commit details
  3. Merge pull request #4 from hedgepigdaniel/meetings

    Add sidebar item for meetings, and page titles
    hedgepigdaniel authored Oct 10, 2017
    Copy the full SHA
    4430bea View commit details

Commits on Oct 13, 2017

  1. Copy the full SHA
    7af5c36 View commit details
  2. Merge pull request #3 from hedgepigdaniel/web3-1.0

    Upgrade web3 to 1.0
    hedgepigdaniel authored Oct 13, 2017
    Copy the full SHA
    e7c14bd View commit details
  3. Update package-lock

    hedgepigdaniel committed Oct 13, 2017
    Copy the full SHA
    33166c0 View commit details
  4. Cleanup

    AnishGopalan84 committed Oct 13, 2017
    Copy the full SHA
    5aef65f View commit details
  5. Adding css

    AnishGopalan84 committed Oct 13, 2017
    Copy the full SHA
    dbd75fa View commit details
  6. Merge pull request #5 from hedgepigdaniel/cleanup

    Cleanup
    gnuman authored Oct 13, 2017
    Copy the full SHA
    ecfe9d0 View commit details
  7. Copy the full SHA
    5a06930 View commit details
  8. Copy the full SHA
    7846ef8 View commit details
  9. Copy the full SHA
    0e32073 View commit details
  10. Copy the full SHA
    ad815b1 View commit details
  11. Copy the full SHA
    4c6ad1a View commit details
  12. Copy the full SHA
    5068c24 View commit details
  13. Copy the full SHA
    4004350 View commit details
12 changes: 2 additions & 10 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ module.exports = {
'react/prop-types': 0,
'react/no-render-return-value': 0,
'no-confusing-arrow': 0,
'no-else-return': 0,
'no-underscore-dangle': 0,
'no-plusplus': 0,
camelcase: 1,
@@ -93,16 +94,7 @@ module.exports = {
peerDependencies: true
}
],
'comma-dangle': [
2,
{
arrays: 'never',
objects: 'never',
imports: 'never',
exports: 'never',
functions: 'never'
}
],
'comma-dangle': [2, 'always-multiline'],
'max-len': [
'error',
{
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{

// Configure glob patterns for excluding files and folders.
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"buildClient/**": true
},
"window.zoomLevel": 1
}
2 changes: 2 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
MIT License

Copyright (c) 2017 James Gillmore <james@faceyspacey.com>
Copyright (c) 2017 Daniel Playfair Cal <daniel.playfair.cal@gmail.com>
Copyright (c) 2017 Anish Patil <anish.developer@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
53 changes: 2 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,57 +1,8 @@
<a href="https://codesandbox.io/s/github/faceyspacey/redux-first-router-codesandbox" target="_blank">
<img alt="Edit Redux-First Router Demo" src="https://codesandbox.io/static/img/play-codesandbox.svg">
</a>


# Universal Demonstration of [Redux-First Router](https://github.com/faceyspacey/redux-first-router)

This demo specializes in SSR and the sort of things like redirecting and authentication you will do on the server. For the simpler example that's easier to start with, check out the [Redux-First Router Boilerplate](https://github.com/faceyspacey/redux-first-router-boilerplate).



![redux-first-router-demo screenshot](./screenshot.png)

## Installation

```
git clone https://github.com/faceyspacey/redux-first-router-demo
cd redux-first-router-demo
git clone https://github.com/hedgepigdaniel/gnomocracy
cd gnomocracy
yarn
yarn start
```


## Files You Should Look At:

*universal code:*
- [***src/routesMap.js***](./src/routesMap.js) - *(observe thunks and `onBeforeChange`)*
- [***src/utils.js***](./src/utils.js) - *(check `isAllowed` function)*

*client code:*
- [***src/configureStore.js***](./src/configureStore.js) - *(nothing new here)*
- [***src/components/Switcher.js***](./src/components/Switcher.js) - *(universal component concept)*
- [***src/components/UniversalComponent.js***](./src/components/UniversalComponent.js) - ***(universal component concept continued...)***
- [***src/components/Sidebar.js***](./src/components/Sidebar.js) - *(look at the different ways to link + dispatch URL-aware actions)*
- [***src/reducers/index.js***](./src/reducers/index.js) - *(observe simplicity of the `page` reducer. Also be cognizant of non-route action types)*


*server code:*
- [***server/index.js***](./server/index.js) - *(built-in ajax API + fake cookie handling)*
- [***server/render.js***](./server/render.js) - *(super simple thanks to [webpack-flush-chunks](https://github.com/faceyspacey/webpack-flush-chunks))*
- [***server/configureStore.js***](./server/configureStore.js) - ***(this is the gem of the repo -- observe how to filter authentication)***

## Notes
I comment throughout the code various things you can try. Look out for comments starting with *"TRY:"* and *"TASK:"*.

For example, there are simple values like the `jwToken` you can toggle to get access to the restricted *admin* area. That showcases a key feature: ***authentication filtering.***

In general, this Demo is all about SSR. It shows how to use the `onBeforeChange` to properly authenticate user's and routes using *JSON Web Tokens*. And of course data-fetching via `thunks` is central to it all. **There's even a real API.**

Lastly, the [***server/configureStore.js***](./server/configureStore.js) file is the absolute most important file of the demo. It essentially brings your ***routing-aware Redux store*** full circle by bringing it server-side in a dead simple yet flexible manner. It works in combination with [***src/routesMap.js***](./src/routesMap.js). Study those and your redux routing dreams have come true 😀

> As a bonus, it comes with code-splitting thanks to [react-universal-component](https://github.com/faceyspacey/react-universal-component). This setup makes splitting stupid-easy. In the future, ***routing-aware pre-fetching*** will be added to the mix, so the users never know you're only serving partial parts of your app 🚀

## TO DO

- auth0-based signup/login that replaces current fake cookie/JWToken setup *(PR welcome)*
Loading