Merge lp:~tveronezi/juju-gui/make-build into lp:juju-gui/experimental

Proposed by Thiago Veronezi
Status: Merged
Approved by: Gary Poster
Approved revision: 257
Merged at revision: 251
Proposed branch: lp:~tveronezi/juju-gui/make-build
Merge into: lp:juju-gui/experimental
Diff against target: 438 lines (+83/-146)
10 files modified
.bzrignore (+1/-9)
Makefile (+33/-31)
app/index.html (+3/-3)
app/views/environment.js (+1/-0)
bin/merge-files (+20/-36)
grunt.js (+3/-3)
lib/server.js (+15/-60)
lib/templates.js (+2/-2)
test-server.js (+4/-1)
test/index.html (+1/-1)
To merge this branch: bzr merge lp:~tveronezi/juju-gui/make-build
Reviewer Review Type Date Requested Status
Juju GUI Hackers Pending
Review via email: mp+134706@code.launchpad.net

Description of the change

Makefile does not support static file deployment

Full description here: https://bugs.launchpad.net/juju-gui/+bug/1078898

This branch does not support CSS minification. It only combines the third-party css files. The minification of the YUI and our custom CSS files is covered by another branch;

The "make debug" command starts the node.js server with the debug version of our application;

The "make server" command starts a python SimpleHTTPServer service with the production version of our application. Note that it is not possible to use REST with this version. It will be covered by another card;

https://codereview.appspot.com/6844061/

To post a comment you must log in.
Revision history for this message
Thiago Veronezi (tveronezi) wrote :

Reviewers: mp+134706_code.launchpad.net,

Message:
Please take a look.

Description:
Makefile does not support static file deployment

Full description here: https://bugs.launchpad.net/juju-gui/+bug/1078898

This branch does not support CSS minification. It only combines the
third-party css files. The minification of the YUI and our custom CSS
files is covered by another branch;

The "make debug" command starts the node.js server with the debug
version of our application;

The "make server" command starts a python SimpleHTTPServer service with
the production version of our application. Note that it is not possible
to use REST with this version. It will be covered by another card;

https://code.launchpad.net/~tveronezi/juju-gui/make-build/+merge/134706

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/6844061/

Affected files:
   M .bzrignore
   M Makefile
   A [revision details]
   M app/index.html
   M bin/merge-files
   M grunt.js
   M lib/server.js
   M lib/templates.js

lp:~tveronezi/juju-gui/make-build updated
252. By Thiago Veronezi

personal code review

Revision history for this message
Thiago Veronezi (tveronezi) wrote :

https://codereview.appspot.com/6844061/diff/1/bin/merge-files
File bin/merge-files (right):

