@@ -9,8 +9,10 @@ var Generator = module.exports = function Generator(args, options) {
99 yeoman . generators . Base . apply ( this , arguments ) ;
1010 this . argument ( 'appname' , { type : String , required : false } ) ;
1111 this . appname = this . appname || path . basename ( process . cwd ( ) ) ;
12+ this . indexFile = this . engine ( this . read ( '../../templates/common/index.html' ) ,
13+ this ) ;
1214
13- var args = [ 'main' ] ;
15+ args = [ 'main' ] ;
1416
1517 if ( typeof this . env . options . appPath === 'undefined' ) {
1618 try {
@@ -146,33 +148,69 @@ Generator.prototype.askForModules = function askForModules() {
146148 } . bind ( this ) ) ;
147149} ;
148150
149- // Duplicated from the SASS generator, waiting a solution for #138
151+ // Waiting a more flexible solution for #138
150152Generator . prototype . bootstrapFiles = function bootstrapFiles ( ) {
151- var appPath = this . appPath ;
152-
153153 if ( this . compassBootstrap ) {
154- var cb = this . async ( ) ;
155-
156- this . write ( path . join ( appPath , 'styles/main.scss' ) , '@import "compass_twitter_bootstrap";' ) ;
157- this . remote ( 'vwall' , 'compass-twitter-bootstrap' , 'v2.2.2.2' , function ( err , remote ) {
158- if ( err ) {
159- return cb ( err ) ;
160- }
161- remote . directory ( 'stylesheets' , path . join ( appPath , 'styles' ) ) ;
162- cb ( ) ;
163- } ) ;
154+ this . copy ( 'styles/bootstrap.scss' , path . join ( this . appPath , 'styles/style.scss' ) ) ;
155+ this . indexFile = this . appendStyles ( this . indexFile , 'styles/main.css' , [ 'styles/style.css' ] ) ;
164156 } else if ( this . bootstrap ) {
165157 this . log . writeln ( 'Writing compiled Bootstrap' ) ;
166- this . copy ( 'bootstrap.css' , path . join ( appPath , 'styles/bootstrap.css' ) ) ;
158+ var cssFiles = [ 'styles/bootstrap.css' , 'styles/main.css' ] ;
159+
160+ cssFiles . forEach ( function ( css ) {
161+ this . copy ( css , path . join ( this . appPath , css ) ) ;
162+ } . bind ( this ) ) ;
163+ this . indexFile = this . appendStyles ( this . indexFile , 'styles/main.css' , cssFiles ) ;
164+ }
165+ } ;
166+
167+ Generator . prototype . bootstrapJS = function bootstrapJS ( ) {
168+ if ( ! this . bootstrap ) {
169+ return ; // Skip if disabled.
167170 }
168171
169- if ( this . bootstrap || this . compassBootstrap ) {
170- // this.directory('images', 'app/images');
172+ // Wire Twitter Bootstrap plugins
173+ this . indexFile = this . appendScripts ( this . indexFile , 'scripts/plugins.js' , [
174+ 'components/jquery/jquery.js' ,
175+ 'components/bootstrap-sass/js/bootstrap-affix.js' ,
176+ 'components/bootstrap-sass/js/bootstrap-alert.js' ,
177+ 'components/bootstrap-sass/js/bootstrap-dropdown.js' ,
178+ 'components/bootstrap-sass/js/bootstrap-tooltip.js' ,
179+ 'components/bootstrap-sass/js/bootstrap-modal.js' ,
180+ 'components/bootstrap-sass/js/bootstrap-transition.js' ,
181+ 'components/bootstrap-sass/js/bootstrap-button.js' ,
182+ 'components/bootstrap-sass/js/bootstrap-popover.js' ,
183+ 'components/bootstrap-sass/js/bootstrap-typeahead.js' ,
184+ 'components/bootstrap-sass/js/bootstrap-carousel.js' ,
185+ 'components/bootstrap-sass/js/bootstrap-scrollspy.js' ,
186+ 'components/bootstrap-sass/js/bootstrap-collapse.js' ,
187+ 'components/bootstrap-sass/js/bootstrap-tab.js'
188+ ] ) ;
189+ } ;
190+
191+ Generator . prototype . extraModules = function extraModules ( ) {
192+ var modules = [ ] ;
193+ if ( this . resourceModule ) {
194+ modules . push ( 'components/angular-resource/angular-resource.js' ) ;
171195 }
196+
197+ if ( this . cookiesModule ) {
198+ modules . push ( 'components/angular-cookies/angular-cookies.js' ) ;
199+ }
200+
201+ if ( this . sanitizeModule ) {
202+ modules . push ( 'components/angular-sanitize/angular-sanitize.js' ) ;
203+ }
204+
205+ if ( modules . length ) {
206+ this . indexFile = this . appendScripts ( this . indexFile , 'scripts/modules.js' ,
207+ modules ) ;
208+ }
209+
172210} ;
173211
174212Generator . prototype . createIndexHtml = function createIndexHtml ( ) {
175- this . template ( '../../templates/common/index.html' , path . join ( this . appPath , 'index.html' ) ) ;
213+ this . write ( path . join ( this . appPath , 'index.html' ) , this . indexFile ) ;
176214} ;
177215
178216Generator . prototype . packageFiles = function ( ) {
0 commit comments