hgbook

changeset 602:de5b1753e865

Merge
author Bryan O'Sullivan <bos@serpentine.com>
date Fri Mar 27 11:55:18 2009 -0500 (2009-03-27)
parents c3c5b964901e 9e8e5292acaa
children 95ae6e9baf99
files
line diff
     1.1 --- a/.hgignore	Fri Mar 27 11:54:22 2009 -0500
     1.2 +++ b/.hgignore	Fri Mar 27 11:55:18 2009 -0500
     1.3 @@ -18,4 +18,5 @@
     1.4  en/all-ids.dat
     1.5  web/hgbook/.database.sqlite3
     1.6  web/hgbook/secrets.py
     1.7 +web/index-read.html.in
     1.8  xsl/system-xsl
     2.1 --- a/en/Makefile	Fri Mar 27 11:54:22 2009 -0500
     2.2 +++ b/en/Makefile	Fri Mar 27 11:55:18 2009 -0500
     2.3 @@ -119,8 +119,12 @@
     2.4  
     2.5  html: $(obj-web-read)/index.html
     2.6  
     2.7 -$(obj-web-read)/index.html: ../xsl/system-xsl .validated-00book.xml
     2.8 +../web/index-read.html.in: ../web/genindex.py $(xml-src-files)
     2.9 +	$<
    2.10 +
    2.11 +$(obj-web-read)/index.html: ../xsl/system-xsl .validated-00book.xml ../web/index-read.html.in
    2.12  	xsltproc $(xsltproc-opts) -o $(obj-web-read)/x ../xsl/chunk-stylesheet.xsl 00book.xml
    2.13 +	python ../web/texpand.py ../web/index-read.html.in html/read/index.html
    2.14  	for i in $(obj-web-read)/*.html; do \
    2.15  	  gzip -9 -c $$i > $$i.gz; \
    2.16  	done
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/web/genindex.py	Fri Mar 27 11:55:18 2009 -0500
     3.3 @@ -0,0 +1,60 @@
     3.4 +#!/usr/bin/env python
     3.5 +
     3.6 +import glob, os, re
     3.7 +
     3.8 +chapter_re = re.compile(r'<(chapter|appendix|preface)\s+id="([^"]+)">')
     3.9 +filename_re = re.compile(r'<\?dbhtml filename="([^"]+)"\?>')
    3.10 +title_re = re.compile(r'<title>(.*)</title>')
    3.11 +
    3.12 +chapters = glob.glob('../en/ch*.xml') + glob.glob('../en/app*.xml')
    3.13 +
    3.14 +fp = open('index-read.html.in', 'w')
    3.15 +
    3.16 +print >> fp, '''<!-- -*- html -*- -->
    3.17 +{% extends "boilerplate.html" %}
    3.18 +{% block bodycontent %}
    3.19 +<div class="navheader"><h1 class="booktitle">Mercurial: The Definitive Guide<div class="authors">by Bryan O'Sullivan</div></h1></div>
    3.20 +<div class="book"><ul class="booktoc">'''
    3.21 +
    3.22 +ch = 0
    3.23 +app = 0
    3.24 +ab = 0
    3.25 +for c in chapters:
    3.26 +    filename = None
    3.27 +    title = None
    3.28 +    chapid = None
    3.29 +    chaptype = None
    3.30 +    for line in open(c):
    3.31 +        m = chapter_re.search(line)
    3.32 +        if m:
    3.33 +            chaptype, chapid = m.groups()
    3.34 +        m = filename_re.search(line)
    3.35 +        if m:
    3.36 +            filename = m.group(1)
    3.37 +        m = title_re.search(line)
    3.38 +        if m:
    3.39 +            title = m.group(1)
    3.40 +        if filename and title and chapid:
    3.41 +            if chaptype == 'appendix':
    3.42 +                num = chr(ord('A') + app)
    3.43 +                app += 1
    3.44 +            else:
    3.45 +                num = ch
    3.46 +                ch += 1
    3.47 +            ab += 1
    3.48 +            date = os.popen('hg log -l1 --template "{date|isodate}" ' + c).read().split(None, 1)[0]
    3.49 +            args = {
    3.50 +                'ab': "ab"[ab % 2],
    3.51 +                'date': date,
    3.52 +                'chapid': chapid,
    3.53 +                'num': num,
    3.54 +                'filename': filename,
    3.55 +                'title': title,
    3.56 +                }
    3.57 +            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
    3.58 +            break
    3.59 +
    3.60 +print >> fp, '''</ul></div>
    3.61 +{% endblock %}'''
    3.62 +
    3.63 +fp.close()
     4.1 --- a/web/index.html.in	Fri Mar 27 11:54:22 2009 -0500
     4.2 +++ b/web/index.html.in	Fri Mar 27 11:55:18 2009 -0500
     4.3 @@ -2,8 +2,7 @@
     4.4  {% extends "boilerplate.html" %}
     4.5  
     4.6  {% block bodycontent %}
     4.7 -<div class="navheader"><h1 class="booktitle">Mercurial: The Definitive Guide<div class="authors">by Bryan
     4.8 -O'Sullivan</div></h1></div>
     4.9 +<div class="navheader"><h1 class="booktitle">Mercurial: The Definitive Guide<div class="authors">by Bryan O'Sullivan</div></h1></div>
    4.10  
    4.11  <div class="book">
    4.12    <h2>Welcome to Mercurial: The Definitive Guide</h2>
    4.13 @@ -31,7 +30,7 @@
    4.14  
    4.15    <p>(If you would like to adapt the comment system for a
    4.16      publishing project of your own, the source for the web application
    4.17 -    is included with the book.)</p>
    4.18 +    is included with the book source at the link above.)</p>
    4.19  
    4.20    <h2>What is Mercurial?</h2>
    4.21