build fiddling

This commit is contained in:
Mark Pilgrim
2009-06-05 00:58:26 -04:00
parent fad286c3fc
commit 97835d382a
5 changed files with 25 additions and 6 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ h1:before{content:""}
<ol>
<li>jQuery is served by <a href=http://code.google.com/apis/ajaxlibs/>Google AJAX Libraries API</a>.
<li>Other Javascript and CSS resources are minimized by <a href=http://developer.yahoo.com/yui/compressor/>YUI Compressor</a>.
<li>HTTP caching and other server-side options are optimized based on advice from <a href=http://developer.yahoo.com/yslow/>YSlow</a>.
<li>HTTP caching and other server-side options are optimized based on advice from <a href=http://developer.yahoo.com/yslow/>YSlow</a> and <a href=http://code.google.com/speed/page-speed/>Page Speed</a>.
<li>The text uses <a href=http://www.alanwood.net/unicode/unicode_samples.html>Unicode characters</a> in place of graphics wherever possible.
<li>The entire book was <a href=http://diveintomark.org/archives/2009/03/27/dive-into-history-2009-edition>lovingly hand-authored in HTML 5</a> to avoid markup cruft.
</ol>
+1 -1
View File
@@ -98,7 +98,7 @@ h1:before {
/* overrides */
.nm, .w, aside, form, form+p, .note span, .q span {
.nm, .w, aside, form, form+p, .note span, .q span, .a {
display:none;
}
dd {
+6
View File
@@ -49,6 +49,12 @@ echo "inlining CSS"
css=`cat build/$revision.css`
sed -i -e "s|<link rel=stylesheet href=dip3.css>|<style>${css}</style>|g" -e "s|</style><style>||g" build/*.html
# remove unused CSS properties on a page-by-page basis
echo "removing unused CSS"
for f in build/*.html; do
python2.6 util/lesscss.py "$f"
done
# secondary stylesheets will be served from a separate domain
echo "fixing hrefs"
sed -i -e "s|href=mobile.css|href=http://wearehugh.com/dip3/m-${revision}.css|g" build/*.html
-4
View File
@@ -1,9 +1,5 @@
#!/usr/bin/python3
# TODO:
# - fix internal xrefs (look for href=<in [chapters]>.html)
# - fix duplicate IDs
import re
# get list of chapters
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/python2.6
from pyquery import PyQuery as pq
import glob
import sys
filename = sys.argv[1]
pqd = pq(filename=filename)
raw_data = open(filename, 'rb').read()
original_css = raw_data.split('<style>', 1)[1].split('</style>', 1)[0]
new_css = ''
for rule in original_css.split('}')[:-1]:
selectors, properties = rule.split('{', 1)
selectors = ','.join([s for s in selectors.split(',') if pqd(s.split(':', 1)[0])])
if selectors:
new_css += '%s{%s}' % (selectors, properties)
open(filename, 'wb').write(raw_data.replace(original_css, new_css))