# HG changeset patch # User Giulio@puck # Date 1244494755 -7200 # Node ID 96c0123423558d180d50ef287e4051df0a136df0 # Parent 716f76ea4a34c9862398036e7c2d1b210fb6f13b More makefile, plus main index template and generator script. diff -r 716f76ea4a34 -r 96c012342355 .hgignore --- a/.hgignore Mon Jun 08 18:34:23 2009 +0200 +++ b/.hgignore Mon Jun 08 22:59:15 2009 +0200 @@ -24,6 +24,7 @@ en/examples/results en/html en/svn +it/html stylesheets/system-xsl tools web/hgbook/.database.sqlite3 diff -r 716f76ea4a34 -r 96c012342355 it/Makefile --- a/it/Makefile Mon Jun 08 18:34:23 2009 +0200 +++ b/it/Makefile Mon Jun 08 22:59:15 2009 +0200 @@ -2,16 +2,24 @@ xml-src-files := \ 00book.xml \ - #app*.xml \ - ch*.xml + $(wildcard ch*.xml) + #$(wildcard app*.xml) + obj-web := html +figs-web := ${obj-web}/figs +web-global := ../web +web-local := web -html: ${obj-web}/index.html +html: ${obj-web}/index.html ${web-local}/index-read.html.in #$(obj-web)/index.html: ../stylesheets/system-xsl .validated-00book.xml #../web/index-read.html.in $(obj-web)/index.html: .validated-00book.xml xsltproc $(xsltproc-opts) -o $(obj-web)/x ../stylesheets/chunk-stylesheet.xsl 00book.xml + cp ${web-global}/styles.css ${obj-web} + mkdir -p ${figs-web} + cp -f ${web-global}/icons/*.png $(figs-web) + sed -i -e "s|/support/||g" ${obj-web}/*.html # 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; \ @@ -20,9 +28,19 @@ #../stylesheets/system-xsl: $(system-xsl-dir) # ln -s $< $@ +$(web-local)/index-read.html.in: $(web-local)/genindex.py $(xml-src-files) + cp $(web-local)/index-template.html $(obj-web)/index.html + sed -i -e "s|{% block bodycontent %}{% endblock %}|$(shell cat $(web-local)/index-read.html.in)|g" ${obj-web}/index.html + +$(web-local)/genindex.py: $(xml-src-files) + cd $(web-local) && ./genindex.py + valid: .validated-00book.xml .validated-00book.xml: $(xml-src-files) #examples/.run xmllint $(xmllint-opts) $< touch $@ +clean: + rm -f $(web-local)/index-read.html.in + rm -rf $(obj-web) diff -r 716f76ea4a34 -r 96c012342355 it/web/genindex.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/it/web/genindex.py Mon Jun 08 22:59:15 2009 +0200 @@ -0,0 +1,58 @@ +#!C:/Programmi/Python30/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 = (sorted(glob.glob('../ch*.xml')) + + sorted(glob.glob('../app*.xml'))) + +fp = open('index-read.html.in', 'w') + +print(''' +<div class="navheader"><h1 class="booktitle">Mercurial: la guida definitiva<div class="authors">di Bryan O'Sullivan</div></h1></div> +<div class="book"><ul class="booktoc">''', file=fp) + +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('<li class="zebra_%(ab)s"><span class="chapinfo">%(date)s<a href="/feeds/comments/%(chapid)s/"><img src="figs/rss.png"/></a></span>%(num)s. <a href="%(filename)s">%(title)s</a></li>' % args, file=fp) + break + +print('</ul></div>', file=fp) + +fp.close() diff -r 716f76ea4a34 -r 96c012342355 it/web/index-template.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/it/web/index-template.html Mon Jun 08 22:59:15 2009 +0200 @@ -0,0 +1,36 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> + <head> + <title>Mercurial: la guida definitiva</title> + <link rel="stylesheet" href="styles.css" type="text/css"/> + <!-- + <link rel="alternate" type="application/atom+xml" title="Comments" + href="/feeds/comments/"/> + --> + <link rel="shortcut icon" type="image/png" href="figs/favicon.png"/> + <!-- No comment system for italian translation + <script type="text/javascript" src="/support/jquery.js"></script> + <script type="text/javascript" src="/support/form.js"></script> + <script type="text/javascript" src="/support/hsbook.js"></script> + --> + </head> + + <body> + {% block bodycontent %}{% endblock %} + + <div class="hgbookfooter"> <p><img src="figs/rss.png"> Volete rimanere aggiornati? Abbonatevi al feed delle modifiche per qualsiasi capitolo o per <a class="feed" href="/feeds/comments/">l'intero libro</a>.</p> <p>Copyright 2006, 2007, 2008, 2009 Bryan O'Sullivan. Icone realizzate da <a href="mailto:mattahan@gmail.com">Paul Davey</a> alias <a href="http://mattahan.deviantart.com/">Mattahan</a>.</p> + </div> + + <!-- Also, no need for Google Analytics on the italian translation + <script type="text/javascript"> + var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); + document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); + </script> + <script type="text/javascript"> + try { + var pageTracker = _gat._getTracker("UA-1805907-5"); + pageTracker._trackPageview(); + } catch(err) {}</script> + --> + </body> +</html>