https://codereview.appspot.com/6844061/diff/1/bin/merge-files#newcode63
bin/merge-files:63: filesToLoad.js.push.apply(filesToLoad.js, [
'./app/assets/javascripts/d3.v2.min.js',
Please, ignore this long line. Its is already fixed.

https://codereview.appspot.com/6844061/

Revision history for this message
Brad Crittenden (bac) wrote :

Thiago I think the work you've done here is good. I'm a bit unclear how
much still needs to be done to finish off this refactoring of the build
structure.

Thanks for tackling it. The branch looks good to land after you make
the changes suggested and weigh the other ones.

https://codereview.appspot.com/6844061/diff/1/Makefile
File Makefile (right):

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode18
Makefile:18: PRODUCTION_FILES=build/juju-ui/assets/modules.js \
I'd be tempted to make a symbol for 'build/juju-ui/assets' since it is
repeated so often.

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode89
Makefile:89: @cd build && python -m SimpleHTTPServer 8888
I'm unhappy that the magic port 8888 is found four times in our code and
twice in documentation. I wish it were possible to define it once,
somewhere but am at a loss for how to do it.

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode94
Makefile:94: @rm -Rf build/
Yay, the clean target is much simplified.

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode100
Makefile:100:
I'm concerned about separate build and install targets and having
template.js in a separate rule from the others. Seems complicated and
twisty.

https://codereview.appspot.com/6844061/diff/1/app/index.html
File app/index.html (right):

https://codereview.appspot.com/6844061/diff/1/app/index.html#newcode14
app/index.html:14: <link rel="stylesheet"
href="http://yui.yahooapis.com/combo?3.8.0pr1/build/slider-base/assets/skins/sam/slider-base.css">
Is this safe? The URL with an embedded version number looks fragile.

https://codereview.appspot.com/6844061/diff/1/app/index.html#newcode15
app/index.html:15: <link>
What is the second <link> for?

https://codereview.appspot.com/6844061/diff/1/grunt.js
File grunt.js (right):

https://codereview.appspot.com/6844061/diff/1/grunt.js#newcode8
grunt.js:8: outputImage: 'stylesheets/sprite.png',
I guess putting sprites in 'stylesheets' is a lie we can live with.

https://codereview.appspot.com/6844061/

lp:~tveronezi/juju-gui/make-build updated
253. By Thiago Veronezi

code review

Revision history for this message
Thiago Veronezi (tveronezi) wrote :

Thanks for your review Brad!

https://codereview.appspot.com/6844061/diff/1/Makefile
File Makefile (right):

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode18
Makefile:18: PRODUCTION_FILES=build/juju-ui/assets/modules.js \
On 2012/11/19 18:18:58, bac wrote:
> I'd be tempted to make a symbol for 'build/juju-ui/assets' since it is
repeated
> so often.

Done.

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode89
Makefile:89: @cd build && python -m SimpleHTTPServer 8888
On 2012/11/19 18:18:58, bac wrote:
> I'm unhappy that the magic port 8888 is found four times in our code
and twice
> in documentation. I wish it were possible to define it once,
somewhere but am
> at a loss for how to do it.

I agree. I would like to create another card under the "Needs
specification" group for it, so we can discuss this issue later. Is that
ok?

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode94
Makefile:94: @rm -Rf build/
On 2012/11/19 18:18:58, bac wrote:
> Yay, the clean target is much simplified.

:O)

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode100
Makefile:100:
On 2012/11/19 18:18:58, bac wrote:
> I'm concerned about separate build and install targets and having
template.js in
> a separate rule from the others. Seems complicated and twisty.

True. "install" does not mean "install". IMO "install" should be renamed
to "generate-files", or something like that. wdyt?

template.js should be in a separated rule, so we can determine when we
should execute it, right? The same applies to the sprites.

https://codereview.appspot.com/6844061/diff/1/app/index.html
File app/index.html (right):

https://codereview.appspot.com/6844061/diff/1/app/index.html#newcode14
app/index.html:14: <link rel="stylesheet"
href="http://yui.yahooapis.com/combo?3.8.0pr1/build/slider-base/assets/skins/sam/slider-base.css">
On 2012/11/19 18:18:58, bac wrote:
> Is this safe? The URL with an embedded version number looks fragile.

True. I've investigated it a little bit further, and it works if I add
the 'slider-base' requirement to the environment.js file. Tkx Brad!

https://codereview.appspot.com/6844061/diff/1/app/index.html#newcode15
app/index.html:15: <link>
On 2012/11/19 18:18:58, bac wrote:
> What is the second <link> for?
for nothing :)
Removed tkx.

https://codereview.appspot.com/6844061/diff/1/grunt.js
File grunt.js (right):

https://codereview.appspot.com/6844061/diff/1/grunt.js#newcode8
grunt.js:8: outputImage: 'stylesheets/sprite.png',
On 2012/11/19 18:18:58, bac wrote:
> I guess putting sprites in 'stylesheets' is a lie we can live with.

I agree.

https://codereview.appspot.com/6844061/

Revision history for this message
Gary Poster (gary) wrote :

Thanks Thiago. This is a nice improvement. Once we have the CSS
changes, and we no longer have the slow initial combo CSS load from YUI,
this will be really nice to use. I have some small suggestions for the
Makefile, in line with Brad's comments.

https://codereview.appspot.com/6844061/diff/1/.bzrignore
File .bzrignore (right):

https://codereview.appspot.com/6844061/diff/1/.bzrignore#newcode16
.bzrignore:16: build
Nice simplification and clean-up.

https://codereview.appspot.com/6844061/diff/1/Makefile
File Makefile (right):

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode100
Makefile:100:
On 2012/11/19 18:18:58, bac wrote:
> I'm concerned about separate build and install targets and having
template.js in
> a separate rule from the others. Seems complicated and twisty.

Having "build" depend on "install" also seems odd, conceptually.

Does the "install" target bring any value? That is, is there any use
case for running it alone? If not, I suggest combining it and "build"
into the "build" target (and deleting the "install" target). What do
you two think of that?

