diff --git a/README.md b/README.md index b433b02376..51ccab68ef 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,11 @@ utilizing a unidirectional data flow. ├── /src/ # The source code of the application │ ├── /actions/ # Action creators that allow to trigger a dispatch to stores │ ├── /assets/ # Static files which are copied to ./build on compile -│ ├── /components/ # React components. E.g. Navbar.jsx, Calendar.jsx +│ ├── /components/ # React components +│ │ ├ /common/ # - Shared components. E.g. Link.js +│ │ ├ /forms/ # - Form components. E.g. TextBox.js +│ │ ├ /layout/ # - Layout components. E.g. Navbar.js +│ │ └ /pages/ # - Web-page components. E.g. About.js │ ├── /constants/ # Enumerations used in action creators and stores │ ├── /core/ # Core components (Flux dispatcher, base classes) │ ├── /images/ # Graphics (.png, .jpg, .svg etc.) diff --git a/gulpfile.js b/gulpfile.js index 3e4e409c3e..b7572e92b8 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -107,7 +107,7 @@ gulp.task('images', function() { // HTML pages gulp.task('pages', function() { - src.pages = ['src/pages/**/*.js', 'src/pages/404.html']; + src.pages = ['src/components/pages/**/*.js', 'src/components/pages/404.html']; var currentPage = {}; var Dispatcher = require('./src/core/Dispatcher'); @@ -123,7 +123,7 @@ gulp.task('pages', function() { }); var render = $.render({ - template: './src/pages/_template.html', + template: './src/components/pages/_template.html', data: function() { return currentPage; } }) .on('error', function(err) { console.log(err); render.end(); }); @@ -137,6 +137,7 @@ gulp.task('pages', function() { collapseWhitespace: true, minifyJS: true }), $.jsbeautifier())) + .pipe($.if('**/home.html', $.rename('index.html'))) .pipe(gulp.dest(DEST)) .pipe($.size({title: 'pages'})); }); diff --git a/package.json b/package.json index 08b540d2b0..9b962bbd85 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "gulp-load-plugins": "^0.8.0", "gulp-minify-css": "^0.3.11", "gulp-plumber": "^0.6.6", + "gulp-rename": "^1.2.0", "gulp-render": "^0.2.1", "gulp-replace": "^0.5.0", "gulp-size": "^1.1.0", diff --git a/src/app.js b/src/app.js index 11a07dc08e..805d2246ad 100644 --- a/src/app.js +++ b/src/app.js @@ -54,8 +54,8 @@ function render(page) { // Define URL routes // See https://github.com/flatiron/director var routes = { - '/': () => render(require('./pages/Index')), - '/privacy': () => render(require('./pages/Privacy')) + '/': () => render(require('./components/pages/Home')), + '/privacy': () => render(require('./components/pages/Privacy')) }; // Initialize a router diff --git a/src/components/Link.js b/src/components/common/Link.js similarity index 92% rename from src/components/Link.js rename to src/components/common/Link.js index dc7faea0d3..7dd0923a60 100644 --- a/src/components/Link.js +++ b/src/components/common/Link.js @@ -9,7 +9,7 @@ 'use strict'; var React = require('react'); -var RouteActions = require('../actions/RouteActions'); +var RouteActions = require('../../actions/RouteActions'); var Link = React.createClass({ propTypes: { diff --git a/src/layouts/DefaultLayout.js b/src/components/layout/App.js similarity index 92% rename from src/layouts/DefaultLayout.js rename to src/components/layout/App.js index 876b66e1bb..71c0b503ef 100644 --- a/src/layouts/DefaultLayout.js +++ b/src/components/layout/App.js @@ -9,9 +9,9 @@ 'use strict'; var React = require('react'); -var PageStore = require('../stores/PageStore'); -var Link = require('../components/Link'); -var Navbar = require('../components/Navbar'); +var PageStore = require('../../stores/PageStore'); +var Link = require('../common/Link'); +var Navbar = require('../layout/Navbar'); /** * Retrieves the current page metadata from the PageStore. diff --git a/src/components/Navbar.js b/src/components/layout/Navbar.js similarity index 94% rename from src/components/Navbar.js rename to src/components/layout/Navbar.js index ab92b9deb0..b5839fd361 100644 --- a/src/components/Navbar.js +++ b/src/components/layout/Navbar.js @@ -9,7 +9,7 @@ 'use strict'; var React = require('react'); -var Link = require('./Link'); +var Link = require('../common/Link'); var Navbar = React.createClass({ render() { diff --git a/src/components/__tests__/Navbar-test.js b/src/components/layout/__tests__/Navbar-test.js similarity index 100% rename from src/components/__tests__/Navbar-test.js rename to src/components/layout/__tests__/Navbar-test.js diff --git a/src/pages/404.html b/src/components/pages/404.html similarity index 100% rename from src/pages/404.html rename to src/components/pages/404.html diff --git a/src/pages/Index.js b/src/components/pages/Home.js similarity index 93% rename from src/pages/Index.js rename to src/components/pages/Home.js index 6ce8581802..374607e6f2 100644 --- a/src/pages/Index.js +++ b/src/components/pages/Home.js @@ -9,13 +9,13 @@ 'use strict'; var React = require('react'); -var PageActions = require('../actions/PageActions'); -var DefaultLayout = require('../layouts/DefaultLayout'); +var PageActions = require('../../actions/PageActions'); +var App = require('../layout/App'); var HomePage = React.createClass({ statics: { - layout: DefaultLayout + layout: App }, componentWillMount() { diff --git a/src/pages/Privacy.js b/src/components/pages/Privacy.js similarity index 95% rename from src/pages/Privacy.js rename to src/components/pages/Privacy.js index 24d0463861..028b336bdf 100644 --- a/src/pages/Privacy.js +++ b/src/components/pages/Privacy.js @@ -9,14 +9,14 @@ 'use strict'; var React = require('react'); -var PageActions = require('../actions/PageActions'); -var DefaultLayout = require('../layouts/DefaultLayout'); -var Link = require('../components/Link'); +var PageActions = require('../../actions/PageActions'); +var App = require('../layout/App'); +var Link = require('../common/Link'); var PrivacyPage = React.createClass({ statics: { - layout: DefaultLayout, + layout: App, breadcrumb: (