@@ -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 {
@@ -144,33 +146,69 @@ Generator.prototype.askForModules = function askForModules() {
144146 } . bind ( this ) ) ;
145147} ;
146148
147- // Duplicated from the SASS generator, waiting a solution for #138
149+ // Waiting a more flexible solution for #138
148150Generator . prototype . bootstrapFiles = function bootstrapFiles ( ) {
149- var appPath = this . appPath ;
150-
151151 if ( this . compassBootstrap ) {
152- var cb = this . async ( ) ;
153-
154- this . write ( path . join ( appPath , 'styles/main.scss' ) , '@import "compass_twitter_bootstrap";' ) ;
155- this . remote ( 'vwall' , 'compass-twitter-bootstrap' , 'v2.2.2.2' , function ( err , remote ) {
156- if ( err ) {
157- return cb ( err ) ;
158- }
159- remote . directory ( 'stylesheets' , path . join ( appPath , 'styles' ) ) ;
160- cb ( ) ;
161- } ) ;
152+ this . copy ( 'styles/bootstrap.scss' , path . join ( this . appPath , 'styles/style.scss' ) ) ;
153+ this . indexFile = this . appendStyles ( this . indexFile , 'styles/main.css' , [ 'styles/style.css' ] ) ;
162154 } else if ( this . bootstrap ) {
163155 this . log . writeln ( 'Writing compiled Bootstrap' ) ;
164- this . copy ( 'bootstrap.css' , path . join ( appPath , 'styles/bootstrap.css' ) ) ;
156+ var cssFiles = [ 'styles/bootstrap.css' , 'styles/main.css' ] ;
157+
158+ cssFiles . forEach ( function ( css ) {
159+ this . copy ( css , path . join ( this . appPath , css ) ) ;
160+ } . bind ( this ) ) ;
161+ this . indexFile = this . appendStyles ( this . indexFile , 'styles/main.css' , cssFiles ) ;
162+ }
163+ } ;
164+
165+ Generator . prototype . bootstrapJS = function bootstrapJS ( ) {
166+ if ( ! this . bootstrap ) {
167+ return ; // Skip if disabled.
165168 }
166169
167- if ( this . bootstrap || this . compassBootstrap ) {
168- // this.directory('images', 'app/images');
170+ // Wire Twitter Bootstrap plugins
171+ this . indexFile = this . appendScripts ( this . indexFile , 'scripts/plugins.js' , [
172+ 'components/jquery/jquery.js' ,
173+ 'components/bootstrap-sass/js/bootstrap-affix.js' ,
174+ 'components/bootstrap-sass/js/bootstrap-alert.js' ,
175+ 'components/bootstrap-sass/js/bootstrap-dropdown.js' ,
176+ 'components/bootstrap-sass/js/bootstrap-tooltip.js' ,
177+ 'components/bootstrap-sass/js/bootstrap-modal.js' ,
178+ 'components/bootstrap-sass/js/bootstrap-transition.js' ,
179+ 'components/bootstrap-sass/js/bootstrap-button.js' ,
180+ 'components/bootstrap-sass/js/bootstrap-popover.js' ,
181+ 'components/bootstrap-sass/js/bootstrap-typeahead.js' ,
182+ 'components/bootstrap-sass/js/bootstrap-carousel.js' ,
183+ 'components/bootstrap-sass/js/bootstrap-scrollspy.js' ,
184+ 'components/bootstrap-sass/js/bootstrap-collapse.js' ,
185+ 'components/bootstrap-sass/js/bootstrap-tab.js'
186+ ] ) ;
187+ } ;
188+
189+ Generator . prototype . extraModules = function extraModules ( ) {
190+ var modules = [ ] ;
191+ if ( this . resourceModule ) {
192+ modules . push ( 'components/angular-resource/angular-resource.js' ) ;
169193 }
194+
195+ if ( this . cookiesModule ) {
196+ modules . push ( 'components/angular-cookies/angular-cookies.js' ) ;
197+ }
198+
199+ if ( this . sanitizeModule ) {
200+ modules . push ( 'components/angular-sanitize/angular-sanitize.js' ) ;
201+ }
202+
203+ if ( modules . length ) {
204+ this . indexFile = this . appendScripts ( this . indexFile , 'scripts/modules.js' ,
205+ modules ) ;
206+ }
207+
170208} ;
171209
172210Generator . prototype . createIndexHtml = function createIndexHtml ( ) {
173- this . template ( '../../templates/common/index.html' , path . join ( this . appPath , 'index.html' ) ) ;
211+ this . write ( path . join ( this . appPath , 'index.html' ) , this . indexFile ) ;
174212} ;
175213
176214Generator . prototype . packageFiles = function ( ) {
0 commit comments