2016-10-20 04:14:26 +03:00
|
|
|
const React = require('react');
|
|
|
|
const ReactRedux = require('react-redux');
|
|
|
|
const ReactRouter = require('react-router');
|
2016-12-13 16:35:39 +02:00
|
|
|
const Styled = require('styled-components');
|
2016-10-20 04:14:26 +03:00
|
|
|
|
2016-12-05 22:28:10 +02:00
|
|
|
const actions = require('@state/actions');
|
2016-12-13 16:35:39 +02:00
|
|
|
const Article = require('@components/article');
|
|
|
|
const Base = require('@ui/components/base');
|
|
|
|
const Footer = require('@components/footer');
|
2017-01-03 00:54:38 +02:00
|
|
|
const Header = require('@containers/header');
|
2016-12-05 22:28:10 +02:00
|
|
|
const Home = require('@containers/home');
|
|
|
|
const NotFound = require('@containers/not-found');
|
2016-10-20 04:14:26 +03:00
|
|
|
|
|
|
|
const {
|
|
|
|
updateRouter
|
|
|
|
} = actions;
|
|
|
|
|
|
|
|
const {
|
|
|
|
connect
|
|
|
|
} = ReactRedux;
|
|
|
|
|
|
|
|
const {
|
|
|
|
Miss,
|
|
|
|
Match
|
|
|
|
} = ReactRouter;
|
|
|
|
|
2016-12-13 16:35:39 +02:00
|
|
|
const {
|
|
|
|
injectGlobal
|
|
|
|
} = Styled;
|
|
|
|
|
2016-10-20 04:14:26 +03:00
|
|
|
const App = connect()(React.createClass({
|
2016-12-14 00:09:04 +02:00
|
|
|
displayName: 'App',
|
2016-10-25 22:15:33 +03:00
|
|
|
propTypes: {
|
|
|
|
children: React.PropTypes.node,
|
|
|
|
dispatch: React.PropTypes.func,
|
|
|
|
router: React.PropTypes.object
|
|
|
|
},
|
2016-10-20 04:14:26 +03:00
|
|
|
componentWillMount: function() {
|
|
|
|
const {
|
|
|
|
router,
|
|
|
|
dispatch
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
// ugly hack needed because of a limitation of react-router api
|
|
|
|
// that doens't pass it's instance to matched routes
|
2016-10-20 22:42:39 +03:00
|
|
|
// wait for react-router-redux@5
|
2016-10-20 04:14:26 +03:00
|
|
|
dispatch(updateRouter(router));
|
2016-12-13 16:35:39 +02:00
|
|
|
|
|
|
|
injectGlobal`
|
|
|
|
${Base.global}
|
|
|
|
`;
|
2016-10-20 04:14:26 +03:00
|
|
|
},
|
|
|
|
render: function() {
|
|
|
|
const {
|
|
|
|
children
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
if (!Array.isArray(children)) {
|
|
|
|
return children;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2016-12-13 16:35:39 +02:00
|
|
|
<Base>
|
2016-10-20 04:14:26 +03:00
|
|
|
{children}
|
2016-12-13 16:35:39 +02:00
|
|
|
</Base>
|
2016-10-20 04:14:26 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
module.exports = (props) => {
|
|
|
|
return (
|
|
|
|
<App {...props}>
|
2016-12-13 16:35:39 +02:00
|
|
|
<Header />
|
|
|
|
<Article>
|
2016-12-15 16:10:36 +02:00
|
|
|
<Match component={Home} pattern='/:org?/:section?' />
|
2016-12-14 00:09:04 +02:00
|
|
|
<Miss component={NotFound} />
|
2016-12-13 16:35:39 +02:00
|
|
|
</Article>
|
|
|
|
<Footer />
|
2016-10-20 04:14:26 +03:00
|
|
|
</App>
|
|
|
|
);
|
|
|
|
};
|