changeset 700:de5b1753e865

Merge
author Bryan O'Sullivan <bos@serpentine.com>
date Fri, 27 Mar 2009 11:55:18 -0500
parents c3c5b964901e (current diff) 9e8e5292acaa (diff)
children 95ae6e9baf99
files
diffstat 4 files changed, 68 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Fri Mar 27 11:54:22 2009 -0500
+++ b/.hgignore	Fri Mar 27 11:55:18 2009 -0500
@@ -18,4 +18,5 @@
 en/all-ids.dat
 web/hgbook/.database.sqlite3
 web/hgbook/secrets.py
+web/index-read.html.in
 xsl/system-xsl
--- a/en/Makefile	Fri Mar 27 11:54:22 2009 -0500
+++ b/en/Makefile	Fri Mar 27 11:55:18 2009 -0500
@@ -119,8 +119,12 @@
 
 html: $(obj-web-read)/index.html
 
-$(obj-web-read)/index.html: ../xsl/system-xsl .validated-00book.xml
+../web/index-read.html.in: ../web/genindex.py $(xml-src-files)
+	$<
+
+$(obj-web-read)/index.html: ../xsl/system-xsl .validated-00book.xml ../web/index-read.html.in
 	xsltproc $(xsltproc-opts) -o $(obj-web-read)/x ../xsl/chunk-stylesheet.xsl 00book.xml
+	python ../web/texpand.py ../web/index-read.html.in html/read/index.html
 	for i in $(obj-web-read)/*.html; do \
 	  gzip -9 -c $$i > $$i.gz; \
 	done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/web/genindex.py	Fri Mar 27 11:55:18 2009 -0500
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+
+import glob, os, re
+
+chapter_re = re.compile(r'<(chapter|appendix|preface)\s+id="([^"]+)">')
+filename_re = re.compile(r'<\?dbhtml filename="([^"]+)"\?>')
+title_re = re.compile(r'<title>(.*)</title>')
+
+chapters = glob.glob('../en/ch*.xml') + glob.glob('../en/app*.xml')
+
+fp = open('index-read.html.in', 'w')
+
+print >> fp, '''<!-- -*- html -*- -->
+{% extends "boilerplate.html" %}
+{% block bodycontent %}
+<div class="navheader"><h1 class="booktitle">Mercurial: The Definitive Guide<div class="authors">by Bryan O'Sullivan</div></h1></div>
+<div class="book"><ul class="booktoc">'''
+
+ch = 0
+app = 0
+ab = 0
+for c in chapters:
+    filename = None
+    title = None
+    chapid = None
+    chaptype = None
+    for line in open(c):
+        m = chapter_re.search(line)
+        if m:
+            chaptype, chapid = m.groups()
+        m = filename_re.search(line)
+        if m:
+            filename = m.group(1)
+        m = title_re.search(line)
+        if m:
+            title = m.group(1)
+        if filename and title and chapid:
+            if chaptype == 'appendix':
+                num = chr(ord('A') + app)
+                app += 1
+            else:
+                num = ch
+                ch += 1
+            ab += 1
+            date = os.popen('hg log -l1 --template "{date|isodate}" ' + c).read().split(None, 1)[0]
+            args = {
+                'ab': "ab"[ab % 2],
+                'date': date,
+                'chapid': chapid,
+                'num': num,
+                'filename': filename,
+                'title': title,
+                }
+            print >> fp, '<li class="zebra_%(ab)s"><span class="chapinfo">%(date)s<a href="/feeds/comments/%(chapid)s/"><img src="/support/figs/rss.png"/></a></span>%(num)s. <a href="%(filename)s">%(title)s</a></li>' % args
+            break
+
+print >> fp, '''</ul></div>
+{% endblock %}'''
+
+fp.close()
--- a/web/index.html.in	Fri Mar 27 11:54:22 2009 -0500
+++ b/web/index.html.in	Fri Mar 27 11:55:18 2009 -0500
@@ -2,8 +2,7 @@
 {% extends "boilerplate.html" %}
 
 {% block bodycontent %}
-<div class="navheader"><h1 class="booktitle">Mercurial: The Definitive Guide<div class="authors">by Bryan
-O'Sullivan</div></h1></div>
+<div class="navheader"><h1 class="booktitle">Mercurial: The Definitive Guide<div class="authors">by Bryan O'Sullivan</div></h1></div>
 
 <div class="book">
   <h2>Welcome to Mercurial: The Definitive Guide</h2>
@@ -31,7 +30,7 @@
 
   <p>(If you would like to adapt the comment system for a
     publishing project of your own, the source for the web application
-    is included with the book.)</p>
+    is included with the book source at the link above.)</p>
 
   <h2>What is Mercurial?</h2>