diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..edfe1bc --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + stage: 0 +} diff --git a/.gitignore b/.gitignore index c055b19..9f2676b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ jspm_packages node_modules +credentials.js diff --git a/cfg/base.js b/cfg/base.js index 74c8a91..e42577a 100644 --- a/cfg/base.js +++ b/cfg/base.js @@ -35,7 +35,7 @@ module.exports = { { test: /\.(js|jsx)$/, include: path.join(__dirname, 'src'), - loader: 'eslint-loader' + loader: 'babel-loader!eslint-loader' } ], loaders: [ @@ -60,7 +60,7 @@ module.exports = { loader: 'style-loader!css-loader!stylus-loader' }, { - test: /\.(png|jpg|gif|woff|woff2)$/, + test: /\.(png|jpg|gif|eot|woff|woff2)/, loader: 'url-loader?limit=8192' } ] diff --git a/package.json b/package.json index 09da43c..726b217 100644 --- a/package.json +++ b/package.json @@ -2,18 +2,18 @@ "name": "hibikeshare", "private": true, "version": "0.0.1", - "description": "YOUR DESCRIPTION - Generated by generator-react-webpack", + "description": "Hi Bikeshare Generated by generator-react-webpack", "main": "", "scripts": { "start": "node server.js --env=dev", "test": "karma start", "posttest": "npm run lint", "serve": "node server.js --env=dev", - "serve:dist": "node server.js --env=dist", - "dist": "npm run copy & webpack --env=dist", - "lint": "eslint ./src", - "copy": "copyfiles -f ./src/index.html ./src/favicon.ico ./dist", - "clean": "rimraf dist/*", + "serve:./public/app/dist": "node server.js --env=./public/app/dist", + "./public/app/dist": "npm run copy & webpack --env=./public/app/dist", + "lint": "eslint ./public/app/src", + "copy": "copyfiles -f ./public/app/src/index.html ./public/app/src/favicon.ico ././public/app/dist", + "clean": "rimraf ./public/app/dist/*", "release:major": "npm version major && npm publish && git push --follow-tags", "release:minor": "npm version minor && npm publish && git push --follow-tags", "release:patch": "npm version patch && npm publish && git push --follow-tags" @@ -52,18 +52,23 @@ "webpack-dev-server": "^1.10.1" }, "dependencies": { - "body-parser": "^1.14.1", - "cookie-parser": "^1.4.0", - "debug": "^2.2.0", - "express": "^4.13.3", - "jade": "^1.11.0", - "leaflet-hoverboard": "^1.1.5", + "d3": "^3.5.6", + "es6-promise": "^3.0.2", + "file-loader": "^0.8.4", + "fynx": "^2.0.0-alpha7", + "immutable": "^3.7.5", + "leaflet": "^0.7.5", + "leaflet-hash": "^0.2.1", "lodash": "^3.10.1", - "morgan": "^1.6.1", + "mapbox-gl": "^0.11.1", "normalize.css": "^3.0.3", - "nunjucks": "^2.1.0", + "omniscient": "^3.3.0", + "pbf": "^1.3.5", + "qs": "^5.1.0", "react": "^0.13.3", + "reqwest-without-xhr2": "^2.0.2", "sass-loader": "^1.0.1", - "serve-favicon": "^2.3.0" + "url-loader": "^0.5.6", + "vector-tile": "^1.1.3" } } diff --git a/public/app/src/actions/README.md b/public/app/src/actions/README.md deleted file mode 100644 index 7267347..0000000 --- a/public/app/src/actions/README.md +++ /dev/null @@ -1,14 +0,0 @@ -# About this folder -This folder will hold all of your **flux** actions if you are using flux. -You can include actions into your components or stores like this: - -```javascript -let react = require('react/addons'); -let MyAction = require('actions/MyAction'); -class MyComponent extends React.Component { - constructor(props) { - super(props); - MyAction.exampleMethod(); - } -} -``` diff --git a/public/app/src/actions/actions.js b/public/app/src/actions/actions.js new file mode 100644 index 0000000..c039476 --- /dev/null +++ b/public/app/src/actions/actions.js @@ -0,0 +1,7 @@ +import {createActions, createAsyncActions} from 'fynx'; + +export default createActions([ + // routeActions.js + 'initRoutes', + 'allRoutes' +]); diff --git a/public/app/src/actions/routeActions.js b/public/app/src/actions/routeActions.js new file mode 100644 index 0000000..b13d2b1 --- /dev/null +++ b/public/app/src/actions/routeActions.js @@ -0,0 +1,36 @@ +import {default as actions} from './actions'; +import qs from 'qs'; +import request from 'reqwest-without-xhr2'; +import routeStore from '../stores/routeStore.js'; +import {Promise} from 'es6-promise'; + +const server = 'http://services.arcgis.com/tNJpAOha4mODLkXz/ArcGIS/rest/services/BikePaths/FeatureServer/0/query'; + +/** + * Fetches routes from api server + */ +actions.initRoutes.listen(() => { + let params = { + where:'1=1', + geometryType:'esriGeometryEnvelope', + spatialRel:'esriSpatialRelIntersects', + units:'esriSRUnit_Meter', + outFields:'*', + returnGeometry:'true', + returnIdsOnly:'false', + returnCountOnly:'false', + returnExtentOnly:'false', + returnDistinctValues:'false', + returnZ:'false', + returnM:'false', + f:'pjson' + } + let url = `${server}?${qs.stringify(params)}`; + request({ + url: url, + type: 'json' + }).then((data) => { + routeStore().set('routes', data.features); + console.log(routeStore().get('routes')); + }); +}); diff --git a/public/app/src/components/Main.js b/public/app/src/components/Main.js index f56c7f8..05b639e 100644 --- a/public/app/src/components/Main.js +++ b/public/app/src/components/Main.js @@ -1,17 +1,37 @@ require('normalize.css'); -require('styles/App.css'); import React from 'react/addons'; +import {default as actions} from '../actions/actions.js'; +import routeActions from '../actions/routeActions.js'; +import store from '../stores/routeStore.js'; +import { + vector_api_key, + mapbox_access_token +} from '../globals/credentials.js'; + +import {mapboxStyles} from '../globals/mapbox.js'; +import {connect} from 'fynx-decorators'; let yeomanImage = require('../images/yeoman.png'); +@connect(store, 'data') class AppComponent extends React.Component { + componentDidMount() { + actions.initRoutes(); + L.mapbox.accessToken = mapbox_access_token; + this.map = new L.mapbox.map('map', 'russellvea2.nl7ij7em', { + center: [21.456597,-157.857164], + zoom: 12 + }) + } + + componentWillUpdate() { + + } + render() { return ( -