[Ivan Diaz] - Remove app folder
This commit is contained in:
parent
b2c66113df
commit
07c0a03c62
|
@ -1,20 +0,0 @@
|
|||
<!doctype html>
|
||||
<html class="no-js" lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="description" content="">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
|
||||
<title>App Name</title>
|
||||
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="app"></div>
|
||||
|
||||
<script src="/js/main.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,57 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import {ListenerMixin} from 'reflux';
|
||||
import {RouteHandler} from 'react-router';
|
||||
|
||||
import CurrentUserActions from './actions/CurrentUserActions';
|
||||
import CurrentUserStore from './stores/CurrentUserStore';
|
||||
import Header from './components-app/Header';
|
||||
import Footer from './components-app/Footer';
|
||||
|
||||
var App = React.createClass({
|
||||
|
||||
mixins: [ListenerMixin],
|
||||
|
||||
getInitialState() {
|
||||
return {
|
||||
currentUser: {}
|
||||
};
|
||||
},
|
||||
|
||||
_onUserChange(err, user) {
|
||||
if ( err ) {
|
||||
this.setState({ error: err });
|
||||
} else {
|
||||
this.setState({ currentUser: user || {}, error: null });
|
||||
}
|
||||
},
|
||||
|
||||
componentWillMount() {
|
||||
console.log('About to mount App');
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
this.listenTo(CurrentUserStore, this._onUserChange);
|
||||
CurrentUserActions.checkLoginStatus();
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
|
||||
<Header />
|
||||
|
||||
<RouteHandler params={this.props.params}
|
||||
query={this.props.query}
|
||||
currentUser={this.state.currentUser} />
|
||||
|
||||
<Footer />
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default App;
|
|
@ -1,23 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import {Route, NotFoundRoute, DefaultRoute} from 'react-router';
|
||||
|
||||
import App from './App';
|
||||
import HomePage from './pages/HomePage';
|
||||
import SearchPage from './pages/SearchPage';
|
||||
import NotFoundPage from './pages/NotFoundPage';
|
||||
import DemoPage from './pages/component-demo-page';
|
||||
|
||||
export default (
|
||||
<Route handler={App} path='/'>
|
||||
|
||||
<DefaultRoute handler={HomePage} />
|
||||
|
||||
<Route name='Home' path='/' handler={HomePage} />
|
||||
<Route name='Demo' path='/demo' handler={DemoPage} />
|
||||
|
||||
<NotFoundRoute handler={NotFoundPage} />
|
||||
|
||||
</Route>
|
||||
);
|
|
@ -1,13 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import Reflux from 'reflux';
|
||||
|
||||
var CurrentUserActions = Reflux.createActions([
|
||||
|
||||
'checkLoginStatus',
|
||||
'login',
|
||||
'logout'
|
||||
|
||||
]);
|
||||
|
||||
export default CurrentUserActions;
|
|
@ -1,16 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
|
||||
var Footer = React.createClass({
|
||||
|
||||
render() {
|
||||
return (
|
||||
<footer>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default Footer;
|
|
@ -1,16 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
|
||||
var Header = React.createClass({
|
||||
|
||||
render() {
|
||||
return (
|
||||
<header>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default Header;
|
|
@ -1,35 +0,0 @@
|
|||
/**
|
||||
* Created by ivan on 16/08/15.
|
||||
*/
|
||||
jest.dontMock('../button.js');
|
||||
|
||||
import React from 'react/addons';
|
||||
import Button from '../button.js';
|
||||
var TestUtils = React.addons.TestUtils;
|
||||
|
||||
describe('Button', () => {
|
||||
it('should render children', () => {
|
||||
var button = TestUtils.renderIntoDocument(
|
||||
<Button>
|
||||
testcontent
|
||||
</Button>
|
||||
);
|
||||
|
||||
expect(button.getDOMNode().textContent).toEqual('testcontent');
|
||||
});
|
||||
|
||||
it('should add passed types to class', () => {
|
||||
var types = [
|
||||
'primary'
|
||||
];
|
||||
|
||||
types.forEach((type) => {
|
||||
var button = TestUtils.renderIntoDocument(
|
||||
<Button type={type}>
|
||||
testcontent
|
||||
</Button>
|
||||
);
|
||||
expect(button.getDOMNode().getAttribute('class')).toContain('button-' + type);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* Created by ivan on 16/08/15.
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import classNames from 'classnames';
|
||||
|
||||
var Button = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
children: React.PropTypes.node,
|
||||
type: React.PropTypes.oneOf([
|
||||
'primary'
|
||||
])
|
||||
},
|
||||
|
||||
getDefaultProps() {
|
||||
return {
|
||||
type: 'primary'
|
||||
}
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<button className={this.getClass()}>
|
||||
{this.props.children}
|
||||
</button>
|
||||
);
|
||||
},
|
||||
|
||||
getClass() {
|
||||
var classes = {
|
||||
'button': true
|
||||
};
|
||||
|
||||
classes['button-' + this.props.type] = (this.props.type);
|
||||
classes[this.props.className] = (this.props.className);
|
||||
|
||||
return classNames(classes);
|
||||
}
|
||||
});
|
||||
|
||||
export default Button;
|
|
@ -1,28 +0,0 @@
|
|||
import React from 'react/addons';
|
||||
import classNames from 'classnames';
|
||||
|
||||
var Widget = React.createClass({
|
||||
propTypes: {
|
||||
children: React.PropTypes.node.isRequired
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className={this.getClass()}>
|
||||
{this.props.children}
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
getClass() {
|
||||
var classes = {
|
||||
'widget': true
|
||||
};
|
||||
|
||||
classes[this.props.className] = (this.props.className);
|
||||
|
||||
return classNames(classes);
|
||||
}
|
||||
});
|
||||
|
||||
export default Widget;
|
|
@ -1,15 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import Router from 'react-router';
|
||||
|
||||
import routes from './Routes';
|
||||
|
||||
if ( process.env.NODE_ENV !== 'production' ) {
|
||||
// Enable React devtools
|
||||
window.React = React;
|
||||
}
|
||||
|
||||
Router.run(routes, Router.HistoryLocation, (Handler, state) => {
|
||||
React.render(<Handler params={state.params} query={state.query} />, document.getElementById('app'));
|
||||
});
|
|
@ -1,28 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import _ from 'lodash';
|
||||
import {Navigation} from 'react-router';
|
||||
|
||||
import CurrentUserStore from '../stores/CurrentUserStore';
|
||||
|
||||
var AuthenticatedRouteMixin = {
|
||||
|
||||
mixins: [Navigation],
|
||||
|
||||
_checkIfRedirect() {
|
||||
if ( _.isEmpty(CurrentUserStore.user) && CurrentUserStore.hasBeenChecked && this.isMounted() ) {
|
||||
this.replaceWith('Home');
|
||||
}
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
this._checkIfRedirect();
|
||||
},
|
||||
|
||||
componentDidUpdate() {
|
||||
this._checkIfRedirect();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export default AuthenticatedRouteMixin;
|
|
@ -1,33 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import {Link} from 'react-router';
|
||||
import DocumentTitle from 'react-document-title';
|
||||
|
||||
var HomePage = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
currentUser: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DocumentTitle title="Home">
|
||||
<section className="home-page">
|
||||
|
||||
<div>
|
||||
Home
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Link to="Search">Search</Link>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</DocumentTitle>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default HomePage;
|
|
@ -1,26 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import DocumentTitle from 'react-document-title';
|
||||
|
||||
var NotFoundPage = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
currentUser: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DocumentTitle title="404: Not Found">
|
||||
<section className="not-found-page">
|
||||
|
||||
Page Not Found
|
||||
|
||||
</section>
|
||||
</DocumentTitle>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default NotFoundPage;
|
|
@ -1,33 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import {Link} from 'react-router';
|
||||
import DocumentTitle from 'react-document-title';
|
||||
|
||||
var SearchPage = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
currentUser: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DocumentTitle title="Search">
|
||||
<section className="search-page">
|
||||
|
||||
<div>
|
||||
Search
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Link to="Home">Back to Home</Link>
|
||||
</div>
|
||||
|
||||
</section>
|
||||
</DocumentTitle>
|
||||
);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default SearchPage;
|
|
@ -1,61 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import {Link} from 'react-router';
|
||||
import DocumentTitle from 'react-document-title';
|
||||
|
||||
import Button from '../components-core/button.js';
|
||||
import Widget from '../components-core/widget.js';
|
||||
|
||||
var DemoPage = React.createClass({
|
||||
|
||||
propTypes: {
|
||||
currentUser: React.PropTypes.object.isRequired
|
||||
},
|
||||
|
||||
elements: [
|
||||
{
|
||||
title: 'Primary Button',
|
||||
render: (
|
||||
<Button type="primary">Sign up</Button>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: 'Widget',
|
||||
render: (
|
||||
<Widget>
|
||||
<h2>Register here!</h2>
|
||||
|
||||
<Button type="primary">SIGN UP</Button>
|
||||
</Widget>
|
||||
)
|
||||
}
|
||||
],
|
||||
|
||||
render() {
|
||||
return (
|
||||
<DocumentTitle title="Demo Page">
|
||||
<section className="home-page">
|
||||
{this.renderElements()}
|
||||
</section>
|
||||
</DocumentTitle>
|
||||
);
|
||||
},
|
||||
|
||||
renderElements: function () {
|
||||
return this.elements.map((element) => {
|
||||
return (
|
||||
<div className="demo-element">
|
||||
<h4>
|
||||
{element.title}
|
||||
</h4>
|
||||
<div class="demo-element--example">
|
||||
{element.render}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export default DemoPage;
|
|
@ -1,13 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import React from 'react/addons';
|
||||
import DocumentTitle from 'react-document-title';
|
||||
|
||||
var HomePage = React.createClass({
|
||||
|
||||
render() {
|
||||
return (
|
||||
null
|
||||
);
|
||||
}
|
||||
});
|
|
@ -1,60 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import Reflux from 'reflux';
|
||||
|
||||
import CurrentUserActions from '../actions/CurrentUserActions';
|
||||
import AuthAPI from '../utils/AuthAPI';
|
||||
|
||||
var CurrentUserStore = Reflux.createStore({
|
||||
|
||||
init() {
|
||||
this.user = null;
|
||||
this.hasBeenChecked = false;
|
||||
|
||||
this.listenTo(CurrentUserActions.checkLoginStatus, this.checkLoginStatus);
|
||||
this.listenTo(CurrentUserActions.login, this.loginUser);
|
||||
this.listenTo(CurrentUserActions.logout, this.logoutUser);
|
||||
},
|
||||
|
||||
setUser(user, cb = function(){}) {
|
||||
this.user = user;
|
||||
cb(null, this.user);
|
||||
this.trigger(null, this.user);
|
||||
},
|
||||
|
||||
throwError(err, cb) {
|
||||
cb(err);
|
||||
this.trigger(err);
|
||||
},
|
||||
|
||||
checkLoginStatus(cb = function(){}) {
|
||||
if ( this.user ) {
|
||||
this.setUser(this.user, cb);
|
||||
} else {
|
||||
AuthAPI.checkLoginStatus().then(user => {
|
||||
this.hasBeenChecked = true;
|
||||
this.setUser(user, cb);
|
||||
}).catch(err => {
|
||||
this.hasBeenChecked = true;
|
||||
this.throwError(err, cb);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
loginUser(user, cb = function(){}) {
|
||||
AuthAPI.login(user).then(user => {
|
||||
this.setUser(user, cb);
|
||||
}).catch(err => {
|
||||
this.throwError(err, cb);
|
||||
});
|
||||
},
|
||||
|
||||
logoutUser(cb = function(){}) {
|
||||
AuthAPI.logout(this.user).then(() => {
|
||||
this.setUser(null, cb);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
export default CurrentUserStore;
|
|
@ -1,87 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import {camelizeKeys} from 'humps';
|
||||
import request from 'superagent';
|
||||
|
||||
var APIUtils = {
|
||||
|
||||
root: '//localhost:3000/api/',
|
||||
|
||||
normalizeResponse(response) {
|
||||
return camelizeKeys(response.body);
|
||||
},
|
||||
|
||||
get(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.get(this.root + path)
|
||||
.withCredentials()
|
||||
.end((err, res) => {
|
||||
if ( err || !res.ok ) {
|
||||
reject(this.normalizeResponse(err || res));
|
||||
} else {
|
||||
resolve(this.normalizeResponse(res));
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
post(path, body) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.post(this.root + path, body)
|
||||
.withCredentials()
|
||||
.end((err, res) => {
|
||||
console.log(err, res);
|
||||
if ( err || !res.ok ) {
|
||||
reject(this.normalizeResponse(err || res));
|
||||
} else {
|
||||
resolve(this.normalizeResponse(res));
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
patch(path, body) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.patch(this.root + path, body)
|
||||
.withCredentials()
|
||||
.end((err, res) => {
|
||||
if ( err || !res.ok ) {
|
||||
reject(this.normalizeResponse(err || res));
|
||||
} else {
|
||||
resolve(this.normalizeResponse(res));
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
put(path, body) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.put(this.root + path, body)
|
||||
.withCredentials()
|
||||
.end((err, res) => {
|
||||
if ( err || !res.ok ) {
|
||||
reject(this.normalizeResponse(err || res));
|
||||
} else {
|
||||
resolve(this.normalizeResponse(res));
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
del(path) {
|
||||
return new Promise((resolve, reject) => {
|
||||
request.del(this.root + path)
|
||||
.withCredentials()
|
||||
.end((err, res) => {
|
||||
if ( err || !res.ok ) {
|
||||
reject(this.normalizeResponse(err || res));
|
||||
} else {
|
||||
resolve(this.normalizeResponse(res));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export default APIUtils;
|
|
@ -1,21 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
import APIUtils from './APIUtils';
|
||||
|
||||
var AuthAPI = {
|
||||
|
||||
checkLoginStatus() {
|
||||
return APIUtils.get('auth/check');
|
||||
},
|
||||
|
||||
login(user) {
|
||||
return APIUtils.post('auth/login', user);
|
||||
},
|
||||
|
||||
logout() {
|
||||
return APIUtils.post('auth/logout');
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
export default AuthAPI;
|
Loading…
Reference in New Issue