added HTML and PDF downloads, updated home page

This commit is contained in:
Mark Pilgrim
2009-09-11 23:06:01 -04:00
parent 81aa17c80c
commit f6a6aee7b3
5 changed files with 40 additions and 9 deletions
+6 -4
View File
@@ -21,10 +21,12 @@ h1:before,h2:before{content:''}
<h1>Dive Into Python 3</h1>
<p><cite>Dive Into Python 3</cite> covers Python 3 and its differences from Python 2. Compared to <cite><a href=//diveintopython.org/>Dive Into Python</a></cite>, it&#8217;s about 20% revised and 80% new material. I am publishing drafts online as I go. <a href=about.html>Please send feedback</a>. The final version will be published on paper by Apress. The book will remain online under the <a rel=license href=//creativecommons.org/licenses/by-sa/3.0/>CC-BY-SA-3.0</a> license.
<p><cite>Dive Into Python 3</cite> covers Python 3 and its differences from Python 2. Compared to <cite><a href=//diveintopython.org/>Dive Into Python</a></cite>, it&#8217;s about 20% revised and 80% new material. The book is now complete, but <a href=about.html>feedback is always welcome</a>.
<h2>Table of Contents (<a href=table-of-contents.html>expand</a>)</h2>
<p style="float:right;width:227px;text-align:center;margin:0 0 0 1.75em"><a style="border:0" href="http://www.amazon.com/gp/product/1430224150?ie=UTF8&amp;tag=diveintomark-20&amp;creativeASIN=1430224150" title="Affiliate link = I earn an extra buck"><em>Also available on dead trees!</em><br><img src=http://ec1.images-amazon.com/images/I/51saAme00ML._SL300_.jpg alt="Dive Into Python 3" width=227 height=300><br><em>Pre-order now, get it October 16th!</em></a>
<ol start=-1>
<li><a href=whats-new.html>What&#8217;s New in &#8220;Dive Into Python 3&#8221;</a>
<li><a href=installing-python.html>Installing Python</a>
@@ -49,11 +51,11 @@ h1:before,h2:before{content:''}
<li id=c><a href=where-to-go-from-here.html>Where to Go From Here</a>
</ol>
<p>There is a <a href=http://hg.diveintopython3.org/>changelog</a>, a <a type=application/atom+xml href=http://hg.diveintopython3.org/atom-log>feed</a>, and <a href='http://www.reddit.com/search?q=%22Dive+Into+Python+3%22&amp;sort=new'>discussion on Reddit</a>. During development, you can download the book by cloning the Mercurial repository:
<p>The book is freely licensed under the <a rel=license href=//creativecommons.org/licenses/by-sa/3.0/>Creative Commons Attribution Share-Alike</a> license. You can download it in <a href=d/diveintopython3-html-latest.zip><abbr>HTML</abbr></a> or <a href=d/diveintopython3-pdf-latest.zip><abbr>PDF</abbr></a>, or by cloning the Mercurial repository:
<pre><samp class=p>you@localhost:~$ </samp><kbd>hg clone http://hg.diveintopython3.org/ diveintopython3</kbd></pre>
<pre><samp class=p>you@localhost:~$ </samp><kbd>hg clone <a href=http://hg.diveintopython3.org/>http://hg.diveintopython3.org/</a> diveintopython3</kbd></pre>
<p>The final version will be downloadable as <abbr>HTML</abbr> and <abbr>PDF</abbr>.
<p>
<p class='c nm'>This site is optimized for Lynx just because fuck you.<br>I&#8217;m told it also looks good in graphical browsers.
+3
View File
@@ -54,3 +54,6 @@ h3 {
ul, ol {
margin: 1.75em 20pt;
}
abbr {
text-decoration: none;
}
+28 -4
View File
@@ -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 "." && \
+2 -1
View File
@@ -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("<style>\n")
for filename in chapters:
include = False
+1
View File
@@ -6,6 +6,7 @@
<meta name="author" content="Mark Pilgrim">
<meta name="subject" content="Python 3 from novice to pro">
<meta name="keywords" content="python, python3, py3k, free, book">
<meta name="date" content="%%DATE%%">
<link rel=stylesheet href=dip3.css>
<style>
body{counter-reset:h1 -2}