Merge lp:~gary/juju-gui/favicon into lp:juju-gui/experimental

Proposed by Gary Poster on 2012-11-20
Status: Merged
Merged at revision: 253
Proposed branch: lp:~gary/juju-gui/favicon
Merge into: lp:juju-gui/experimental
Diff against target: 247 lines (+110/-48)
3 files modified
Makefile (+105/-48)
app/index.html (+1/-0)
lib/server.js (+4/-0)
To merge this branch: bzr merge lp:~gary/juju-gui/favicon
Reviewer Review Type Date Requested Status
Brad Crittenden (community) 2012-11-20 Approve on 2012-11-20
Review via email: mp+135045@code.launchpad.net

Description of the Change

Add favicon, tweak Makefile

Added the juju icon as a favicon, and then got lost in Makefile tweaks. Makefile now does not do unnecessary work, and no longer hides commands with @ so that we can see when we reintroduce unnecessary work. Also switch from a Makefile comment about the node_modules to a message generated by the Makefile.

https://codereview.appspot.com/6842072/

To post a comment you must log in.
Brad Crittenden (bac) wrote :

Hi Gary,

Thanks for the clean up to the Makefile and the addition of the favicon. I hadn't missed it before but think it'll be nice to have.

I took the liberty of making a card for this task assuming you just forgot. Also I couldn't find a Rietveld proposal for this work so I'm reviewing old school.

Unfortunately, running 'make server' locally I do not see the favicon show up in Chromium (and FF is hopelessly broken ATM). Looking at the downloaded resources I see it was served up but it does not show in the address bar. Are you actually seeing it?

I'm a bit confused by the NODE_TARGETS / EXPECTED_NODE_TARGETS / FOUND_NODE_TARGETS dance. I assume we can't just compute FOUND_NODE_TARGETS and use it directly. If that is really the case could you document exactly what is going on lest someone like the Future Me try to undo your work?

The 'test -d' before 'mkdir -p' is nice but unnecessary ask 'mkdir -p' will happily do a no-op and exit with 0 if the directory already exists. I see it used in a few places.

Otherwise it looks good and is easier to follow. Thanks.

review: Approve
Gary Poster (gary) wrote :

Reviewers: mp+135045_code.launchpad.net,

Message:
Please take a look.

Description:
Add favicon, tweak Makefile

Added the juju icon as a favicon, and then got lost in Makefile tweaks.
Makefile now does not do unnecessary work, and no longer hides commands
with @ so that we can see when we reintroduce unnecessary work. Also
switch from a Makefile comment about the node_modules to a message
generated by the Makefile; maybe this should cause the make to fail, so
that we actually force this to be maintained?

https://code.launchpad.net/~gary/juju-gui/favicon/+merge/135045

(do not edit description out of merge proposal)

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

Affected files:
   M Makefile
   A [revision details]
   A app/favicon.ico

lp:~gary/juju-gui/favicon updated on 2012-11-20
253. By Gary Poster on 2012-11-20

get debug and FF working

Thiago Veronezi (tveronezi) wrote :

Thanks Gary!
Seems good to me.

+1

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

https://codereview.appspot.com/6842072/diff/1/Makefile#newcode27
Makefile:27: test -d "$(BUILD_ASSETS_DIR)/stylesheets" || mkdir -p
"$(BUILD_ASSETS_DIR)/stylesheets"
Whats wrong with the use of "@"? Don't we like it any more? :O)

https://codereview.appspot.com/6842072/diff/1/Makefile#newcode42
Makefile:42: @# Check to see if we made what we expected to make, and
warn if we did not.
Do we need this @ before the comment?

https://codereview.appspot.com/6842072/

Gary Poster (gary) wrote :

Thank you, Thiago. Replies below. I'm happy to make a change if you
prefer, but until you tell me otherwise I'm going to proceed with the
understanding that you are fine with it as is.

Gary

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