https://codereview.appspot.com/6844061/diff/1/lib/server.js
File lib/server.js (right):

https://codereview.appspot.com/6844061/diff/1/lib/server.js#newcode57
lib/server.js:57: res.sendfile('build/juju-ui/assets/' + fileName);
Interesting. I wanted the development server code to be even simpler
than this, but I can see why what you did is compelling. I would be
tempted to experiment with converting the js files to symlinks in a
later branch and simplifying this code. This is an improvement anyway,
though, and maybe my hunch won't work out.

https://codereview.appspot.com/6844061/

lp:~tveronezi/juju-gui/make-build updated
254. By Thiago Veronezi

code review

255. By Thiago Veronezi

trunk merge

256. By Thiago Veronezi

code review

257. By Thiago Veronezi

code review

Revision history for this message
Thiago Veronezi (tveronezi) wrote :

Thanks Gary for your review!

https://codereview.appspot.com/6844061/diff/1/.bzrignore
File .bzrignore (right):

https://codereview.appspot.com/6844061/diff/1/.bzrignore#newcode16
.bzrignore:16: build
On 2012/11/19 19:00:33, gary.poster wrote:
> Nice simplification and clean-up.

Ohhh yeah. :O)

https://codereview.appspot.com/6844061/diff/1/Makefile
File Makefile (right):

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode100
Makefile:100:
On 2012/11/19 19:00:33, gary.poster wrote:
> On 2012/11/19 18:18:58, bac wrote:
> > I'm concerned about separate build and install targets and having
template.js
> in
> > a separate rule from the others. Seems complicated and twisty.

> Having "build" depend on "install" also seems odd, conceptually.

> Does the "install" target bring any value? That is, is there any use
case for
> running it alone? If not, I suggest combining it and "build" into the
"build"
> target (and deleting the "install" target). What do you two think of
that?

Ah... I see! I will delete the "install" target and change the "build"
target from...

build: install

... to...

build: appcache $(NODE_TARGETS) build/juju-ui/templates.js yuidoc
spritegen combinejs

Is that ok?

https://codereview.appspot.com/6844061/diff/1/lib/server.js
File lib/server.js (right):

https://codereview.appspot.com/6844061/diff/1/lib/server.js#newcode57
lib/server.js:57: res.sendfile('build/juju-ui/assets/' + fileName);
On 2012/11/19 19:00:33, gary.poster wrote:
> Interesting. I wanted the development server code to be even simpler
than this,
> but I can see why what you did is compelling. I would be tempted to
experiment
> with converting the js files to symlinks in a later branch and
simplifying this
> code. This is an improvement anyway, though, and maybe my hunch won't
work out.

I needed to change the "test-server.js" file too. The tests were broken
due to the new notification stuff. I've tried to use the symbolic link
approach in order to avoid it, but with no success.

I will use the "new branch" option to do it. Thanks.

https://codereview.appspot.com/6844061/

Revision history for this message
Thiago Veronezi (tveronezi) wrote :
Revision history for this message
Gary Poster (gary) wrote :

Good, Thiago, thank you. The slow CSS loading is the only downside for
putting this branch in staging, and if you can follow it quickly with
the CSS branch then I think it will be great.

+1!

Gary

https://codereview.appspot.com/6844061/diff/1/Makefile
File Makefile (right):

https://codereview.appspot.com/6844061/diff/1/Makefile#newcode89
Makefile:89: @cd build && python -m SimpleHTTPServer 8888
On 2012/11/19 18:50:59, thiago wrote:
> On 2012/11/19 18:18:58, bac wrote:
> > I'm unhappy that the magic port 8888 is found four times in our code
and twice
> > in documentation. I wish it were possible to define it once,
somewhere but am
> > at a loss for how to do it.

> I agree. I would like to create another card under the "Needs
specification"
> group for it, so we can discuss this issue later. Is that ok?

If you have any ideas on what we can do, +1. Otherwise, eh, don't
bother IMO.

https://codereview.appspot.com/6844061/diff/1/lib/server.js
File lib/server.js (right):

