diff --git a/index.html b/index.html index 6207cca..abdf69e 100644 --- a/index.html +++ b/index.html @@ -21,10 +21,12 @@ h1:before,h2:before{content:''}
Dive Into Python 3 covers Python 3 and its differences from Python 2. Compared to Dive Into Python, it’s about 20% revised and 80% new material. I am publishing drafts online as I go. Please send feedback. The final version will be published on paper by Apress. The book will remain online under the CC-BY-SA-3.0 license. +
Dive Into Python 3 covers Python 3 and its differences from Python 2. Compared to Dive Into Python, it’s about 20% revised and 80% new material. The book is now complete, but feedback is always welcome.
Also available on dead trees!
Pre-order now, get it October 16th!
+
There is a changelog, a feed, and discussion on Reddit. During development, you can download the book by cloning the Mercurial repository: +
The book is freely licensed under the Creative Commons Attribution Share-Alike license. You can download it in HTML or PDF, or by cloning the Mercurial repository: -
you@localhost:~$ hg clone http://hg.diveintopython3.org/ diveintopython3+
you@localhost:~$ hg clone http://hg.diveintopython3.org/ diveintopython3-
The final version will be downloadable as HTML and PDF. +
This site is optimized for Lynx just because fuck you.
I’m told it also looks good in graphical browsers.
diff --git a/prince.css b/prince.css
index 25d03b8..5dbf409 100644
--- a/prince.css
+++ b/prince.css
@@ -54,3 +54,6 @@ h3 {
ul, ol {
margin: 1.75em 20pt;
}
+abbr {
+ text-decoration: none;
+}
diff --git a/publish b/publish
index a9404d7..984c598 100755
--- a/publish
+++ b/publish
@@ -9,10 +9,12 @@ die () {
echo "started build"
revision=`hg tip | grep changeset|cut -d":" -f2|cut -d" " -f4`
+today=`date +"%Y-%m-%d"`
# make build directory and copy original files there for preflighting
rm -rf build
mkdir build
+mkdir build/d
cp robots.txt *.css build/
cp -R j build/
cp -R i build/
@@ -21,8 +23,9 @@ cp -R examples build/
cp .htaccess build/
echo "building HTML distribution"
-htmldir=build/diveintopython3-r"$revision"
-mkdir "$htmldir"
+htmlbasedir=diveintopython3-r"$revision"-"$today"
+htmldir=build/"$htmlbasedir"
+mkdir -p "$htmldir"
cp *.html "$htmldir"/
cp dip3.css "$htmldir"/
mkdir "$htmldir"/i
@@ -32,8 +35,26 @@ cp j/dip3.js j/html5.js j/jquery.js j/prettify.js "$htmldir"/j/
mkdir "$htmldir"/examples
cp examples/*.jpg examples/*.json examples/*.pickle examples/*.py examples/*.txt examples/*.xml "$htmldir"/examples/
cd build/ && \
- zip -9rq diveintopython3-r"$revision".zip diveintopython3-r"$revision" && \
+ zip -9rq diveintopython3-html-r"$revision"-"$today".zip "$htmlbasedir" && \
cd ..
+echo "Redirect /d/diveintopython3-html-latest.zip http://diveintopython3.org/d/diveintopython3-html-r$revision-$today.zip" >> build/d/.htaccess
+mv "$htmldir" "$htmldir".html.bak
+
+echo "building PDF distribution"
+python3 util/flatten.py # outputs to build/single.html
+pdfbasedir="$htmlbasedir"
+pdfdir="$htmldir"
+mkdir -p "$pdfdir"
+pdffile="$pdfdir"/diveintopython3-r"$revision".pdf
+prince --style=prince.css --output="$pdffile" build/single.html 2>build/prince.log
+mkdir "$pdfdir"/examples
+cp examples/*.jpg examples/*.json examples/*.pickle examples/*.py examples/*.txt examples/*.xml "$pdfdir"/examples/
+cd build/ && \
+ zip -9rq diveintopython3-pdf-r"$revision"-"$today".zip "$pdfbasedir" && \
+cd ..
+echo "Redirect /d/diveintopython3-pdf-latest.zip http://diveintopython3.org/d/diveintopython3-pdf-r$revision-$today.zip" >> build/d/.htaccess
+mv "$pdfdir" "$pdfdir".pdf.bak
+mv build/single.html build/single.html.bak
echo "linting JS"
@@ -104,7 +125,10 @@ chmod 755 build/examples build/j build/i && \
# ship it!
echo -n "publishing"
-rsync -essh -a build/i/* build/i/.htaccess diveintomark.org:~/web/wearehugh.com/dip3/ && \
+die "Intentionally aborting without publishing"
+rsync -essh -a build/d/.htaccess build/*.zip diveintomark.org:~/web/diveintopython3.org/d/ && \
+ echo -n "." && \
+ rsync -essh -a build/i/* build/i/.htaccess diveintomark.org:~/web/wearehugh.com/dip3/ && \
echo -n "." && \
rsync -essh -a build/j/$revision.js build/j/html5.js build/j/.htaccess diveintomark.org:~/web/diveintopython3.org/j/ && \
echo -n "." && \
diff --git a/util/flatten.py b/util/flatten.py
index 3f3bc8f..ca5debe 100644
--- a/util/flatten.py
+++ b/util/flatten.py
@@ -1,6 +1,7 @@
#!/usr/bin/python3
import re
+import time
# get list of chapters
chapters = []
@@ -17,7 +18,7 @@ id_munge = re.compile(" id=(.*?)[ >]")
# munge and combine chapter-specific styles
out = open('build/single.html', 'w', encoding="utf-8")
-out.write(open('util/single-header.html', encoding="utf-8").read())
+out.write(open('util/single-header.html', encoding="utf-8").read().replace('%%DATE%%', time.strftime('%Y-%m-%d', time.localtime())))
out.write("