https://codereview.appspot.com/6842072/diff/1/Makefile#newcode27
Makefile:27: test -d "$(BUILD_ASSETS_DIR)/stylesheets" || mkdir -p
"$(BUILD_ASSETS_DIR)/stylesheets"
On 2012/11/20 14:33:56, thiago wrote:
> Whats wrong with the use of "@"? Don't we like it any more? :O)
:-) "@" hides context when there are errors, and it hides the fact that
code is being re-run when it should not be in the Makefile. IMO, the
only advantage used to be that it made restarting the server (or running
tests or whatever) quieter, but now with the changes I've made it is
pretty quiet unless it is actually doing work. It didn't seem to get in
my way.

https://codereview.appspot.com/6842072/diff/1/Makefile#newcode42
Makefile:42: @# Check to see if we made what we expected to make, and
warn if we did not.
On 2012/11/20 14:33:56, thiago wrote:
> Do we need this @ before the comment?

If you don't, it is sent to stdout, and in this particular case I didn't
think it brought value to have it in stdout. Maybe that's
idiosyncratic; if someone removes I'd be fine with it.

https://codereview.appspot.com/6842072/

lp:~gary/juju-gui/favicon updated on 2012-11-20
254. By Gary Poster on 2012-11-20

respond to bac review

Gary Poster (gary) wrote :

> Hi Gary,

Hi Brad. Thank you for the review. Replies inline.

>
> Thanks for the clean up to the Makefile and the addition of the favicon. I
> hadn't missed it before but think it'll be nice to have.
>
> I took the liberty of making a card for this task assuming you just forgot.
> Also I couldn't find a Rietveld proposal for this work so I'm reviewing old
> school.

Yes, thank you. Sorry, it was an evening hack that got bigger than I intended.

>
> Unfortunately, running 'make server' locally I do not see the favicon show up
> in Chromium (and FF is hopelessly broken ATM). Looking at the downloaded
> resources I see it was served up but it does not show in the address bar. Are
> you actually seeing it?

Yes. As I mentioned on IRC, it was not working in debug mode, and I fixed that. Firefox seemed happier when I was explicit about the ico file also, though that should not be necessary. I tested it on another computer as well and it seemed ok to me.

>
> I'm a bit confused by the NODE_TARGETS / EXPECTED_NODE_TARGETS /
> FOUND_NODE_TARGETS dance. I assume we can't just compute FOUND_NODE_TARGETS
> and use it directly. If that is really the case could you document exactly
> what is going on lest someone like the Future Me try to undo your work?

Good call. I added a comment and got your approval on IRC.

>
> The 'test -d' before 'mkdir -p' is nice but unnecessary ask 'mkdir -p' will
> happily do a no-op and exit with 0 if the directory already exists. I see it
> used in a few places.

Nice improvement, yes. Changed.

>
> Otherwise it looks good and is easier to follow. Thanks.

Thank you!

Gary

Gary Poster (gary) wrote :

*** Submitted:

Add favicon, tweak Makefile

Added the juju icon as a favicon, and then got lost in Makefile tweaks.
Makefile now does not do unnecessary work, and no longer hides commands
with @ so that we can see when we reintroduce unnecessary work. Also
switch from a Makefile comment about the node_modules to a message
generated by the Makefile.

R=thiago
CC=
https://codereview.appspot.com/6842072