https://codereview.appspot.com/6844061/diff/1/lib/server.js#newcode57
lib/server.js:57: res.sendfile('build/juju-ui/assets/' + fileName);
On 2012/11/19 20:23:19, thiago wrote:
> On 2012/11/19 19:00:33, gary.poster wrote:
> > Interesting. I wanted the development server code to be even
simpler than
> this,
> > but I can see why what you did is compelling. I would be tempted to
> experiment
> > with converting the js files to symlinks in a later branch and
simplifying
> this
> > code. This is an improvement anyway, though, and maybe my hunch
won't work
> out.

> I needed to change the "test-server.js" file too. The tests were
broken due to
> the new notification stuff. I've tried to use the symbolic link
approach in
> order to avoid it, but with no success.

> I will use the "new branch" option to do it. Thanks.

Cool. I'm not sure it is that worth it to mess with it, given that you
have already experimented with it. That said, bug 1078910 will lead to
a natural opportunity to investigate.

https://codereview.appspot.com/6844061/diff/6002/Makefile
File Makefile (right):

https://codereview.appspot.com/6844061/diff/6002/Makefile#newcode16
Makefile:16: BUILD_ASSETS_DIR=build/juju-ui/assets
This ends up saving two characters per reference. :-) I guess it is
still an advantage to prevent typos though. Well...not even much there,
since bash doesn't have errors for unknown names. I dunno, I'm
certainly fine with this, but it didn't end up helping much IMO. Maybe
bac has a different suggestion for a name?

https://codereview.appspot.com/6844061/diff/6002/Makefile#newcode95
Makefile:95: build: appcache $(NODE_TARGETS) build/juju-ui/templates.js
yuidoc spritegen combinejs
I think "build" is the right name logically. benji might not like the
fact that we are breaking backwards compatibility for the dev
experience, but since the "all" target is equivalent and still works, I
think it is fine.

https://codereview.appspot.com/6844061/

Revision history for this message
Thiago Veronezi (tveronezi) wrote :

*** Submitted:

Makefile does not support static file deployment

Full description here: https://bugs.launchpad.net/juju-gui/+bug/1078898

This branch does not support CSS minification. It only combines the
third-party css files. The minification of the YUI and our custom CSS
files is covered by another branch;

The "make debug" command starts the node.js server with the debug
version of our application;

The "make server" command starts a python SimpleHTTPServer service with
the production version of our application. Note that it is not possible
to use REST with this version. It will be covered by another card;

R=bac, gary.poster
CC=
https://codereview.appspot.com/6844061

