Skip to content

Commit

Permalink
add angular new router prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiip authored and Mehdy Dara committed Aug 25, 2015
1 parent c0b7424 commit 75b3f1c
Show file tree
Hide file tree
Showing 35 changed files with 124 additions and 19 deletions.
7 changes: 7 additions & 0 deletions app/prompts.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@
},
"name": "ngRoute, the official router"
},
{
"value": {
"key": "new-router",
"module": "ngNewRouter"
},
"name": "Angular 2 new router which is compatible with Angular 1 (experimental)"
},
{
"value": {
"key": "none",
Expand Down
6 changes: 6 additions & 0 deletions app/src/bower.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ module.exports = function(GulpAngularGenerator) {
}
}

if (this.props.router.key === 'new-router') {
bowerOverrides['angular-new-router'] = {
main: [ 'dist/router.es5.js' ]
};
}

if (_.isEmpty(bowerOverrides)) {
this.bowerOverrides = null;
} else {
Expand Down
11 changes: 9 additions & 2 deletions app/src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,27 @@ module.exports = function(GulpAngularGenerator) {
GulpAngularGenerator.prototype.computeRouter = function computeRouter() {
var routerPartialSrc = 'src/app/main/__' + this.props.ui.key + '.html';

if (this.props.router.module === 'ngRoute') {
if (this.props.router.key === 'angular-route') {
this.routerHtml = '<div ng-view></div>';
this.files.push({
src: 'src/app/_ngroute/__ngroute.' + this.props.jsPreprocessor.srcExtension,
dest: 'src/app/index.route.' + this.props.jsPreprocessor.extension,
template: true
});
} else if (this.props.router.module === 'ui.router') {
} else if (this.props.router.key === 'ui-router') {
this.routerHtml = '<div ui-view></div>';
this.files.push({
src: 'src/app/_uirouter/__uirouter.' + this.props.jsPreprocessor.srcExtension,
dest: 'src/app/index.route.' + this.props.jsPreprocessor.extension,
template: true
});
} else if (this.props.router.key === 'new-router') {
this.routerHtml = '<div ng-viewport ng-controller="RouterController"></div>';
this.files.push({
src: 'src/app/_newrouter/__newrouter.' + this.props.jsPreprocessor.srcExtension,
dest: 'src/app/index.route.' + this.props.jsPreprocessor.extension,
template: true
});
} else {
this.routerHtml = this.fs.read(this.templatePath(routerPartialSrc));
this.routerHtml = this.routerHtml.replace(
Expand Down
2 changes: 2 additions & 0 deletions app/templates/_bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
"angular-route": "<%- props.angularVersion %>",
<% } if (props.router.key === 'ui-router') { -%>
"angular-ui-router": "~0.2.15",
<% } if (props.router.key === 'new-router') { -%>
"angular-new-router": "~0.5.3",
<% } if(props.ui.key === 'bootstrap') { -%>
<% if(props.cssPreprocessor.extension === 'scss') { -%>
"bootstrap-sass": "~3.3.4",
Expand Down
14 changes: 10 additions & 4 deletions app/templates/src/app/_index.module.es6
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
/* global malarkey:false, moment:false */

import config from './index.config';
<% if (props.router.key !== 'none') { %>
<% if (props.router.key === 'new-router') { -%>
import { routerConfig, RouterController } from './index.route';
<% } else if (props.router.key !== 'none') { -%>
import routerConfig from './index.route';
<% } %>
<% } -%>
import runBlock from './index.run';
import MainController from './main/main.controller';
import GithubContributorService from '../app/components/githubContributor/githubContributor.service';
Expand All @@ -14,12 +17,15 @@ angular.module('<%- appName %>', [<%- modulesDependencies %>])
.constant('malarkey', malarkey)
.constant('moment', moment)
.config(config)
<% if (props.router.key !== 'none') { %>
<% if (props.router.key !== 'none') { -%>
.config(routerConfig)
<% } %>
<% } -%>
.run(runBlock)
.service('githubContributor', GithubContributorService)
.service('webDevTec', WebDevTecService)
<% if (props.router.key !== 'none') { -%>
.controller('RouterController', RouterController)
<% } -%>
.controller('MainController', MainController)
.directive('acmeNavbar', () => new NavbarDirective())
.directive('acmeMalarkey', () => new MalarkeyDirective(malarkey));
29 changes: 18 additions & 11 deletions app/templates/src/app/_index.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,23 @@ import { acmeMalarkey } from '../app/components/malarkey/malarkey.directive';
declare var malarkey: any;
declare var moment: moment.MomentStatic;

angular.module('<%- appName %>', [<%- modulesDependencies %>])
.constant('malarkey', malarkey)
.constant('moment', moment)
.config(config)
module <%- appName %> {
'use strict';

angular.module('<%- appName %>', [<%- modulesDependencies %>])
.constant('malarkey', malarkey)
.constant('moment', moment)
.config(config)
<% if (props.router.key !== 'none') { -%>
.config(routerConfig)
.config(routerConfig)
<% } -%>
.run(runBlock)
.service('githubContributor', GithubContributor)
.service('webDevTec', WebDevTecService)
<% if (props.router.key === 'new-router') { -%>
.controller('RouterController', RouterController)
<% } -%>
.run(runBlock)
.service('githubContributor', GithubContributor)
.service('webDevTec', WebDevTecService)
.controller('MainController', MainController)
.directive('acmeNavbar', acmeNavbar)
.directive('acmeMalarkey', acmeMalarkey);
.controller('MainController', MainController)
.directive('acmeNavbar', acmeNavbar)
.directive('acmeMalarkey', acmeMalarkey);
}
12 changes: 12 additions & 0 deletions app/templates/src/app/_newrouter/__newrouter.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
angular.module '<%- appName %>'
.config ($componentLoaderProvider) ->
'ngInject'
$componentLoaderProvider.setTemplateMapping (name) ->
"app/#{ name }/#{ name }.html"

.controller 'RouterController', ($router) ->
'ngInject'
$router.config [
path: '/'
component: 'main'
]
15 changes: 15 additions & 0 deletions app/templates/src/app/_newrouter/__newrouter.es6
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export function routerConfig($componentLoaderProvider) {
'ngInject';
$componentLoaderProvider.setTemplateMapping(function(name) {
return `app/${ name }/${ name }.html`;
});
}

export class RouterController {
constructor($router) {
'ngInject';
$router.config([
{ path: '/', component: 'main' }
]);
}
}
23 changes: 23 additions & 0 deletions app/templates/src/app/_newrouter/__newrouter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(function() {
'use strict';

angular
.module('<%- appName %>')
.config(routerConfig)
.controller('RouterController', RouterController);

/** @ngInject */
function routerConfig($componentLoaderProvider) {
$componentLoaderProvider.setTemplateMapping(function(name) {
return 'app/' + name + '/' + name + '.html';
});
}

/** @ngInject */
function RouterController($router) {
$router.config([
{ path: '/', component: 'main' }
]);
}

})();
19 changes: 19 additions & 0 deletions app/templates/src/app/_newrouter/__newrouter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module <%- appName %> {
'use strict';

/** @ngInject */
export function routerConfig($componentLoaderProvider) {
$componentLoaderProvider.setTemplateMapping(function(name) {
return 'app/' + name + '/' + name + '.html';
});
}

/** @ngInject */
export class RouterController {
constructor($router) {
$router.config([
{ path: '/', component: 'main' }
]);
}
}
}
4 changes: 2 additions & 2 deletions app/templates/src/app/_uirouter/__uirouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

angular
.module('<%- appName %>')
.config(routeConfig);
.config(routerConfig);

/** @ngInject */
function routeConfig($stateProvider, $urlRouterProvider) {
function routerConfig($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/',
Expand Down
Binary file added docs/assets/original/LESS-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/angular-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/babel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/bootstrap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/bower.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/browsersync.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/coffeescript.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/foundation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/gulp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/haml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/handlebars.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/istanbul.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/jade.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/jasmine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/jshint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/karma.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/materialdesign.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/protractor.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/sass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/assets/original/sass.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/stylus.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/traceur.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/typescript.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/assets/original/webpack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 75b3f1c

Please sign in to comment.