https://codereview.appspot.com/6842072/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2012-11-19 20:20:50 +0000
3+++ Makefile 2012-11-20 15:12:20 +0000
4@@ -1,16 +1,14 @@
5 JSFILES=$(shell bzr ls -RV -k file | grep -E -e '.+\.js(on)?$$|generateTemplates$$' | grep -Ev -e '^manifest\.json$$' -e '^test/assets/' -e '^app/assets/javascripts/reconnecting-websocket.js$$' -e '^server.js$$')
6
7-# After a successful "make" run, the NODE_TARGETS list can be regenerated with
8-# this command (and then manually pasted in here):
9-# find node_modules -maxdepth 1 -mindepth 1 -type d -printf 'node_modules/%f '
10-NODE_TARGETS=node_modules/minimatch node_modules/cryptojs \
11- node_modules/yuidocjs node_modules/chai node_modules/less \
12- node_modules/.bin node_modules/node-markdown node_modules/rimraf \
13- node_modules/mocha node_modules/d3 node_modules/graceful-fs \
14- node_modules/should node_modules/jshint node_modules/expect.js \
15- node_modules/express node_modules/yui node_modules/yuidoc \
16- node_modules/grunt node_modules/node-spritesheet \
17- node_modules/node-minify
18+NODE_TARGETS=node_modules/chai node_modules/cryptojs node_modules/d3 \
19+ node_modules/expect.js node_modules/express node_modules/graceful-fs \
20+ node_modules/grunt node_modules/jshint node_modules/less \
21+ node_modules/minimatch node_modules/mocha node_modules/node-markdown \
22+ node_modules/node-minify node_modules/node-spritesheet \
23+ node_modules/rimraf node_modules/should node_modules/yui \
24+ node_modules/yuidocjs
25+EXPECTED_NODE_TARGETS=$(shell echo "$(NODE_TARGETS)" | tr ' ' '\n' | sort | tr '\n' ' ')
26+
27 TEMPLATE_TARGETS=$(shell bzr ls -k file app/templates)
28 SPRITE_SOURCE_FILES=$(shell bzr ls -R -k file app/assets/images)
29 BUILD_ASSETS_DIR=build/juju-ui/assets
30@@ -26,92 +24,151 @@
31 all: build
32
33 build/juju-ui/templates.js: $(TEMPLATE_TARGETS) bin/generateTemplates
34- @test -d "$(BUILD_ASSETS_DIR)/stylesheets" || mkdir -p "$(BUILD_ASSETS_DIR)/stylesheets"
35- @./bin/generateTemplates
36+ mkdir -p "$(BUILD_ASSETS_DIR)/stylesheets"
37+ ./bin/generateTemplates
38
39 yuidoc/index.html: node_modules/yuidocjs $(JSFILES)
40- @node_modules/.bin/yuidoc -o yuidoc -x assets app
41+ node_modules/.bin/yuidoc -o yuidoc -x assets app
42
43 yuidoc: yuidoc/index.html
44
45 $(SPRITE_GENERATED_FILES): node_modules/grunt node_modules/node-spritesheet $(SPRITE_SOURCE_FILES)
46- @node_modules/grunt/bin/grunt spritegen
47+ node_modules/grunt/bin/grunt spritegen
48
49 $(NODE_TARGETS): package.json
50- @npm install
51- @#link depends
52- @ln -sf `pwd`/node_modules/yui ./app/assets/javascripts/
53- @ln -sf `pwd`/node_modules/d3/d3.v2* ./app/assets/javascripts/
54+ npm install
55+ # Keep all targets up to date, not just new/changed ones.
56+ for dirname in $(NODE_TARGETS); do touch $$dirname ; done
57+ @# Check to see if we made what we expected to make, and warn if we did not.
58+ @# Note that we calculate FOUND_TARGETS here, in this way and not in the
59+ @# standard Makefile way, because we need to see what node_modules were
60+ @# created by this target. Makefile variables and substitutions, even when
61+ @# using $(eval...) within a target, happen initially, before the target
62+ @# is run. Therefore, if this were a simple Makefile variable, it
63+ @# would be empty after a first run, and you would always see the warning
64+ @# message in that case. We have to connect it to the "if" command with
65+ @# "; \" because Makefile targets are evaluated per line, with bash
66+ @# variables discarded between them. We compare the result with
67+ @# EXPECTED_NODE_TARGETS and not simply the NODE_TARGETS because this
68+ @# gives us normalization, particularly of the trailing whitespace, that
69+ @# we do not otherwise have.
70+ @FOUND_TARGETS=$$(find node_modules -maxdepth 1 -mindepth 1 -type d \
71+ -printf 'node_modules/%f ' | tr ' ' '\n' | grep -Ev '\.bin$$' \
72+ | sort | tr '\n' ' '); \
73+ if [ "$$FOUND_TARGETS" != "$(EXPECTED_NODE_TARGETS)" ]; then \
74+ echo; \
75+ echo "******************************************************************"; \
76+ echo "******************************************************************"; \
77+ echo "******************************************************************"; \
78+ echo "******************************************************************"; \
79+ echo "IMPORTANT: THE NODE_TARGETS VARIABLE IN THE MAKEFILE SHOULD CHANGE"; \
80+ echo "******************************************************************"; \
81+ echo "******************************************************************"; \
82+ echo "******************************************************************"; \
83+ echo "******************************************************************"; \
84+ echo; \
85+ echo "Change it to the following."; \
86+ echo; \
87+ echo $$FOUND_TARGETS; \
88+ fi
89+
90+app/assets/javascripts/yui: node_modules/yui
91+ ln -sf `pwd`/node_modules/yui ./app/assets/javascripts/
92+
93+node_modules/d3/d3.v2.js node_modules/d3/d3.v2.min.js: node_modules/d3
94+
95+app/assets/javascripts/d3.v2.js: node_modules/d3/d3.v2.js
96+ ln -sf `pwd`/node_modules/d3/d3.v2.js ./app/assets/javascripts/d3.v2.js
97+
98+app/assets/javascripts/d3.v2.min.js: node_modules/d3/d3.v2.min.js
99+ ln -sf `pwd`/node_modules/d3/d3.v2.min.js ./app/assets/javascripts/d3.v2.min.js
100+
101+javascript_libraries: app/assets/javascripts/yui \
102+ app/assets/javascripts/d3.v2.js app/assets/javascripts/d3.v2.min.js
103
104 gjslint: virtualenv/bin/gjslint
105- @virtualenv/bin/gjslint --strict --nojsdoc --jslint_error=all \
106+ virtualenv/bin/gjslint --strict --nojsdoc --jslint_error=all \
107 --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 \
108 $(JSFILES)
109
110 jshint: node_modules/jshint
111- @node_modules/jshint/bin/hint $(JSFILES)
112+ node_modules/jshint/bin/hint $(JSFILES)
113
114 yuidoc-lint: $(JSFILES)
115- @bin/lint-yuidoc
116+ bin/lint-yuidoc
117
118 lint: gjslint jshint yuidoc-lint
119
120 virtualenv/bin/gjslint virtualenv/bin/fixjsstyle:
121- @virtualenv virtualenv
122- @virtualenv/bin/easy_install archives/closure_linter-latest.tar.gz
123+ virtualenv virtualenv
124+ virtualenv/bin/easy_install archives/closure_linter-latest.tar.gz
125
126 beautify: virtualenv/bin/fixjsstyle
127- @virtualenv/bin/fixjsstyle --strict --nojsdoc --jslint_error=all $(JSFILES)
128+ virtualenv/bin/fixjsstyle --strict --nojsdoc --jslint_error=all $(JSFILES)
129
130 spritegen: $(SPRITE_GENERATED_FILES)
131
132 $(PRODUCTION_FILES): node_modules/yui node_modules/d3/d3.v2.min.js $(JSFILES) ./bin/merge-files
133- @rm -f $(PRODUCTION_FILES)
134- @test -d "$(BUILD_ASSETS_DIR)/stylesheets" || mkdir -p "$(BUILD_ASSETS_DIR)/stylesheets"
135- @./bin/merge-files
136- @cp app/modules.js $(BUILD_ASSETS_DIR)/modules.js
137- @cp app/config.js $(BUILD_ASSETS_DIR)/config.js
138+ rm -f $(PRODUCTION_FILES)
139+ mkdir -p "$(BUILD_ASSETS_DIR)/stylesheets"
140+ ./bin/merge-files
141+ cp app/modules.js $(BUILD_ASSETS_DIR)/modules.js
142+ cp app/config.js $(BUILD_ASSETS_DIR)/config.js
143
144 combinejs: $(PRODUCTION_FILES)
145
146 prep: beautify lint
147
148 test: build
149- @./test-server.sh
150+ ./test-server.sh
151
152 debug: build
153 @echo "Customize config.js to modify server settings"
154- @node server.js
155+ node server.js
156
157 server: build
158- @echo "Runnning the application from a SimpleHTTPServer"
159- @cd build && python -m SimpleHTTPServer 8888
160+ @echo "Running the application from a SimpleHTTPServer"
161+ cd build && python -m SimpleHTTPServer 8888
162
163 clean:
164- @rm -rf node_modules virtualenv
165- @make -C docs clean
166- @rm -Rf build/
167-
168-build: appcache $(NODE_TARGETS) build/juju-ui/templates.js yuidoc spritegen combinejs
169- @cp -f app/index.html build/
170- @cp -rf app/assets/images $(BUILD_ASSETS_DIR)/images
171- @cp -rf app/assets/svgs $(BUILD_ASSETS_DIR)/svgs
172+ rm -rf node_modules virtualenv
173+ make -C docs clean
174+ rm -Rf build/
175+
176+build/index.html: app/index.html
177+ cp -f app/index.html build/
178+
179+build/favicon.ico: app/favicon.ico
180+ cp -f app/favicon.ico build/
181+
182+$(BUILD_ASSETS_DIR)/images: $(SPRITE_SOURCE_FILES)
183+ cp -rf app/assets/images $(BUILD_ASSETS_DIR)/images
184+
185+$(BUILD_ASSETS_DIR)/svgs: $(shell bzr ls -R -k file app/assets/svgs)
186+ cp -rf app/assets/svgs $(BUILD_ASSETS_DIR)/svgs
187+
188+build_images: build/favicon.ico $(BUILD_ASSETS_DIR)/images \
189+ $(BUILD_ASSETS_DIR)/svgs
190+
191+build: appcache $(NODE_TARGETS) javascript_libraries \
192+ build/juju-ui/templates.js yuidoc spritegen \
193+ combinejs build/index.html build_images
194
195 $(APPCACHE): manifest.appcache.in
196- @test -d "build/juju-ui/assets" || mkdir -p "build/juju-ui/assets"
197- @cp manifest.appcache.in $(APPCACHE)
198- @sed -re 's/^\# TIMESTAMP .+$$/\# TIMESTAMP $(DATE)/' -i $(APPCACHE)
199+ mkdir -p "build/juju-ui/assets"
200+ cp manifest.appcache.in $(APPCACHE)
201+ sed -re 's/^\# TIMESTAMP .+$$/\# TIMESTAMP $(DATE)/' -i $(APPCACHE)
202
203 appcache: $(APPCACHE)
204
205 # A target used only for forcibly updating the appcache.
206 appcache-touch:
207- @touch manifest.appcache.in
208+ touch manifest.appcache.in
209
210 # This is the real target. appcache-touch needs to be executed before
211 # appcache, and this provides the correct order.
212 appcache-force: appcache-touch appcache
213
214-.PHONY: test lint beautify server build clean prep jshint gjslint \
215+.PHONY: test lint beautify server clean build_images prep jshint gjslint \
216 appcache appcache-touch appcache-force yuidoc spritegen yuidoc-lint \
217- combinejs
218+ combinejs javascript_libraries
219
220=== added file 'app/favicon.ico'
221Binary files app/favicon.ico 1970-01-01 00:00:00 +0000 and app/favicon.ico 2012-11-20 15:12:20 +0000 differ
222=== modified file 'app/index.html'
223--- app/index.html 2012-11-19 18:49:43 +0000
224+++ app/index.html 2012-11-20 15:12:20 +0000
225@@ -7,6 +7,7 @@
226 <meta name="description" content="">
227 <meta name="author" content="Juju team">
228 <link href='http://fonts.googleapis.com/css?family=Ubuntu:400,400italic&subset=latin,latin-ext' rel='stylesheet' type='text/css'>
229+ <link rel="shortcut icon" href="/favicon.ico">
230 <link rel="stylesheet" href="/juju-ui/assets/stylesheets/all-static.css">
231 <link rel="stylesheet" href="/juju-ui/assets/stylesheets/juju-gui.css">
232 <link rel="stylesheet" href="/juju-ui/assets/stylesheets/sprite.css">
233
234=== modified file 'lib/server.js'
235--- lib/server.js 2012-11-16 16:20:13 +0000
236+++ lib/server.js 2012-11-20 15:12:20 +0000
237@@ -68,6 +68,10 @@
238 res.sendfile('build/juju-ui/assets/stylesheets/' + fileName);
239 });
240
241+server.get('/favicon.ico', function(req, res) {
242+ res.sendfile('app/favicon.ico');
243+});
244+
245 server.get('*', function(req, res) {
246 res.sendfile('app/index.html');
247 });

Subscribers

People subscribed via source and target branches