Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion public/_redirects

This file was deleted.

22 changes: 22 additions & 0 deletions public/cn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<meta
name="description"
content="Great Circle Map displays the shortest
route between airports and calculates the distance. It draws geodesic flight
paths on top of Google maps, so you can create your own route map."
/>
<title>Great Circle Map</title>
</head>
<body>
<div id="app"></div>
<script>
window.COUNTRY = 'cn';
</script>
<script src="/bundle.js"></script>
</body>
</html>
10 changes: 10 additions & 0 deletions public/netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[[redirects]]
from = "/*"
to = "/cn.html"
status = 200
force = false
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
force = false
51 changes: 27 additions & 24 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
const path = require("path")
const express = require("express")
const favicon = require("serve-favicon")
const cookieParser = require("cookie-parser")
const bodyParser = require("body-parser")
const session = require("express-session")
const compression = require("compression")
const path = require('path');
const express = require('express');
const favicon = require('serve-favicon');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const session = require('express-session');
const compression = require('compression');

const port = process.env.PORT || "3000"
const app = express()
const port = process.env.PORT || '3000';
const app = express();

app.use(compression())
app.use(favicon(path.join(__dirname, "public", "favicon.ico")))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(session({ // REMOVE IF NOT NEEDED
secret: "What is this secret for??", // CHANGE!
resave: false,
saveUninitialized: false
}))
app.use(compression());
app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(
session({
// REMOVE IF NOT NEEDED
secret: 'What is this secret for??', // CHANGE!
resave: false,
saveUninitialized: false
})
);

app.use(express.static(path.join(__dirname, "public")))
app.use(express.static(path.join(__dirname, 'public')));

app.get("*", (req, res) => {
res.sendFile(path.join(__dirname, "public", "index.html"))
})
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});

/* eslint-disable no-console */
app.listen(port, () => console.log(`Server listening on port ${port}`))
app.listen(port, () => console.log(`Server listening on port ${port}`));
/* eslint-enable no-console */
21 changes: 17 additions & 4 deletions src/components/GoogleMapWrapper.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { getRoutes, getAirports, getSectors, getBrighterColor } from '../selectors';
import { getAirports, getBrighterColor, getRoutes, getSectors } from '../selectors';
import GoogleMap from './GoogleMap';

class GoogleMapWrapper extends Component {
Expand Down Expand Up @@ -46,10 +46,21 @@ class GoogleMapWrapper extends Component {
}

render() {
const { routes, airports, sectors, mapType, label, routeColor, pointColor, map } = this.props;
const {
routes,
airports,
sectors,
mapType,
label,
routeColor,
pointColor,
map,
country
} = this.props;
const rootUrl = country === 'cn' ? 'http://maps.google.cn' : 'https://maps.googleapis.com';
return (
<GoogleMap
googleMapURL="https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyBISa-Ul-NOnD-H5lweC_w4evLmV_0fuSU"
googleMapURL={`${rootUrl}/maps/api/js?v=3.exp&key=AIzaSyBISa-Ul-NOnD-H5lweC_w4evLmV_0fuSU`}
loadingElement={<div style={{ height: '100%' }} />}
containerElement={<div id="map-container" />}
mapElement={<div id="map" />}
Expand All @@ -67,6 +78,7 @@ class GoogleMapWrapper extends Component {
}
}
GoogleMapWrapper.propTypes = {
country: PropTypes.string,
dispatch: PropTypes.func.isRequired,
routes: PropTypes.arrayOf(PropTypes.array),
sectors: PropTypes.arrayOf(PropTypes.array).isRequired,
Expand All @@ -83,6 +95,7 @@ GoogleMapWrapper.defaultProps = { map: null, routes: null };

function mapStateToProps(state) {
return {
country: state.country,
routes: getRoutes(state).routes,
sectors: getSectors(state),
airports: getAirports(state),
Expand Down
19 changes: 10 additions & 9 deletions src/index.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import 'babel-polyfill';
import createBrowserHistory from 'history/createBrowserHistory';
import React from 'react';
import ReactDOM from 'react-dom';
import { createStore, applyMiddleware, combineReducers, compose } from 'redux';
import { Provider } from 'react-redux';
import { applyMiddleware, combineReducers, compose, createStore } from 'redux';
import { routerForBrowser } from 'redux-little-router';
import createBrowserHistory from 'history/createBrowserHistory';
import ReduxThunk from 'redux-thunk';
// import logger from 'redux-logger';

import './stylesheets/styles.scss';
import './stylesheets/map.scss';

import reducers from './reducers';
import ReduxThunk from 'redux-thunk';
import App from './components/App';
import reducers from './reducers';
import './stylesheets/map.scss';
import './stylesheets/styles.scss';
import checkIfMobile from './utils/checkIfMobile';

const history = createBrowserHistory();
Expand Down Expand Up @@ -57,9 +55,12 @@ const { reducer, middleware, enhancer } = routerForBrowser({
routes
});

const country = window.COUNTRY;
delete window.COUNTRY;

const store = createStore(
combineReducers({ ...reducers, router: reducer }),
{ isMobile: checkIfMobile() },
{ isMobile: checkIfMobile(), country },
compose(
enhancer,
applyMiddleware(ReduxThunk, middleware)
Expand Down
5 changes: 5 additions & 0 deletions src/reducers/country.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const country = (state = null) => {
return state;
};

export default country;
6 changes: 4 additions & 2 deletions src/reducers/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import airportData from './airportData';
import map from './map';
import country from './country';
import inputMode from './inputMode';
import settings from './settings';
import isMobile from './isMobile';
import map from './map';
import searchInput from './searchInput';
import settings from './settings';
import svgMap from './svgMap';

export default {
airportData,
country,
map,
inputMode,
settings,
Expand Down