-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-aaronkmurray-site.bat
284 lines (186 loc) · 12.8 KB
/
build-aaronkmurray-site.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
@ECHO OFF
REM Do all of the prep-work steps required to build the aaronkmurray.com site
REM https://github.com/akmurray/aaronkmurray-blog-tools/blob/master/build/build-aaronkmurray-site.bat
REM --------------------------------------------------------------------------
REM Run Javascript Unit Tests - fail build if necessary
REM http://phantomjs.org/
REM http://pivotal.github.com/jasmine/
REM --------------------------------------------------------------------------
SET phantomjsErrFile=_phantomjs_results.txt
phantomjs.exe --web-security=false ../../aaronkmurray-blog/test/jasmine-standalone-1.2.0/lib/phantom-jasmine/run-jasmine-test.coffee ../../aaronkmurray-blog/test/jasmine-standalone-1.2.0/SpecRunner.html > %phantomjsErrFile%
IF ERRORLEVEL 2 GOTO phantomjs_errors
IF ERRORLEVEL 1 GOTO phantomjs_errors
IF ERRORLEVEL 0 GOTO phantomjs_success
:phantomjs_errors
ECHO phantomjs: errors found
notepad %phantomjsErrFile%
exit
:phantomjs_success
ECHO phantomjs: success
:phantomjs_post_success
REM --------------------------------------------------------------------------
REM Run Tidy to check for HTML warnings/errors and fail build if necessary
REM http://tidy.sourceforge.net/
REM ALT? http://home.ccil.org/~cowan/XML/tagsoup/
REM --------------------------------------------------------------------------
SET tidyErrFile=_tidy.index.html.errors.txt
tidy.exe -output _tidy.index.html.original.txt -file %tidyErrFile% ../../aaronkmurray-blog/index.html
IF ERRORLEVEL 2 GOTO tidy_errors
IF ERRORLEVEL 1 GOTO tidy_warnings
IF ERRORLEVEL 0 GOTO tidy_success
:tidy_errors
ECHO tidy: errors found
notepad %tidyErrFile%
exit
:tidy_warnings
ECHO tidy: Warnings found. Review the notepad file and close it to continue processing.
notepad %tidyErrFile%
REM don't kill the build on warnings, but show what they are
GOTO :tidy_post_success
:tidy_success
ECHO tidy: success
:tidy_post_success
REM --------------------------------------------------------------------------
REM Generate small post thumbnails
REM http://www.imagemagick.org/
REM --------------------------------------------------------------------------
REM Make post screenshot thumbnails if necessary
FOR /F %%A IN ('dir /b "../../aaronkmurray-blog/img/blog/screenshots/" ^|findstr /liv "thumb"') DO (
REM so that we can update variables inside a loop. Those variables are wrapped in "!" instead of "%"
SETLOCAL ENABLEDELAYEDEXPANSION
SET thumbName=%%~nA-thumb-100.png
SET thumbPath=../../aaronkmurray-blog/img/blog/screenshots/
SET thumbPathAndName=!thumbPath!!thumbName!
IF NOT EXIST !thumbPathAndName! (
ECHO Creating thumbnail for !thumbName!
convert.exe -thumbnail 100 !thumbPath!%%A !thumbPathAndName!
) ELSE (
REM ECHO Already created thumbnail for !thumbName!
)
)
REM --------------------------------------------------------------------------
REM Run CSS Preprocessor (SASS) to compile CSS and fail build if necessary
REM https://github.com/akmurray/aaronkmurray-blog-tools/tree/master/js-css/preprocessor
REM http://sass-lang.com
REM https://github.com/nex3/sass
REM --------------------------------------------------------------------------
SET cssPreProcess_ErrFileName=%~dp0_preprocessor.errors.txt
%~dp0preprocessor/preprocessor.exe -s:../../aaronkmurray-blog/ -pat:*.scss -err=%cssPreProcess_ErrFileName% -recurseDirs=true
IF ERRORLEVEL 2 GOTO cssPreProcess_errors
IF ERRORLEVEL 1 GOTO cssPreProcess_warnings
IF ERRORLEVEL 0 GOTO cssPreProcess_success
:cssPreProcess_errors
ECHO cssPreProcess: errors found
notepad %cssPreProcess_ErrFileName%
exit
:cssPreProcess_warnings
ECHO cssPreProcess: Warnings found. Review the messages above. Also review the notepad file and close it to continue processing.
notepad %cssPreProcess_ErrFileName%
REM GOTO :cssPreProcess_post_success
:cssPreProcess_success
ECHO cssPreProcess: success
:cssPreProcess_post_success
REM --------------------------------------------------------------------------
REM Create a CSS Sprite for small post thumbs
REM https://github.com/akmurray/aaronkmurray-blog-tools/tree/master/img/imgsprite
REM --------------------------------------------------------------------------
REM use imgsprite to make a css sprite for the thumbnail previews
imgsprite.exe -in:../../aaronkmurray-blog/img/blog/screenshots/*-thumb-100*.png -img-out:../../aaronkmurray-blog/img/blog/sprites/post-screenshot-thumbs-all.png -css-out:../../aaronkmurray-blog/css/sprites/post-screenshot-thumbs-all.css -css-class-name-prefix:img- -image-deploy-url-base:../../img/blog/sprites/ -gen-test-html:true -test-html-path:../../aaronkmurray-blog/test/sprites/ -test-html-deploy-url-base:../../img/blog/sprites/ -limit-bit-depth:8
REM use imgsprite to make a css sprite for site header & footer icons
imgsprite.exe -in:../../aaronkmurray-blog/img/blog/icons/*.png -img-out:../../aaronkmurray-blog/img/blog/sprites/blog-icons-all.png -css-out:../../aaronkmurray-blog/css/sprites/blog-icons-all.css -css-class-name-prefix:img- -image-deploy-url-base:../../img/blog/sprites/ -gen-test-html:true -test-html-path:../../aaronkmurray-blog/test/sprites/ -test-html-deploy-url-base:../../img/blog/sprites/
REM just here as a stub example for reducing an image to 8bpp
REM imgsprite.exe -in:../../aaronkmurray-blog/img/blog/posts/post-22-speed-affects-consumers.png -img-out:../../aaronkmurray-blog/img/blog/posts/post-22-speed-affects-consumers-8.png -css-out:delete_me.css -css-class-name-prefix:img- -image-deploy-url-base:/ -gen-test-html:false -limit-bit-depth:8
REM --------------------------------------------------------------------------
REM Run CSSLint (via Java/Rhino) to check for CSS warnings/errors and fail build if necessary
REM https://github.com/stubbornella/csslint
REM https://developer.mozilla.org/en-US/docs/Rhino
REM --------------------------------------------------------------------------
SET csslintErrFile=_csslint.errors.txt
"C:\Program Files (x86)\Java\jre7\bin\java" -jar rhino.jar csslint-rhino.js --ignore=ids,qualified-headings,unique-headings,duplicate-background-images,zero-units,outline-none,empty-rules,overqualified-elements,adjoining-classes --warnings=universal-selector ../../aaronkmurray-blog/css/ > %csslintErrFile%
IF ERRORLEVEL 2 GOTO csslint_errors
IF ERRORLEVEL 1 GOTO csslint_warnings
IF ERRORLEVEL 0 GOTO csslint_success
:csslint_errors
ECHO csslint: errors found
notepad %csslintErrFile%
exit
:csslint_warnings
ECHO csslint: Warnings found. Review the notepad file and close it to continue processing.
notepad %csslintErrFile%
REM don't kill the build on warnings, but show what they are
GOTO :csslint_post_success
:csslint_success
ECHO csslint: success
:csslint_post_success
REM Temp hack until I figure out why Rhino isn't returning the errorlevels from the command line
notepad %csslintErrFile%
REM --------------------------------------------------------------------------
REM Minify, Bundle, and Version: CSS and Javascript files
REM TODO: Need to get the file list for various bundles dynamically
REM TODO: Need to version the files
REM TODO: Need to have a "dev" path that doesn't require the bundling
REM https://github.com/akmurray/aaronkmurray-blog-tools
REM http://developer.yahoo.com/yui/compressor/
REM --------------------------------------------------------------------------
REM Examples for minifying a single file
REM bundler.exe -pathSource=..\..\aaronkmurray-blog\js\ -pathOutput=..\..\aaronkmurray-blog\js\min\XMLHttpRequest.2012.09.02.min.js -searchPattern="XMLHttpRequest.2012.09.02.js"
REM bundler.exe -pathSource=..\..\aaronkmurray-blog\js\ -pathOutput=..\..\aaronkmurray-blog\js\min\prototype-extensions.min.js -searchPattern="prototype-extensions.js"
REM bundler.exe -pathSource=..\..\aaronkmurray-blog\js\ -pathOutput=..\..\aaronkmurray-blog\js\min\akm-util.min.js -searchPattern="akm-util.js"
REM bundler.exe -pathSource=..\..\aaronkmurray-blog\js\ -pathOutput=..\..\aaronkmurray-blog\js\min\akm-gist.min.js -searchPattern="akm-gist.js"
REM bundler.exe -pathSource=..\..\aaronkmurray-blog\js\ -pathOutput=..\..\aaronkmurray-blog\js\min\akm-blog.min.js -searchPattern="akm-blog.js"
REM JS Minify multiple files into a fewer bundles (stable and volatile)
bundler.exe -pathSource=..\..\aaronkmurray-blog\js\ -pathOutput=..\..\aaronkmurray-blog\js\bundles\index.top.stable.min.js -searchPattern="XMLHttpRequest.2012.09.02.js|prototype-extensions.js" -headerComment=" Author / Merged by: Aaron Murray, [email protected], @aaronkmurray"
bundler.exe -pathSource=..\..\aaronkmurray-blog\js\ -pathOutput=..\..\aaronkmurray-blog\js\bundles\index.top.volatile.min.js -searchPattern="akm-util.js|akm-gist.js|akm-blog.js" -headerComment=" Author / Merged by: Aaron Murray, [email protected], @aaronkmurray"
REM CSS Minify multiple files into a fewer bundles (stable and volatile)
bundler.exe -pathSource=..\..\aaronkmurray-blog\css\ -pathOutput=..\..\aaronkmurray-blog\css\bundles\index.stable.min.css -searchPattern="blog-reset.css|blog-logo.css|sprites/blog-icons-all.css|sprites/sprite-logo.css|gist-embed.css" -headerComment=" Author / Merged by: Aaron Murray, [email protected], @aaronkmurray"
bundler.exe -pathSource=..\..\aaronkmurray-blog\css\ -pathOutput=..\..\aaronkmurray-blog\css\bundles\index.volatile.min.css -searchPattern="blog.css|sprites/post-screenshot-thumbs-all.css" -headerComment=" Author / Merged by: Aaron Murray, [email protected], @aaronkmurray"
REM Example for using YUI from the jar...not fun to work with. Need a working directory to not mess with originals
REM xcopy /Y /R /V /I "..\..\aaronkmurray-blog\js\*.js" "..\..\aaronkmurray-blog\js\bundles"
REM REM "C:\Program Files (x86)\Java\jre7\bin\java" -jar yuicompressor-2.4.7.jar --nomunge --line-break 0 -o '.js$:-min.js' ../../aaronkmurray-blog/js/min/*.js
REM REM "C:\Program Files (x86)\Java\jre7\bin\java" -jar yuicompressor-2.4.7.jar --nomunge --line-break 0 -o '.js$:../../aaronkmurray-blog/js/min/akm-blog-min.js' ../../aaronkmurray-blog/js/min/akm-blog.js
REM REM "C:\Program Files (x86)\Java\jre7\bin\java" -jar yuicompressor-2.4.7.jar --nomunge --line-break 0 -o ../../aaronkmurray-blog/js/min/akm-blog.js ../../aaronkmurray-blog/js/min/akm-blog.js
REM --------------------------------------------------------------------------
REM TODO Minify HTML
REM Possible Future Step (just testing for now)
REM HTML minification nets approx 10% filesize reduction
REM Straight gzip on unminified HTML went from 59KB to 18KB...so we can realistically expect this to only have a 1% actual improvement
REM http://code.google.com/p/htmlcompressor/
REM --------------------------------------------------------------------------
REM 59->55KB java -jar htmlcompressor-1.5.3.jar -o ../../aaronkmurray-blog/index.min.html ../../aaronkmurray-blog/index.html
REM 59->54.5KB java -jar htmlcompressor-1.5.3.jar --preserve-line-breaks -o ../../aaronkmurray-blog/index.min.html ../../aaronkmurray-blog/index.html
REM 59->54KB java -jar htmlcompressor-1.5.3.jar --preserve-line-breaks --remove-quotes --remove-intertag-spaces -o ../../aaronkmurray-blog/index.min.html ../../aaronkmurray-blog/index.html
REM 59->53.5KB java -jar htmlcompressor-1.5.3.jar --preserve-line-breaks --remove-quotes --remove-intertag-spaces --remove-http-protocol --remove-surrounding-spaces all -o ../../aaronkmurray-blog/index.min.html ../../aaronkmurray-blog/index.html
REM --------------------------------------------------------------------------
REM Generate RSS/ATOM feeds and fail build if necessary
REM https://github.com/akmurray/aaronkmurray-blog-tools/tree/master/rss/rssgen
REM --------------------------------------------------------------------------
REM use RSSGEN to build rss feed
rssgen.exe -s=../../aaronkmurray-blog/index.html -o=../../aaronkmurray-blog/feeds/feed-rss.xml -f=rss
IF ERRORLEVEL 2 GOTO rssgen_error
IF ERRORLEVEL 1 GOTO rssgen_warning
IF ERRORLEVEL 0 GOTO rssgen_xml_success
:rssgen_xml_success
REM use RSSGEN to build atom feed
rssgen.exe -s=../../aaronkmurray-blog/index.html -o=../../aaronkmurray-blog/feeds/feed-atom.xml -f=atom
IF ERRORLEVEL 2 GOTO rssgen_error
IF ERRORLEVEL 1 GOTO rssgen_warning
IF ERRORLEVEL 0 GOTO rssgen_atom_success
:rssgen_error
:rssgen_warning
ECHO rssgen: errors found
exit
:rssgen_atom_success
REM --------------------------------------------------------------------------
REM Compress images to save bandwidth
REM https://github.com/akmurray/aaronkmurray-blog-tools/tree/master/img/imgsqz
REM --------------------------------------------------------------------------
REM use imgsqz to losslessly compress the filesize of images
imgsqz.exe -s=../../aaronkmurray-blog/
REM --------------------------------------------------------------------------
REM COMPLETE!
REM --------------------------------------------------------------------------
ECHO ............................................
ECHO Build Complete at %date% %time%
ECHO ............................................
REM just pause the screen so we can see the output (remove after you get the point)
pause