From 07c0a03c62907a958cbac8bc73efadd555dc0c32 Mon Sep 17 00:00:00 2001 From: Ivan Diaz Date: Tue, 26 Jan 2016 10:37:31 -0300 Subject: [PATCH] [Ivan Diaz] - Remove app folder --- app/fonts/.gitkeep | 0 app/images/.gitkeep | 0 app/index.html | 20 ----- app/js/App.js | 57 ------------ app/js/Routes.js | 23 ----- app/js/actions/.gitkeep | 0 app/js/actions/CurrentUserActions.js | 13 --- app/js/components-app/Footer.js | 16 ---- app/js/components-app/Header.js | 16 ---- .../components-core/__tests__/button-test.js | 35 -------- app/js/components-core/button.js | 44 ---------- app/js/components-core/widget.js | 28 ------ app/js/index.js | 15 ---- app/js/mixins/.gitkeep | 0 app/js/mixins/AuthenticatedRouteMixin.js | 28 ------ app/js/pages/HomePage.js | 33 ------- app/js/pages/NotFoundPage.js | 26 ------ app/js/pages/SearchPage.js | 33 ------- app/js/pages/component-demo-page.js | 61 ------------- app/js/pages/home-page.js | 13 --- app/js/stores/.gitkeep | 0 app/js/stores/CurrentUserStore.js | 60 ------------- app/js/utils/.gitkeep | 0 app/js/utils/APIUtils.js | 87 ------------------- app/js/utils/AuthAPI.js | 21 ----- 25 files changed, 629 deletions(-) delete mode 100644 app/fonts/.gitkeep delete mode 100644 app/images/.gitkeep delete mode 100644 app/index.html delete mode 100644 app/js/App.js delete mode 100644 app/js/Routes.js delete mode 100644 app/js/actions/.gitkeep delete mode 100644 app/js/actions/CurrentUserActions.js delete mode 100644 app/js/components-app/Footer.js delete mode 100644 app/js/components-app/Header.js delete mode 100644 app/js/components-core/__tests__/button-test.js delete mode 100644 app/js/components-core/button.js delete mode 100644 app/js/components-core/widget.js delete mode 100644 app/js/index.js delete mode 100644 app/js/mixins/.gitkeep delete mode 100644 app/js/mixins/AuthenticatedRouteMixin.js delete mode 100644 app/js/pages/HomePage.js delete mode 100644 app/js/pages/NotFoundPage.js delete mode 100644 app/js/pages/SearchPage.js delete mode 100644 app/js/pages/component-demo-page.js delete mode 100644 app/js/pages/home-page.js delete mode 100644 app/js/stores/.gitkeep delete mode 100644 app/js/stores/CurrentUserStore.js delete mode 100644 app/js/utils/.gitkeep delete mode 100644 app/js/utils/APIUtils.js delete mode 100644 app/js/utils/AuthAPI.js diff --git a/app/fonts/.gitkeep b/app/fonts/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/images/.gitkeep b/app/images/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/index.html b/app/index.html deleted file mode 100644 index 6aff3455..00000000 --- a/app/index.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - App Name - - - - - -
- - - - - \ No newline at end of file diff --git a/app/js/App.js b/app/js/App.js deleted file mode 100644 index af81a6d5..00000000 --- a/app/js/App.js +++ /dev/null @@ -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 ( -
- -
- - - -
- -
- ); - } - -}); - -export default App; \ No newline at end of file diff --git a/app/js/Routes.js b/app/js/Routes.js deleted file mode 100644 index a96c4fcf..00000000 --- a/app/js/Routes.js +++ /dev/null @@ -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 ( - - - - - - - - - - -); \ No newline at end of file diff --git a/app/js/actions/.gitkeep b/app/js/actions/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/js/actions/CurrentUserActions.js b/app/js/actions/CurrentUserActions.js deleted file mode 100644 index 3701b74e..00000000 --- a/app/js/actions/CurrentUserActions.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -import Reflux from 'reflux'; - -var CurrentUserActions = Reflux.createActions([ - - 'checkLoginStatus', - 'login', - 'logout' - -]); - -export default CurrentUserActions; \ No newline at end of file diff --git a/app/js/components-app/Footer.js b/app/js/components-app/Footer.js deleted file mode 100644 index 3bc42db2..00000000 --- a/app/js/components-app/Footer.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -import React from 'react/addons'; - -var Footer = React.createClass({ - - render() { - return ( -
-
- ); - } - -}); - -export default Footer; \ No newline at end of file diff --git a/app/js/components-app/Header.js b/app/js/components-app/Header.js deleted file mode 100644 index e9c44faa..00000000 --- a/app/js/components-app/Header.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -import React from 'react/addons'; - -var Header = React.createClass({ - - render() { - return ( -
-
- ); - } - -}); - -export default Header; \ No newline at end of file diff --git a/app/js/components-core/__tests__/button-test.js b/app/js/components-core/__tests__/button-test.js deleted file mode 100644 index 1fd7a257..00000000 --- a/app/js/components-core/__tests__/button-test.js +++ /dev/null @@ -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( - - ); - - expect(button.getDOMNode().textContent).toEqual('testcontent'); - }); - - it('should add passed types to class', () => { - var types = [ - 'primary' - ]; - - types.forEach((type) => { - var button = TestUtils.renderIntoDocument( - - ); - expect(button.getDOMNode().getAttribute('class')).toContain('button-' + type); - }); - }); -}); \ No newline at end of file diff --git a/app/js/components-core/button.js b/app/js/components-core/button.js deleted file mode 100644 index 6ae24dca..00000000 --- a/app/js/components-core/button.js +++ /dev/null @@ -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 ( - - ); - }, - - 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; \ No newline at end of file diff --git a/app/js/components-core/widget.js b/app/js/components-core/widget.js deleted file mode 100644 index 098bccf7..00000000 --- a/app/js/components-core/widget.js +++ /dev/null @@ -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 ( -
- {this.props.children} -
- ); - }, - - getClass() { - var classes = { - 'widget': true - }; - - classes[this.props.className] = (this.props.className); - - return classNames(classes); - } -}); - -export default Widget; \ No newline at end of file diff --git a/app/js/index.js b/app/js/index.js deleted file mode 100644 index 38f06b80..00000000 --- a/app/js/index.js +++ /dev/null @@ -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(, document.getElementById('app')); -}); \ No newline at end of file diff --git a/app/js/mixins/.gitkeep b/app/js/mixins/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/js/mixins/AuthenticatedRouteMixin.js b/app/js/mixins/AuthenticatedRouteMixin.js deleted file mode 100644 index 90ce5ab4..00000000 --- a/app/js/mixins/AuthenticatedRouteMixin.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/app/js/pages/HomePage.js b/app/js/pages/HomePage.js deleted file mode 100644 index de1cbd48..00000000 --- a/app/js/pages/HomePage.js +++ /dev/null @@ -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 ( - -
- -
- Home -
- -
- Search -
- -
-
- ); - } - -}); - -export default HomePage; \ No newline at end of file diff --git a/app/js/pages/NotFoundPage.js b/app/js/pages/NotFoundPage.js deleted file mode 100644 index 9040afe8..00000000 --- a/app/js/pages/NotFoundPage.js +++ /dev/null @@ -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 ( - -
- - Page Not Found - -
-
- ); - } - -}); - -export default NotFoundPage; \ No newline at end of file diff --git a/app/js/pages/SearchPage.js b/app/js/pages/SearchPage.js deleted file mode 100644 index 41dc117e..00000000 --- a/app/js/pages/SearchPage.js +++ /dev/null @@ -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 ( - -
- -
- Search -
- -
- Back to Home -
- -
-
- ); - } - -}); - -export default SearchPage; \ No newline at end of file diff --git a/app/js/pages/component-demo-page.js b/app/js/pages/component-demo-page.js deleted file mode 100644 index d9490870..00000000 --- a/app/js/pages/component-demo-page.js +++ /dev/null @@ -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: ( - - ) - }, - { - title: 'Widget', - render: ( - -

Register here!

- - -
- ) - } - ], - - render() { - return ( - -
- {this.renderElements()} -
-
- ); - }, - - renderElements: function () { - return this.elements.map((element) => { - return ( -
-

- {element.title} -

-
- {element.render} -
-
- ); - }); - } -}); - -export default DemoPage; \ No newline at end of file diff --git a/app/js/pages/home-page.js b/app/js/pages/home-page.js deleted file mode 100644 index 7c584535..00000000 --- a/app/js/pages/home-page.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -import React from 'react/addons'; -import DocumentTitle from 'react-document-title'; - -var HomePage = React.createClass({ - - render() { - return ( - null - ); - } -}); \ No newline at end of file diff --git a/app/js/stores/.gitkeep b/app/js/stores/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/js/stores/CurrentUserStore.js b/app/js/stores/CurrentUserStore.js deleted file mode 100644 index 16e2f741..00000000 --- a/app/js/stores/CurrentUserStore.js +++ /dev/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; \ No newline at end of file diff --git a/app/js/utils/.gitkeep b/app/js/utils/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/app/js/utils/APIUtils.js b/app/js/utils/APIUtils.js deleted file mode 100644 index f85b139d..00000000 --- a/app/js/utils/APIUtils.js +++ /dev/null @@ -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; \ No newline at end of file diff --git a/app/js/utils/AuthAPI.js b/app/js/utils/AuthAPI.js deleted file mode 100644 index 34d8a402..00000000 --- a/app/js/utils/AuthAPI.js +++ /dev/null @@ -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; \ No newline at end of file