https://codereview.appspot.com/6844061/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2012-11-13 15:04:19 +0000
3+++ .bzrignore 2012-11-19 20:22:19 +0000
4@@ -3,22 +3,14 @@
5 gui.sublime-project
6 .emacs.desktop.lock
7 gui.sublime-workspace
8-app/templates.js
9-app/assets/stylesheets/juju-gui.css
10 app/assets/javascripts/d3.v2.js
11 app/assets/javascripts/d3.v2.min.js
12 app/assets/javascripts/yui
13-app/templates.js
14-app/assets/stylesheets/juju-gui.css
15 docs/_build/doctrees
16 docs/_build/html
17 *~
18-app/assets/stylesheets/juju-gui.css
19 tags
20 Session.vim
21 virtualenv
22 yuidoc
23-app/assets/manifest.appcache
24-app/assets/sprite
25-app/assets/javascripts/generated/
26-app/assets/stylesheets/all-static.css
27+build
28
29=== modified file 'Makefile'
30--- Makefile 2012-11-15 13:07:29 +0000
31+++ Makefile 2012-11-19 20:22:19 +0000
32@@ -13,18 +13,20 @@
33 node_modules/node-minify
34 TEMPLATE_TARGETS=$(shell bzr ls -k file app/templates)
35 SPRITE_SOURCE_FILES=$(shell bzr ls -R -k file app/assets/images)
36-SPRITE_GENERATED_FILES=app/assets/sprite/sprite.css app/assets/sprite/sprite.png
37-COMPRESSED_FILES=app/assets/javascripts/generated/all-app-debug.js \
38- app/assets/javascripts/generated/all-app.js \
39- app/assets/javascripts/generated/all-third.js \
40- app/assets/javascripts/generated/all-yui.js \
41- app/assets/stylesheets/all-static.css
42+BUILD_ASSETS_DIR=build/juju-ui/assets
43+SPRITE_GENERATED_FILES=$(BUILD_ASSETS_DIR)/stylesheets/sprite.css \
44+ $(BUILD_ASSETS_DIR)/stylesheets/sprite.png
45+PRODUCTION_FILES=$(BUILD_ASSETS_DIR)/modules.js \
46+ $(BUILD_ASSETS_DIR)/config.js \
47+ $(BUILD_ASSETS_DIR)/app.js \
48+ $(BUILD_ASSETS_DIR)/stylesheets/all-static.css
49 DATE=$(shell date -u)
50-APPCACHE=app/assets/manifest.appcache
51-
52-all: install
53-
54-app/templates.js: $(TEMPLATE_TARGETS) bin/generateTemplates
55+APPCACHE=$(BUILD_ASSETS_DIR)/manifest.appcache
56+
57+all: build
58+
59+build/juju-ui/templates.js: $(TEMPLATE_TARGETS) bin/generateTemplates
60+ @test -d "$(BUILD_ASSETS_DIR)/stylesheets" || mkdir -p "$(BUILD_ASSETS_DIR)/stylesheets"
61 @./bin/generateTemplates
62
63 yuidoc/index.html: node_modules/yuidocjs $(JSFILES)
64@@ -34,8 +36,6 @@
65
66 $(SPRITE_GENERATED_FILES): node_modules/grunt node_modules/node-spritesheet $(SPRITE_SOURCE_FILES)
67 @node_modules/grunt/bin/grunt spritegen
68- @rm -Rf app/assets/sprite/
69- @mv bin/sprite app/assets
70
71 $(NODE_TARGETS): package.json
72 @npm install
73@@ -43,8 +43,6 @@
74 @ln -sf `pwd`/node_modules/yui ./app/assets/javascripts/
75 @ln -sf `pwd`/node_modules/d3/d3.v2* ./app/assets/javascripts/
76
77-install: appcache $(NODE_TARGETS) app/templates.js yuidoc spritegen combinejs
78-
79 gjslint: virtualenv/bin/gjslint
80 @virtualenv/bin/gjslint --strict --nojsdoc --jslint_error=all \
81 --custom_jsdoc_tags module,main,class,method,event,property,attribute,submodule,namespace,extends,config,constructor,static,final,readOnly,writeOnce,optional,required,param,return,for,type,private,protected,requires,default,uses,example,chainable,deprecated,since,async,beta,bubbles,extension,extensionfor,extension_for \
82@@ -67,36 +65,40 @@
83
84 spritegen: $(SPRITE_GENERATED_FILES)
85
86-$(COMPRESSED_FILES): node_modules/yui node_modules/d3/d3.v2.min.js $(JSFILES) ./bin/merge-files
87- @rm -f app/assets/stylesheets/all-static.css
88- @rm -Rf app/assets/javascripts/generated/
89- @mkdir app/assets/javascripts/generated/
90+$(PRODUCTION_FILES): node_modules/yui node_modules/d3/d3.v2.min.js $(JSFILES) ./bin/merge-files
91+ @rm -f $(PRODUCTION_FILES)
92+ @test -d "$(BUILD_ASSETS_DIR)/stylesheets" || mkdir -p "$(BUILD_ASSETS_DIR)/stylesheets"
93 @./bin/merge-files
94+ @cp app/modules.js $(BUILD_ASSETS_DIR)/modules.js
95+ @cp app/config.js $(BUILD_ASSETS_DIR)/config.js
96
97-combinejs: $(COMPRESSED_FILES)
98+combinejs: $(PRODUCTION_FILES)
99
100 prep: beautify lint
101
102-test: install
103+test: build
104 @./test-server.sh
105
106-debug: install
107- @echo "Customize config.js to modify server settings"
108- @node server.js debug
109-
110-server: install
111+debug: build
112 @echo "Customize config.js to modify server settings"
113 @node server.js
114
115+server: build
116+ @echo "Runnning the application from a SimpleHTTPServer"
117+ @cd build && python -m SimpleHTTPServer 8888
118+
119 clean:
120 @rm -rf node_modules virtualenv
121 @make -C docs clean
122- @rm -Rf bin/sprite/
123- @rm -Rf app/assets/sprite/
124- @rm -Rf app/assets/javascripts/generated/
125- @rm -f app/assets/stylesheets/all-static.css
126+ @rm -Rf build/
127+
128+build: appcache $(NODE_TARGETS) build/juju-ui/templates.js yuidoc spritegen combinejs
129+ @cp -f app/index.html build/
130+ @cp -rf app/assets/images $(BUILD_ASSETS_DIR)/images
131+ @cp -rf app/assets/svgs $(BUILD_ASSETS_DIR)/svgs
132
133 $(APPCACHE): manifest.appcache.in
134+ @test -d "build/juju-ui/assets" || mkdir -p "build/juju-ui/assets"
135 @cp manifest.appcache.in $(APPCACHE)
136 @sed -re 's/^\# TIMESTAMP .+$$/\# TIMESTAMP $(DATE)/' -i $(APPCACHE)
137
138@@ -110,6 +112,6 @@
139 # appcache, and this provides the correct order.
140 appcache-force: appcache-touch appcache
141
142-.PHONY: test lint beautify server install clean prep jshint gjslint \
143+.PHONY: test lint beautify server build clean prep jshint gjslint \
144 appcache appcache-touch appcache-force yuidoc spritegen yuidoc-lint \
145 combinejs
146
147=== modified file 'app/index.html'
148--- app/index.html 2012-11-15 15:44:00 +0000
149+++ app/index.html 2012-11-19 20:22:19 +0000
150@@ -9,7 +9,7 @@
151 <link href='http://fonts.googleapis.com/css?family=Ubuntu:400,400italic&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
152 <link rel="stylesheet" href="/juju-ui/assets/stylesheets/all-static.css">
153 <link rel="stylesheet" href="/juju-ui/assets/stylesheets/juju-gui.css">
154- <link rel="stylesheet" href="/juju-ui/assets/sprite/sprite.css">
155+ <link rel="stylesheet" href="/juju-ui/assets/stylesheets/sprite.css">
156 <!--[if lt IE 9]>
157 <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
158 <![endif]-->
159@@ -68,9 +68,9 @@
160 <div id="vp-right-border"></div>
161 </div>
162 <!-- javascript away -->
163- <script src="/juju-ui/assets/yui.js"></script>
164- <script src="/juju-ui/assets/all-third.js"></script>
165+ <script src="/juju-ui/assets/app.js"></script>
166 <script src="/juju-ui/assets/modules.js"></script>
167+ <script src="/juju-ui/assets/config.js"></script>
168 <script>
169 YUI(GlobalConfig).use(["juju-gui"], function(Y) {
170 app = new Y.juju.App(juju_config);
171
172=== modified file 'app/views/environment.js'
173--- app/views/environment.js 2012-11-19 16:20:21 +0000
174+++ app/views/environment.js 2012-11-19 20:22:19 +0000
175@@ -1814,5 +1814,6 @@
176 'svg-layouts',
177 'event-resize',
178 'slider',
179+ 'slider-base',
180 'view']
181 });
182
183=== modified file 'bin/merge-files'
184--- bin/merge-files 2012-11-15 13:07:29 +0000
185+++ bin/merge-files 2012-11-19 20:22:19 +0000
186@@ -30,8 +30,7 @@
187 syspath = require('path'),
188 paths,
189 reqs,
190- filesToLoad,
191- thirdPartyCSS;
192+ filesToLoad;
193
194 // First we find all of the paths to our custom Javascript in the app
195 // directory. We need to tell the function to ignore the "assets" directory
196@@ -42,6 +41,9 @@
197 [syspath.join(process.cwd(), './app/assets'),
198 syspath.join(process.cwd(), './app/modules-debug.js')]);
199
200+ // templates.js is a generated file. It is not part of the app directory.
201+ paths.push(syspath.join(process.cwd(), './build/juju-ui/templates.js'));
202+
203 // Get the name of all the YUI modules that our custom js files use directly.
204 reqs = merge.loadRequires(paths);
205
206@@ -56,41 +58,23 @@
207
208 // Get all of the YUI files and their dependencies
209 filesToLoad = merge.getYUIFiles(reqs);
210- thirdPartyCSS = filesToLoad.css;
211- thirdPartyCSS.push('./app/assets/stylesheets/bootstrap-2.0.4.css');
212- thirdPartyCSS.push('./app/assets/stylesheets/bootstrap-responsive-2.0.4.css');
213- console.log('CSS: ' + thirdPartyCSS);
214-
215- // Combine YUI js files
216+
217+ // Merge third-party files to the filesToLoad list
218+ filesToLoad.js.push.apply(filesToLoad.js, [
219+ './app/assets/javascripts/d3.v2.min.js',
220+ './app/assets/javascripts/d3-components.js',
221+ './app/assets/javascripts/reconnecting-websocket.js',
222+ './app/assets/javascripts/svg-layouts.js' ]);
223+
224+ // Merge our list of custom js files to the filesToLoad list
225+ filesToLoad.js.push.apply(filesToLoad.js, paths);
226+
227+ // Combine YUI and our js files
228 merge.combine(filesToLoad.js,
229- './app/assets/javascripts/generated/all-yui.js', 'uglifyjs');
230+ './build/juju-ui/assets/app.js', 'uglifyjs');
231
232 // Combine third party css files
233- merge.combine(thirdPartyCSS,
234- './app/assets/stylesheets/all-static.css', 'yui-css');
235-
236- // Combine third party js libraries
237- merge.combine([ './app/assets/javascripts/d3.v2.min.js',
238- './app/assets/javascripts/d3-components.js',
239- './app/assets/javascripts/reconnecting-websocket.js',
240- './app/assets/javascripts/svg-layouts.js' ],
241- './app/assets/javascripts/generated/all-third-min.js', 'uglifyjs');
242-
243- // It has only one file but eventually it will have more.
244- merge.combine([ './app/assets/javascripts/d3.v2.js' ],
245- './app/assets/javascripts/generated/all-third.js', 'uglifyjs');
246-
247- // Now we only need to generate the file that is used to tell YUI where all
248- // the dependencies are. We either use a debug version or the production
249- // version. The debug version is simply pointers to the individual files.
250- // The production version aggregates all of the files together.
251-
252- // Creating the combined file for the modules-debug.js and config.js files
253- merge.combine(['./app/modules-debug.js', './app/config.js'],
254- './app/assets/javascripts/generated/all-app-debug.js');
255-
256- // Creating the combined file for all our files. Note that this includes
257- // app/modules.js in the rollup, which is why that file still needs exist.
258- merge.combine(paths, './app/assets/javascripts/generated/all-app.js',
259- 'uglifyjs');
260+ merge.combine([ './app/assets/stylesheets/bootstrap-2.0.4.css',
261+ './app/assets/stylesheets/bootstrap-responsive-2.0.4.css' ],
262+ './build/juju-ui/assets/stylesheets/all-static.css', 'yui-css');
263 });
264
265=== modified file 'grunt.js'
266--- grunt.js 2012-11-06 12:28:51 +0000
267+++ grunt.js 2012-11-19 20:22:19 +0000
268@@ -5,13 +5,13 @@
269 spritesheet: {
270 compile: {
271 options: {
272- outputImage: 'sprite/sprite.png',
273- outputCss: 'sprite/sprite.css',
274+ outputImage: 'stylesheets/sprite.png',
275+ outputCss: 'stylesheets/sprite.css',
276 selector: '.sprite'
277
278 },
279 files: {
280- 'bin': 'app/assets/images/*'
281+ 'build/juju-ui/assets': 'app/assets/images/*'
282 }
283 }
284 }
285
286=== modified file 'lib/server.js'
287--- lib/server.js 2012-11-15 13:07:29 +0000
288+++ lib/server.js 2012-11-19 20:22:19 +0000
289@@ -5,35 +5,10 @@
290 fs = require('fs'),
291 path = require('path'),
292 config = require('../config').config.server,
293- debugMode = (String(process.argv[2]).toLowerCase() === 'debug'),
294 public_dir = config.public_dir,
295 Templates = require('./templates.js'),
296 view = require('./view.js');
297
298-
299-/**
300- * It finds a file under the given path. The first match wins.
301- * @param {string} path starting point.
302- * @param {string} fileName name of the file to be found.
303- * @return {string} the file path.
304- */
305-function findFile(path, fileName) {
306- var file, files = fs.readdirSync(path);
307- for (var i = 0; i < files.length; i = i + 1) {
308- if (files[i] === fileName) {
309- return path + '/' + files[i];
310- }
311- file = fs.statSync(path + '/' + files[i]);
312- if (file.isDirectory()) {
313- file = findFile(path + '/' + files[i], fileName);
314- if (file) {
315- return file;
316- }
317- }
318- }
319- return null;
320-}
321-
322 server.configure(function() {
323 server.set('views', __dirname + './lib/views/');
324 server.set('view engine', 'handlebars');
325@@ -70,47 +45,27 @@
326 });
327 });
328
329-server.get('/juju-ui/assets/all-third.js', function(req, res) {
330- if (debugMode) {
331- res.sendfile('app/assets/javascripts/generated/all-third.js');
332- } else {
333- res.sendfile('app/assets/javascripts/generated/all-third-min.js');
334- }
335-});
336-
337-server.get('/juju-ui/assets/modules.js', function(req, res) {
338- if (debugMode) {
339- res.sendfile('app/assets/javascripts/generated/all-app-debug.js');
340- } else {
341- res.sendfile('app/assets/javascripts/generated/all-app.js');
342- }
343-});
344-
345-server.get('/juju-ui/assets/yui.js', function(req, res) {
346- if (debugMode) {
347+server.get('/juju-ui/assets/:file', function(req, res) {
348+ var fileName = req.params.file;
349+ if ('app.js' === fileName) {
350 res.sendfile('app/assets/javascripts/yui/yui/yui-debug.js');
351+ } else if ('modules.js' === fileName) {
352+ res.sendfile('app/modules-debug.js');
353+ } else if ('config.js' === fileName) {
354+ res.sendfile('app/config.js');
355 } else {
356- res.sendfile('app/assets/javascripts/generated/all-yui.js');
357+ res.sendfile('build/juju-ui/assets/' + fileName);
358 }
359 });
360
361+server.get('/juju-ui/:file', function(req, res) {
362+ var fileName = req.params.file;
363+ res.sendfile('build/juju-ui/' + fileName);
364+});
365+
366 server.get('/juju-ui/assets/stylesheets/:file', function(req, res) {
367- var file, fileName = req.params.file;
368- if (path.extname(fileName).toLowerCase() === '.css') {
369- res.sendfile('app/assets/stylesheets/' + fileName);
370- } else {
371- // We've merged all the yui and third party files into a single css file.
372- // YUI expects to load its images from the same path as its css files, so
373- // we need to mock this position. When the system tries to load a resource
374- // from "app/assets/stylesheets/", it tries to find this resource under the
375- // "./app/assets" directory. The first match wins. Another solution would
376- // be to manually copy all the images we need to the
377- // "./app/assets/stylesheets" directory.
378- // This is an example of image...
379- // ./yui/datatable-sort/assets/skins/sam/sort-arrow-sprite-ie.png
380- file = findFile('./app/assets', fileName);
381- res.sendfile(file);
382- }
383+ var fileName = req.params.file;
384+ res.sendfile('build/juju-ui/assets/stylesheets/' + fileName);
385 });
386
387 server.get('*', function(req, res) {
388
389=== modified file 'lib/templates.js'
390--- lib/templates.js 2012-09-26 23:31:13 +0000
391+++ lib/templates.js 2012-11-19 20:22:19 +0000
392@@ -122,7 +122,7 @@
393
394 var templateSpecs = {
395 templates: {
396- output: __dirname + '/../app/templates.js',
397+ output: __dirname + '/../build/juju-ui/templates.js',
398 callback: function(strategy, name) {
399 cache = {};
400 getPrecompiled();
401@@ -138,7 +138,7 @@
402 },
403
404 stylesheet: {
405- output: __dirname + '/../app/assets/stylesheets/juju-gui.css',
406+ output: __dirname + '/../build/juju-ui/assets/stylesheets/juju-gui.css',
407 callback: function(strategy, name) {
408 var parser = new less.Parser({
409 paths: [config.server.view_dir],
410
411=== modified file 'test-server.js'
412--- test-server.js 2012-10-31 10:57:16 +0000
413+++ test-server.js 2012-11-19 20:22:19 +0000
414@@ -17,7 +17,10 @@
415 server.use(express.methodOverride());
416 });
417
418-
419+server.get('/juju-ui/:file', function(req, res) {
420+ var fileName = req.params.file;
421+ res.sendfile('build/juju-ui/' + fileName);
422+});
423
424 var port = 8084;
425
426
427=== modified file 'test/index.html'
428--- test/index.html 2012-11-15 15:30:59 +0000
429+++ test/index.html 2012-11-19 20:22:19 +0000
430@@ -48,7 +48,7 @@
431 continue
432 }
433 resource.fullpath = resource.fullpath.replace(
434- '/juju-ui/', '../app/', 1);
435+ '/juju-ui/', '../juju-ui/', 1);
436 }
437 }
438 // Load before test runner

Subscribers

People subscribed via source and target branches