From f86132582a0d0d43296f2ca3db6198c053f7c010 Mon Sep 17 00:00:00 2001 From: Oroian Rares Lucian Date: Thu, 21 Apr 2016 10:56:37 +0300 Subject: [PATCH 1/9] Reorganise app sources by-feature, rename sources. --- e2e/main.po.js | 10 ------ e2e/main.spec.js | 21 ------------ gulp/build.js | 4 +-- gulp/inject.js | 2 +- src/app/index.js | 14 -------- src/app/index.module.js | 32 +++++++++++++++++++ src/app/main/main.controller.spec.js | 22 ------------- .../directives/navbar/navbar.controller.js | 16 ++++++++++ .../directives/navbar/navbar.directive.js | 15 +++++++++ .../directives/navbar/navbar.template.html} | 2 +- .../test-page.controller.js} | 25 +++++++++------ src/app/testPage/test-page.module.js | 4 +++ .../test-page.template.html} | 2 +- src/app/vendor.scss | 4 +-- src/components/navbar/navbar.controller.js | 6 ---- src/index.html | 6 ++-- 16 files changed, 93 insertions(+), 92 deletions(-) delete mode 100644 e2e/main.po.js delete mode 100644 e2e/main.spec.js delete mode 100644 src/app/index.js create mode 100644 src/app/index.module.js delete mode 100644 src/app/main/main.controller.spec.js create mode 100644 src/app/testPage/directives/navbar/navbar.controller.js create mode 100644 src/app/testPage/directives/navbar/navbar.directive.js rename src/{components/navbar/navbar.html => app/testPage/directives/navbar/navbar.template.html} (88%) rename src/app/{main/main.controller.js => testPage/test-page.controller.js} (80%) create mode 100644 src/app/testPage/test-page.module.js rename src/app/{main/main.html => testPage/test-page.template.html} (93%) delete mode 100644 src/components/navbar/navbar.controller.js diff --git a/e2e/main.po.js b/e2e/main.po.js deleted file mode 100644 index d2f909c..0000000 --- a/e2e/main.po.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var MainPage = function() { - this.jumbEl = element(by.css('.jumbotron')); - this.h1El = this.jumbEl.element(by.css('h1')); - this.imgEl = this.jumbEl.element(by.css('img')); - this.thumbnailEls = element(by.css('body')).all(by.repeater('awesomeThing in awesomeThings')); -}; - -module.exports = new MainPage(); diff --git a/e2e/main.spec.js b/e2e/main.spec.js deleted file mode 100644 index 577a2e9..0000000 --- a/e2e/main.spec.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -describe('The main view', function () { - var page; - - beforeEach(function () { - browser.get('http://localhost:3000/index.html'); - page = require('./main.po'); - }); - - it('should include jumbotron with correct data', function() { - expect(page.h1El.getText()).toBe('\'Allo, \'Allo!'); - expect(page.imgEl.getAttribute('src')).toMatch(/assets\/images\/algotech.png$/); - expect(page.imgEl.getAttribute('alt')).toBe('We are AlgoTech'); - }); - - it('list more than 5 awesome things', function () { - expect(page.thumbnailEls.count()).toBeGreaterThan(5); - }); - -}); diff --git a/gulp/build.js b/gulp/build.js index 2c6c0c9..01c7b68 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -19,7 +19,7 @@ gulp.task('partials', function () { quotes: true })) .pipe($.angularTemplatecache('templateCacheHtml.js', { - module: 'test' + module: 'app' })) .pipe(gulp.dest(paths.tmp + '/partials/')); }); @@ -46,7 +46,7 @@ gulp.task('html', ['inject', 'partials'], function () { .pipe($.uglify({preserveComments: $.uglifySaveLicense})) .pipe(jsFilter.restore()) .pipe(cssFilter) - .pipe($.replace('../bootstrap-sass-official/assets/fonts/bootstrap', 'fonts')) + .pipe($.replace('../bootstrap-sass/assets/fonts/bootstrap', 'fonts')) .pipe($.csso()) .pipe(cssFilter.restore()) .pipe(assets.restore()) diff --git a/gulp/inject.js b/gulp/inject.js index 4a277b8..4ab3020 100644 --- a/gulp/inject.js +++ b/gulp/inject.js @@ -28,7 +28,7 @@ gulp.task('inject', ['styles'], function () { var wiredepOptions = { directory: 'bower_components', - exclude: [/bootstrap-sass-official/, /bootstrap\.css/, /bootstrap\.css/, /foundation\.css/] + exclude: [/bootstrap-sass/, /bootstrap\.css/, /bootstrap\.css/, /foundation\.css/] }; return gulp.src(paths.src + '/*.html') diff --git a/src/app/index.js b/src/app/index.js deleted file mode 100644 index c4a6386..0000000 --- a/src/app/index.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -angular.module('test', ['ngTouch', 'restangular', 'ui.router', 'ui.bootstrap']) - .config(function($stateProvider, $urlRouterProvider) { - $stateProvider - .state('home', { - url: '/', - templateUrl: 'app/main/main.html', - controller: 'MainCtrl' - }); - - $urlRouterProvider.otherwise('/'); - }) -; diff --git a/src/app/index.module.js b/src/app/index.module.js new file mode 100644 index 0000000..f50e4ec --- /dev/null +++ b/src/app/index.module.js @@ -0,0 +1,32 @@ +(function indexIIFE() { + 'use strict'; + + angular + .module('app', [ + 'ngTouch', + 'restangular', + 'ui.router', + 'ui.bootstrap', + + 'app.testPage' + ]) + .config(appConfigFunc) + .run(appRunFunc); + + appConfigFunc.$inject = ['$stateProvider', '$urlRouterProvider']; + + function appConfigFunc($stateProvider, $urlRouterProvider) { + $stateProvider + .state('home', { + url: '/', + templateUrl: 'app/testPage/test-page.template.html', + controller: 'TestPageCtrl' + }); + + $urlRouterProvider.otherwise('/'); + } + + function appRunFunc() { + + } +})(); diff --git a/src/app/main/main.controller.spec.js b/src/app/main/main.controller.spec.js deleted file mode 100644 index 3a50f28..0000000 --- a/src/app/main/main.controller.spec.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -describe('controllers', function() { - var scope; - - beforeEach(module('test')); - - beforeEach(inject(function($rootScope) { - scope = $rootScope.$new(); - })); - - it('should define more than 5 awesome things', inject(function($controller) { - expect(scope.awesomeThings).toBeUndefined(); - - $controller('MainCtrl', { - $scope: scope - }); - - expect(angular.isArray(scope.awesomeThings)).toBeTruthy(); - expect(scope.awesomeThings.length > 5).toBeTruthy(); - })); -}); diff --git a/src/app/testPage/directives/navbar/navbar.controller.js b/src/app/testPage/directives/navbar/navbar.controller.js new file mode 100644 index 0000000..ed50645 --- /dev/null +++ b/src/app/testPage/directives/navbar/navbar.controller.js @@ -0,0 +1,16 @@ +/** + * Created by rares on 19/04/16. + */ +(function navbarCtrlIIFE() { + 'use strict'; + + angular + .module('app.testPage') + .controller('NavbarCtrl', NavbarCtrlFunc); + + NavbarCtrlFunc.$inject = ['$scope']; + + function NavbarCtrlFunc($scope) { + $scope.date = new Date(); + } +})(); diff --git a/src/app/testPage/directives/navbar/navbar.directive.js b/src/app/testPage/directives/navbar/navbar.directive.js new file mode 100644 index 0000000..48b3e5e --- /dev/null +++ b/src/app/testPage/directives/navbar/navbar.directive.js @@ -0,0 +1,15 @@ +(function navbarDirectiveIIFE() { + 'use strict'; + + angular + .module('app.testPage') + .directive('navbar', navbarFunc); + + function navbarFunc() { + return { + restrict: 'E', + controller: 'NavbarCtrl', + templateUrl: 'app/testPage/directives/navbar/navbar.template.html' + }; + } +})(); diff --git a/src/components/navbar/navbar.html b/src/app/testPage/directives/navbar/navbar.template.html similarity index 88% rename from src/components/navbar/navbar.html rename to src/app/testPage/directives/navbar/navbar.template.html index 046e696..169563d 100644 --- a/src/components/navbar/navbar.html +++ b/src/app/testPage/directives/navbar/navbar.template.html @@ -1,4 +1,4 @@ -