Skip to content

Kepler.gl is a powerful open source geospatial analysis tool for large-scale data sets.

GitHub browser history (#321)

Giuseppe Macrì27f19a80bca5
diff --git a/README.md b/README.md
index 72f409adb..53e4ae1a8 100644
--- a/README.md
+++ b/README.md
@@ -242,7 +242,7 @@ import KeplerGl from 'kepler.gl';
import {toggleFullScreen, forwardTo} from 'kepler.gl/actions';
import {connect} from 'react-redux';
-Const MapContainer = props => (
+const MapContainer = props => (
<div>
<button onClick={() => props.keplerGlDispatch(toggleFullScreen())}/>
<KeplerGl
@@ -278,7 +278,7 @@ import {toggleFullScreen, wrapTo} from 'kepler.gl/actions';
const wrapToMap = wrapTo('foo');
const MapContainer = ({dispatch}) => (
<div>
- <button onClick=() => dispatch(wrapToMap(toggleFullScreen())/>
+ <button onClick={() => dispatch(wrapToMap(toggleFullScreen())} />
<KeplerGl
id="foo"
/>
@@ -344,6 +344,7 @@ const myCustomHeaderFactory = () => withState(
)(CustomHeader);
```
+
#### 5. How to add data to map
In order to interact with a kepler.gl instance and add new data to it the following methods are available:
- updateVisData
@@ -388,3 +389,5 @@ the latter will be applied and the map view will be moved the defined coordinate
[stack]: https://stackoverflow.com/questions/tagged/kepler.gl
[web]: http://www.kepler.gl/
[vis-academy]: http://vis.academy/#/kepler.gl/
+
+
diff --git a/contributing/DEVELOPERS.md b/contributing/DEVELOPERS.md
index ce6883cea..3e067bdae 100644
--- a/contributing/DEVELOPERS.md
+++ b/contributing/DEVELOPERS.md
@@ -230,6 +230,27 @@ Publish on github pages __Authorized User Only__.
yarn deploy
```
+### <a name="gh-pages"></a> Testing environment using GH Pages
+We currently host the demo-app on Github pages. We have provided a way to test github pages before pushing the branch to
+the actual repo.
+In order to test github pages with your changes, you need to satisfy the following requirements first:
+- Make sure you have your own github pages (username.github.io) repo, [click here](https://pages.github.com/)
+- In your local fork of kepler.gl, add your github pages repo to the list of git remotes by doing:
+
+```bash
+git remote add test [email protected]:<username>/<username>.github.io.git
+```
+
+With the above command, A new origin __test__ will be created, and your own testing copy of gh pages will be push to it.
+
+When everything is set up, run the following command:
+
+```bash
+yarn deploy:test
+```
+
+The above command will build the website and push to your gh-pages branch.
+
[demo-app]: http://kepler.gl/#/demo
[documentationjs]: https://documentation.js.org/
[eslint]: https://eslint.org/
diff --git a/examples/demo-app/src/actions.js b/examples/demo-app/src/actions.js
index 297ad3c63..645229446 100644
--- a/examples/demo-app/src/actions.js
+++ b/examples/demo-app/src/actions.js
@@ -25,10 +25,10 @@ import {loadFiles, toggleModal} from 'kepler.gl/actions';
import {
LOADING_SAMPLE_ERROR_MESSAGE,
LOADING_SAMPLE_LIST_ERROR_MESSAGE,
- MAP_CONFIG_URL
+ MAP_CONFIG_URL, MAP_URI
} from './constants/default-settings';
import {LOADING_METHODS_NAMES} from './constants/default-settings';
-import {AUTH_HANDLERS} from './utils/sharing/authentication';
+import {CLOUD_PROVIDERS} from './utils/cloud-providers';
import {generateHashId} from './utils/strings';
import KeplerGlSchema from 'kepler.gl/schemas';
@@ -42,7 +42,7 @@ export const SET_SAMPLE_LOADING_STATUS = 'SET_SAMPLE_LOADING_STATUS';
// Sharing
export const PUSHING_FILE = 'PUSHING_FILE';
-export const CLOUD_LOGIC_SUCCESS = 'CLOUD_LOGIC_SUCCESS';
+export const CLOUD_LOGIN_SUCCESS = 'CLOUD_LOGIN_SUCCESS';
// ACTIONS
export function initApp() {
@@ -354,7 +354,7 @@ export function setPushingFile(isLoading, metadata) {
* @returns {Function}
*/
export function exportFileToCloud(handlerName = 'dropbox') {
- const authHandler = AUTH_HANDLERS[handlerName];
+ const authHandler = CLOUD_PROVIDERS[handlerName];
return (dispatch, getState) => {
// extract data from kepler
const data = KeplerGlSchema.save(getState().demo.keplerGl.map);
@@ -365,7 +365,7 @@ export function exportFileToCloud(handlerName = 'dropbox') {
// need to perform share as well
.then(
response => {
- dispatch(push(`/map?mapUrl=${response.url}`));
+ dispatch(push(`/${MAP_URI}${response.url}`));
dispatch(setPushingFile(false, {filename: file.name, status: 'success', metadata: response}));
},
error => {
@@ -377,6 +377,6 @@ export function exportFileToCloud(handlerName = 'dropbox') {
export function setCloudLoginSuccess() {
return {
- type: CLOUD_LOGIC_SUCCESS
+ type: CLOUD_LOGIN_SUCCESS
};
}
diff --git a/examples/demo-app/src/components/sharing/cloud-storage.js b/examples/demo-app/src/components/sharing/cloud-storage.js
index cf4b71184..8c22e7e90 100644
--- a/examples/demo-app/src/components/sharing/cloud-storage.js
+++ b/examples/demo-app/src/components/sharing/cloud-storage.js
@@ -25,7 +25,7 @@ import {CopyToClipboard} from 'react-copy-to-clipboard';
import {StyledModalContent} from 'kepler.gl/components';
import CloudTile from './cloud-tile';
import StatusPanel from './status-panel';
-import {AUTH_HANDLERS} from '../../utils/sharing/authentication';
+import {CLOUD_PROVIDERS} from '../../utils/cloud-providers';
import {KEPLER_DISCLAIMER} from '../../constants/default-settings';
import {getMapPermalink} from '../../utils/url';
@@ -139,13 +139,13 @@ const ExportCloudModal = ({
</div>
</div>
<div className="selection">
- {Object.keys(AUTH_HANDLERS).map((name, index) => (
+ {Object.keys(CLOUD_PROVIDERS).map((name, index) => (
<CloudTile
key={index}
- token={AUTH_HANDLERS[name].getAccessToken()}
+ token={CLOUD_PROVIDERS[name].getAccessToken()}
onExport={onExport}
- onLogin={() => AUTH_HANDLERS[name].handleLogin(onCloudLoginSuccess)}
- Icon={AUTH_HANDLERS[name].icon}
+ onLogin={() => CLOUD_PROVIDERS[name].handleLogin(onCloudLoginSuccess)}
+ Icon={CLOUD_PROVIDERS[name].icon}
/>
))}
</div>
diff --git a/examples/demo-app/src/constants/default-settings.js b/examples/demo-app/src/constants/default-settings.js
index 7e06879bc..e0663bd7d 100644
--- a/examples/demo-app/src/constants/default-settings.js
+++ b/examples/demo-app/src/constants/default-settings.js
@@ -24,7 +24,7 @@ import keyMirror from 'keymirror';
export const ASSETS_URL = 'https://d1a3f4spazzrp4.cloudfront.net/kepler.gl/';
export const DATA_URL = 'https://raw.githubusercontent.com/uber-web/kepler.gl-data/master/';
-export const MAP_URI = 'map?mapUrl=';
+export const MAP_URI = 'demo/map?mapUrl=';
/*
* If you want to add more samples, feel free to edit the json file on github kepler.gl data repo
*/
@@ -97,3 +97,5 @@ export const CORS_LINK = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
export const KEPLER_DISCLAIMER = '* Kepler.gl will save your map data to your personal cloud storage, only people with the URL can access your map and data.';
export const DEFAULT_LOADING_METHOD = LOADING_METHODS[0];
+
+export const DEFAULT_CLOUD_PROVIDER = 'dropbox';
diff --git a/examples/demo-app/src/main.js b/examples/demo-app/src/main.js
index 36dafdc44..f482fb9d2 100644
--- a/examples/demo-app/src/main.js
+++ b/examples/demo-app/src/main.js
@@ -26,33 +26,18 @@ import {syncHistoryWithStore} from 'react-router-redux';
import {render} from 'react-dom';
import store from './store';
import App from './app';
-import { AUTH_HANDLERS } from "./utils/sharing/authentication";
+import {buildAppRoutes} from './utils/routes';
const history = syncHistoryWithStore(browserHistory, store);
-const onEnterCallback = (nextState, transition, callback) => {
- // TODO: detect auth provider
- const defaultProvider = 'dropbox';
- const authProvider = AUTH_HANDLERS[defaultProvider];
-
- // Check if the current tab was opened by our previous tab
- if (window.opener) {
- const { location } = nextState;
- const token = authProvider.getAccessTokenFromLocation(location);
- window.opener.postMessage({token}, location.origin);
- }
-
- callback();
-};
+const appRoute = buildAppRoutes(App);
const Root = () => (
<Provider store={store}>
<Router history={history}>
- <Route path="/auth" component={App} onEnter={onEnterCallback} />
- <Route path="/demo/(:id)" component={App} />
- <Route path="/map" component={App} />
- <Route path="/" component={App} />
- <Route path="*" component={App} />
+ <Route path="/" component={App}>
+ {appRoute}
+ </Route>
</Router>
</Provider>
);
diff --git a/examples/demo-app/src/reducers/sharing.js b/examples/demo-app/src/reducers/sharing.js
index 2f604e379..4613db490 100644
--- a/examples/demo-app/src/reducers/sharing.js
+++ b/examples/demo-app/src/reducers/sharing.js
@@ -19,13 +19,13 @@
// THE SOFTWARE.
import {handleActions} from 'redux-actions';
-import { AUTH_HANDLERS } from '../utils/sharing/authentication';
-import { CLOUD_LOGIC_SUCCESS, LOAD_REMOTE_RESOURCE_ERROR, PUSHING_FILE } from '../actions';
+import {CLOUD_PROVIDERS} from '../utils/cloud-providers';
+import {CLOUD_LOGIN_SUCCESS, LOAD_REMOTE_RESOURCE_ERROR, PUSHING_FILE} from '../actions';
-const readAuthTokens = () => Object.keys(AUTH_HANDLERS)
+const readAuthTokens = () => Object.keys(CLOUD_PROVIDERS)
.reduce((tokens, name) => ({
...tokens,
- [name]: AUTH_HANDLERS[name].getAccessToken()
+ [name]: CLOUD_PROVIDERS[name].getAccessToken()
}), {});
const sharingInitialState = {
@@ -48,7 +48,7 @@ export const sharingReducer = handleActions({
isLoading: action.isLoading,
info: action.metadata
}),
- [CLOUD_LOGIC_SUCCESS]: state => ({
+ [CLOUD_LOGIN_SUCCESS]: state => ({
...state,
tokens: readAuthTokens()
})
diff --git a/examples/demo-app/src/utils/sharing/dropbox.js b/examples/demo-app/src/utils/cloud-providers/dropbox.js
similarity index 97%
rename from examples/demo-app/src/utils/sharing/dropbox.js
rename to examples/demo-app/src/utils/cloud-providers/dropbox.js
index 109c26896..2919b353a 100644
--- a/examples/demo-app/src/utils/sharing/dropbox.js
+++ b/examples/demo-app/src/utils/cloud-providers/dropbox.js
@@ -92,7 +92,7 @@ function shareFile(metadata) {
}
/**
- * Override dropbox sharing url
+ * Override dropbox cloud-providers url
* https://www.dropbox.com/s/bxwwdb81z0jg7pb/keplergl_2018-11-01T23%3A22%3A43.940Z.json?dl=0
* ->
* https://dl.dropboxusercontent.com/s/bxwwdb81z0jg7pb/keplergl_2018-11-01T23%3A22%3A43.940Z.json
@@ -147,7 +147,7 @@ function getAccessToken() {
return (token || '') !== '' ? token : null;
}
-// All sharing providers must implement the following properties
+// All cloud-providers providers must implement the following properties
export default {
name: NAME,
getAccessTokenFromLocation,
diff --git a/examples/demo-app/src/utils/sharing/authentication.js b/examples/demo-app/src/utils/cloud-providers/index.js
similarity index 97%
rename from examples/demo-app/src/utils/sharing/authentication.js
rename to examples/demo-app/src/utils/cloud-providers/index.js
index 0f96c9c8c..202ce532d 100644
--- a/examples/demo-app/src/utils/sharing/authentication.js
+++ b/examples/demo-app/src/utils/cloud-providers/index.js
@@ -20,6 +20,6 @@
import DropboxHandler from './dropbox';
-export const AUTH_HANDLERS = {
+export const CLOUD_PROVIDERS = {
[DropboxHandler.name]: DropboxHandler
};
diff --git a/examples/demo-app/src/utils/routes.js b/examples/demo-app/src/utils/routes.js
new file mode 100644
index 000000000..0d6c1d675
--- /dev/null
+++ b/examples/demo-app/src/utils/routes.js
@@ -0,0 +1,52 @@
+// Copyright (c) 2019 Uber Technologies, Inc.
+//
+// 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.
+
+import {CLOUD_PROVIDERS} from './cloud-providers';
+import {IndexRoute, Route} from 'react-router';
+import React from 'react';
+import Demo from '../app';
+import {DEFAULT_CLOUD_PROVIDER} from '../constants/default-settings';
+
+export function onAuthEnterCallback(nextState, replace, callback) {
+ // TODO: detect auth provider
+ const authProvider = CLOUD_PROVIDERS[DEFAULT_CLOUD_PROVIDER];
+
+ // Check if the current tab was opened by our previous tab
+ if (window.opener) {
+ const {location} = nextState;
+ const token = authProvider.getAccessTokenFromLocation(location);
+ window.opener.postMessage({token}, location.origin);
+ }
+
+ callback();
+}
+
+export function buildAppRoutes(Component) {
+ return [
+ (<Route key="auth" path="auth" component={Demo} onEnter={onAuthEnterCallback} />),
+ (
+ <Route key="demo" path="demo">
+ <IndexRoute component={Component} />
+ <Route path="map" component={Component} />
+ <Route path="(:id)" component={Component} />
+ </Route>
+ )
+ ];
+}
diff --git a/examples/demo-app/src/utils/url.js b/examples/demo-app/src/utils/url.js
index c97129598..b8c31c31b 100644
--- a/examples/demo-app/src/utils/url.js
+++ b/examples/demo-app/src/utils/url.js
@@ -22,19 +22,18 @@ import {MAP_URI} from '../constants/default-settings';
export function parseQueryString(query) {
const searchParams = new URLSearchParams(query);
- const params = [...searchParams].reduce((queryParams, entry) => ({
- ...queryParams,
- ...(entry && entry.length === 2 ?
- {[entry[0]]: entry[1]} : null
- )
- }), {});
+ const params = {};
+ for (const p of searchParams) {
+ if (p && p.length === 2 && p[0])
+ params[p[0]] = p[1]
+ }
return params;
}
/**
* Returns a permalink with the given map url: kepler.gl/[]
- * @param mapLink the sharing url used to store the map
+ * @param mapLink the cloud-providers url used to store the map
* @returns {string}
*/
export function getMapPermalink(mapLink) {
diff --git a/examples/demo-app/webpack.config.js b/examples/demo-app/webpack.config.js
index a8bb9612b..cc2fc44a3 100644
--- a/examples/demo-app/webpack.config.js
+++ b/examples/demo-app/webpack.config.js
@@ -62,7 +62,7 @@ const CONFIG = {
// to support browser history api and remove the '#' sign
devServer: {
- historyApiFallback: true,
+ historyApiFallback: true
},
// Optional: Enables reading mapbox token from environment variable
diff --git a/package.json b/package.json
index 41714ecb1..322e91ff1 100644
--- a/package.json
+++ b/package.json
@@ -23,7 +23,8 @@
"url": "https://github.com/uber/kepler.gl.git"
},
"scripts": {
- "install:example": "cd examples/demo-app && npm i",
+ "install:example": "cd examples/demo-app && yarn --ignore-engines",
+ "install:web": "yarn install:example && cd website && yarn --ignore-engines",
"install-and-start": "node ./scripts/install-and-start",
"fast-test": "npm run test-node && npm run test-browser",
"test-browser": "NODE_ENV=test babel-tape-runner -r ./test/setup-browser-env.js ./test/browser.js",
@@ -34,13 +35,15 @@
"start:custom-layer": "npm run install-and-start -- examples/custom-layer start-local",
"start:open-modal": "npm run install-and-start -- examples/open-modal start-local",
"start:custom-reducer": "npm run install-and-start -- examples/custom-reducer start-local",
+ "start:web": "cd website && yarn start",
"build": "rm -fr dist && uber-licence && babel src --out-dir dist --plugins=transform-es2015-modules-commonjs --source-maps inline",
"lint": "eslint src examples/**/src website/src",
"check-licence": "uber-licence --dry",
"add-licence": "uber-licence",
"prepublish": "uber-licence && npm run build",
- "web": "(npm run install:example && cd website && yarn --ignore-engines && yarn start)",
- "deploy": "(cd website && yarn build && git checkout gh-pages && cp dist/* .. && git add .. && git commit -m 'Update website' && git push origin gh-pages && git checkout master)",
+ "web": "(yarn && yarn install:web && yarn start:web)",
+ "deploy": "yarn clean && yarn && yarn install:web && (cd website && yarn build && git checkout gh-pages && cp dist/* .. && git add .. && git commit -m 'Update website' && git push origin gh-pages && git checkout master)",
+ "deploy:test": "yarn clean && yarn && yarn install:web && (cd website && yarn build && git checkout -B gh-pages-test gh-pages && cp dist/* .. && git add .. && git commit -m 'Update website' && git push -f test gh-pages-test:master)",
"clean": "rm -rf node_modules examples/demo-app/node_modules website/node_modules"
},
"files": [
diff --git a/schemas.js b/schemas.js
index 374972190..574e93de6 100644
--- a/schemas.js
+++ b/schemas.js
@@ -18,4 +18,4 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
-module.exports = require('./dist/schemas');
\ No newline at end of file
+module.exports = require('./dist/schemas');
diff --git a/src/actions/actions.js b/src/actions/actions.js
index 0be81ba17..7239ce5ad 100644
--- a/src/actions/actions.js
+++ b/src/actions/actions.js
@@ -98,7 +98,7 @@ export * from './identity-actions';
*/
export const addDataToMap = createAction(
ActionTypes.ADD_DATA_TO_MAP,
- (datasets, options, config) => ({datasets, options, config})
+ data => data
);
/**
diff --git a/src/components/injector.js b/src/components/injector.js
index 305e1a022..1c5a6ea7f 100644
--- a/src/components/injector.js
+++ b/src/components/injector.js
@@ -95,4 +95,4 @@ export function withState(lenses, mapStateToProps = identity, actions = {}) {
}
}
-// Helpter to add actionCreator to custom component
\ No newline at end of file
+// Helpter to add actionCreator to custom component
diff --git a/src/components/modals/export-image-modal.js b/src/components/modals/export-image-modal.js
index e02bbcf0a..fbe6e4efb 100644
--- a/src/components/modals/export-image-modal.js
+++ b/src/components/modals/export-image-modal.js
@@ -152,7 +152,7 @@ class ExportImageModal extends Component {
<div className="image-option-section-title">Ratio</div>
Choose the ratio for various usages.
<div className="button-list">
- {RATIO_OPTIONS.map(op =>
+ {RATIO_OPTIONS.map(op =>
<Button
key={op.id}
selected={ratio === op.id}
@@ -167,7 +167,7 @@ class ExportImageModal extends Component {
<div className="image-option-section-title">Resolution</div>
High resolution is better for prints.
<div className="button-list">
- {RESOLUTION_OPTIONS.map(op =>
+ {RESOLUTION_OPTIONS.map(op =>
<Button
key={op.id}
selected={resolution === op.id}
@@ -199,7 +199,7 @@ class ExportImageModal extends Component {
</StyledModalContent>
</div>
);
- }
+ }
}
const ExportImageModalFactory = () => ExportImageModal;
diff --git a/src/components/side-panel/map-manager.js b/src/components/side-panel/map-manager.js
index f812db4cd..99f499a9b 100644
--- a/src/components/side-panel/map-manager.js
+++ b/src/components/side-panel/map-manager.js
@@ -62,7 +62,7 @@ function MapManagerFactory(MapStyleSelector, LayerGroupSelector) {
render() {
const {mapStyle} = this.props;
- const editableLayers = DEFAULT_LAYER_GROUPS.map(lg =>
+ const editableLayers = DEFAULT_LAYER_GROUPS.map(lg =>
lg.slug
);
diff --git a/src/constants/default-settings.js b/src/constants/default-settings.js
index 87674e0db..04964d8dd 100644
--- a/src/constants/default-settings.js
+++ b/src/constants/default-settings.js
@@ -43,7 +43,7 @@ import {
export const KEPLER_GL_NAME = 'kepler.gl';
export const KEPLER_GL_VERSION = 'v1.0';
-export const KEPLER_GL_WEBSITE = 'http://kepler.gl/#/';
+export const KEPLER_GL_WEBSITE = 'http://kepler.gl/';
export const DIMENSIONS = {
sidePanel: {
diff --git a/src/reducers/map-style-updaters.js b/src/reducers/map-style-updaters.js
index 6c9dd21db..5472bdf1f 100644
--- a/src/reducers/map-style-updaters.js
+++ b/src/reducers/map-style-updaters.js
@@ -120,7 +120,7 @@ function getMapStyles({
function get3DBuildingColor(style) {
// set building color to be the same as the background color.
const backgroundLayer = (style.style.layers || []).find(({id}) => id === 'background');
- const buildingColor = backgroundLayer && backgroundLayer.paint && backgroundLayer.paint['background-color'] ?
+ const buildingColor = backgroundLayer && backgroundLayer.paint && backgroundLayer.paint['background-color'] ?
backgroundLayer.paint['background-color'] : DEFAULT_BLDG_COLOR;
// brighten or darken building based on style
const operation = style.id.match(/(?=(dark|night))/) ? 'brighter': 'darker';
diff --git a/src/schemas/index.js b/src/schemas/index.js
index 814ddd8fd..f6b83d259 100644
--- a/src/schemas/index.js
+++ b/src/schemas/index.js
@@ -20,4 +20,4 @@
// Schemas
export {default as default, default as KeplerGlSchema} from './schema-manager';
-export {CURRENT_VERSION, VERSIONS} from './versions';
\ No newline at end of file
+export {CURRENT_VERSION, VERSIONS} from './versions';
diff --git a/test/fixtures/state-saved-v1-2.js b/test/fixtures/state-saved-v1-2.js
index b07b845a5..37948e0df 100644
--- a/test/fixtures/state-saved-v1-2.js
+++ b/test/fixtures/state-saved-v1-2.js
@@ -5051,4 +5051,4 @@ export const v1expectedFields_2 = [
{name: 'start_ts', type: 'timestamp', format: 'x'},
{name: 'end_ts', type: 'timestamp', format: 'x'},
{name: 'time string', type: 'timestamp', format: 'YYYY/M/D H:m'}
-];
\ No newline at end of file
+];
diff --git a/test/node.js b/test/node.js
index 58697698e..15dd60304 100644
--- a/test/node.js
+++ b/test/node.js
@@ -19,4 +19,4 @@
// THE SOFTWARE.
// Run the tests
-require('./node/index.js');
\ No newline at end of file
+require('./node/index.js');
diff --git a/website/package.json b/website/package.json
index 06eb5b2f4..16d5e01b1 100644
--- a/website/package.json
+++ b/website/package.json
@@ -40,6 +40,11 @@
"babel-core": "^6.25.0",
"babel-eslint": "6.1.0",
"babel-loader": "^7.1.1",
+ "babel-plugin-module-resolver": "^3.0.0",
+ "babel-plugin-transform-builtin-extend": "^1.1.0",
+ "babel-plugin-transform-decorators-legacy": "^1.3.4",
+ "babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
+ "babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
diff --git a/website/src/components/examples.js b/website/src/components/examples.js
index f4348a10f..9b326e057 100644
--- a/website/src/components/examples.js
+++ b/website/src/components/examples.js
@@ -26,6 +26,7 @@ import {media} from '../styles';
import StaggeredScrollAnimation from './common/staggered-scroll-animation';
import {VerticalCard} from './common/card';
import {LinkButton, CenteredContent} from './common/styled-components';
+import {DEMO_LINK} from '../constants';
const CardsContainer = styled.div`
display: flex;
@@ -75,7 +76,7 @@ class Examples extends PureComponent {
))}
</StaggeredScrollAnimation>
<CenteredContent>
- <LinkButton outline large href="#/demo">
+ <LinkButton outline large href={DEMO_LINK}>
See More
</LinkButton>
</CenteredContent>
diff --git a/website/src/components/footer.js b/website/src/components/footer.js
index 4eb262b69..0e3bb603c 100644
--- a/website/src/components/footer.js
+++ b/website/src/components/footer.js
@@ -31,6 +31,7 @@ import {cdnUrl} from '../utils';
import {LinkButton} from './common/styled-components';
import {media} from '../styles';
import MapboxLogo from './mapbox-logo';
+import {DEMO_LINK} from '../constants';
const Container = styled.div`
background: #242730;
@@ -165,7 +166,7 @@ export default class Footer extends PureComponent {
</LogosContainer>
<ButtonSection>
<ButtonContainer>
- <LinkButton large href="#/demo">
+ <LinkButton large href={DEMO_LINK}>
Get Started
</LinkButton>
<LinkButton
diff --git a/website/src/components/hero.js b/website/src/components/hero.js
index 85de06411..272b3c22b 100644
--- a/website/src/components/hero.js
+++ b/website/src/components/hero.js
@@ -27,6 +27,7 @@ import {media, breakPoints} from '../styles';
import {HERO_IMAGES, HERO_IMAGES_SCALED} from '../content';
import SlideShow from './common/slideshow';
import {LinkButton} from './common/styled-components';
+import {DEMO_LINK} from '../constants';
const SlideShowAnimation = keyframes`
0% {
@@ -199,7 +200,7 @@ export default class Hero extends PureComponent {
<span>data sets.</span>
</div>
<ButtonContainer>
- <LinkButton large href="#/demo">
+ <LinkButton large href={DEMO_LINK}>
Get Started
</LinkButton>
<LinkButton
diff --git a/website/src/constants.js b/website/src/constants.js
index b3aefdc68..c25efa2fc 100644
--- a/website/src/constants.js
+++ b/website/src/constants.js
@@ -21,3 +21,4 @@
export const CLOUDFRONT = 'https://d1a3f4spazzrp4.cloudfront.net';
export const KEPLER_GL_BUCKET = 'kepler.gl';
export const WEBSITE_ASSET_FOLDER = 'website';
+export const DEMO_LINK = '/demo';
diff --git a/website/src/reducers/index.js b/website/src/reducers/index.js
index d8c8b43dd..489cc32c5 100644
--- a/website/src/reducers/index.js
+++ b/website/src/reducers/index.js
@@ -23,7 +23,7 @@ import {routerReducer} from 'react-router-redux';
import {taskMiddleware} from 'react-palm/tasks';
import thunk from 'redux-thunk';
import {routerMiddleware} from 'react-router-redux';
-import {hashHistory} from 'react-router';
+import {browserHistory} from 'react-router';
import appReducer from './app';
import demoReducer from '../../../examples/demo-app/src/reducers';
import analyticsMiddleware from './analytics';
@@ -40,17 +40,18 @@ const combinedReducers = combineReducers(reducers);
export const middlewares = [
taskMiddleware,
thunk,
- routerMiddleware(hashHistory),
+ routerMiddleware(browserHistory),
analyticsMiddleware
];
export const enhancers = [applyMiddleware(...middlewares)];
+const composeEnhancers = compose;
// add redux devtools
// const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
export default createStore(
combinedReducers,
initialState,
- compose(...enhancers)
+ composeEnhancers(...enhancers)
);
diff --git a/website/src/routes.js b/website/src/routes.js
index ce1e1c382..8ddf29e93 100644
--- a/website/src/routes.js
+++ b/website/src/routes.js
@@ -19,14 +19,16 @@
// THE SOFTWARE.
import React from 'react';
-import {Router, Route, IndexRoute, hashHistory} from 'react-router';
+import {Router, Route, IndexRoute, browserHistory} from 'react-router';
import {syncHistoryWithStore} from 'react-router-redux';
import window from 'global/window';
import store from './reducers';
-
import Home from './components/home';
import App from './components/app';
import Demo from '../../examples/demo-app/src/app';
+import {buildAppRoutes} from '../../examples/demo-app/src/utils/routes';
+
+const appRoute = buildAppRoutes(Demo);
const trackPageChange = (location) => {
const links = location.split('/');
@@ -39,19 +41,35 @@ const trackPageChange = (location) => {
})
}
};
-const history = syncHistoryWithStore(hashHistory, store);
+
+const history = syncHistoryWithStore(browserHistory, store);
history.listen(location => {
if (location.action === 'POP') {
trackPageChange(location.pathname);
}
});
+function isOldUrl(location) {
+ return Boolean(location.pathname === '/' && location.hash && location.hash.startsWith('#/demo'))
+}
+
+function onEnter(nextState, replace, callback) {
+ /**
+ * For backward compatibility, when we see a url path starting with '#/demo/...'
+ * we redirect to '/demo/.../
+ **/
+ if (isOldUrl(nextState.location)) {
+ replace(location.hash.substring(1))
+ }
+ callback();
+}
+
// eslint-disable-next-line react/display-name
export default () => (
- <Router history={syncHistoryWithStore(hashHistory, store)}>
- <Route path="/" component={App}>
- <IndexRoute component={Home} />
- <Route path="demo(/:id)" component={Demo}/>
+ <Router history={history}>
+ <Route path="/" component={App} onEnter={onEnter}>
+ <IndexRoute component={Home} onEnter={onEnter} />
+ {appRoute}
</Route>
</Router>
);
diff --git a/website/src/static/index.html b/website/src/static/index.html
index d17796488..90809f5f3 100644
--- a/website/src/static/index.html
+++ b/website/src/static/index.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Kepler.gl is a data agnostic, WebGL empowered, high-performance web application for geospatial analytic visualizations.">
<title>kepler.gl</title>
- <link rel="shortcut icon" href="favicon.png">
+ <link rel="shortcut icon" href="/favicon.png">
<link rel="stylesheet" id="font-link" href="//d1a3f4spazzrp4.cloudfront.net/uber-fonts/3.1.0/refresh.css">
<link href="//api.tiles.mapbox.com/mapbox-gl-js/v0.42.0/mapbox-gl.css" rel="stylesheet">
@@ -44,6 +44,6 @@
</style>
</head>
<body>
- <script src='bundle.js'></script>
+ <script src="/bundle.js"></script>
</body>
</html>
diff --git a/website/webpack.config.js b/website/webpack.config.js
index 1c4b36746..9bcdac4a0 100644
--- a/website/webpack.config.js
+++ b/website/webpack.config.js
@@ -87,6 +87,11 @@ const COMMON_CONFIG = {
fs: 'empty'
},
+ // to support browser history api and remove the '#' sign
+ devServer: {
+ historyApiFallback: true
+ },
+
// Optional: Enables reading mapbox token from environment variable
plugins: [
new webpack.EnvironmentPlugin(['MapboxAccessToken', 'DropboxClientId'])
@@ -142,7 +147,7 @@ module.exports = env => {
if (!process.env.MapboxAccessToken) {
logError('Error! MapboxAccessToken is not defined');
logInstruction(`Make sure to run "export MapboxAccessToken=<token>" before deploy the website`);
- logInstruction('You can get the token at http://t.uber.com/kepler.gl-token');
+ logInstruction('You can get the token at https://www.mapbox.com/help/how-access-tokens-work/');
throw new Error('Missing Mapbox Access token');
}
config = addProdConfig(config);