3 # make-website.py -- implement The lilypond WWW site
5 # source file of the GNU LilyPond music typesetter
7 # (c) 1997, 1998 Han-Wen Nienhuys <hanwen@stack.nl>
11 stupid script to generate WWW site.
13 The WWW site is my test-suite for LilyPond, I usually don't
14 distribute versions that fail to complete this script
16 You should set the following environment vars:
30 lilypath = os.environ['LILYPOND_SOURCEDIR'] + '/'
32 print 'Please set LILYPOND_SOURCEDIR to the toplevel source, eg LILYPOND_SOURCEDIR=/home/foobar/lilypond-1.2.3/'
35 lilypath = lilypath + '/bin/'
36 sys.path.append(lilypath)
38 from lilypython import *
43 makewebsite_id = "<!make_website!>";
44 id_str = "make-website 0.8";
47 mailaddress = "unknown"
52 include_path=[ 'input', 'mutopia' , 'mutopia/J.S.Bach',
53 'mutopia/J.S.Bach/out' ]
56 __main__.lilyversion = version_tuple_to_str(lilydirs.version_tuple())
57 os.environ["TEXINPUTS"] = os.environ["TEXINPUTS"] + ":%s/input/:" % depth;
59 os.environ["LILYINCLUDE"] = join (':', __main__.include_path)
60 os.environ["LILYTOP"] = depth;
61 __main__.mailaddress= os.environ['MAILADDRESS']
62 pw = pwd.getpwuid (os.getuid());
64 __main__.fullname= pw[4];
66 backstr = '\n<hr>Please take me <a href=%s>back to the index</a>\n\
67 of LilyPond -- The GNU Project Music typesetter\n\
69 This page was built using <code>%s</code> from lilypond-%s by <p>\n\
70 <address><br>%s <a href=mailto:%s><<!bla>%s</a>></address>\n\
75 return backstr % (index, id_str, lilyversion, fullname, mailaddress, mailaddress)
79 # do something, check return status
90 sys.stderr.write( "ignoring failed command \`%s\' (status %d)\n" % (cmd, ret))
92 sys.stderr.write( 'make-website: failed on command %s (status %d)\n' % (cmd, ret))
97 examples=["twinkle-pop",
108 mutopia_examples = [ "wtk1-fugue2",
118 print 'generating HTML'
119 my_system (["make -kC .. html"]);
122 def gen_examples(inputs):
123 print 'generating examples:\n'
127 located = multiple_find ([i + '.ly'], include_path) [0]
129 print 'continuing dazed & confused (%s) ' % i
131 outputs.append (located)
132 if not file_exist_b(i + '.dvi'):
133 my_system (['ly2dvi %s' % located])
134 if not file_exist_b(i + '.ly.txt'):
135 os.link (located, i + ".ly.txt")
136 list = map(lambda x: 'out/%s.ps.gz out/%s.gif' % (x,x), inputs)
137 my_system (['make -C .. ' + join(' ', list)])
141 def gen_list(inputs, filename):
142 print "generating HTML list %s\n" % filename;
143 list = open(filename, 'w')
144 list.write ('<html><TITLE>Rendered Examples</TITLE>\n'
145 '<body>These example files are taken from the LilyPond distribution.\n'
146 'LilyPond currently only outputs TeX and MIDI. The pictures and\n'
147 'PostScript files were generated using TeX, Ghostscript and some\n'
148 'graphics tools. The papersize used for these examples is A4. The GIF\n'
149 'files have been scaled to eliminate aliasing.\n');
153 header = read_mudela_header(ex + '.ly.txt')
155 def read_dict(s, default, h =header):
161 head = read_dict('title', ex)
162 composer = read_dict('composer', '')
163 desc = read_dict('description', '')
165 list.write('<h1>example file: %s</h1>' % head);
167 list.write('<h2>%s</h2>\n' % composer)
169 list.write('%s<p>' % desc)
171 def list_item(filename, desc, l = list):
172 if file_exist_b(filename):
173 l.write ('<li><a href=%s>%s</a>\n' % (filename, desc))
175 list_item(ex + '.ly.txt', 'The input')
176 for pageno in range(1,10):
177 f = ex + '-page%d.gif' % pageno
178 if not file_exist_b (f):
180 list_item(f, 'The output (picture, page %d)' % pageno)
181 list_item(ex + '.ps.gz', 'The output (gzipped PostScript)')
182 list_item(ex + '.midi', 'The output (MIDI)')
183 list.write ("</ul>");
185 list.write( "</BODY></HTML>");
188 texstuff = ["mudela-man", "mudela-course"]
191 print 'generating TeX doco manuals'
192 list = open('tex_manuals.html', 'w')
193 list.write( "<HTML><TITLE>PostScript Manuals</TITLE>\n"
194 "<BODY><h1>LilyPond manuals (in PostScript)</h1>"
197 for stuff in texstuff:
198 todo = todo + ' out/' + stuff + '.ps.gz'
199 list.write("<li><a href=%s.ps.gz>%s.ps.gz</a>" % (stuff, stuff))
200 list.write('</ul></BODY></HTML>')
203 my_system (['make -C .. ' + todo])
205 def file_exist_b(name):
213 print "copying files\n"
215 # my_system ("ln -s depth/out ./docxx" )
216 my_system([ "cp %s/TODO ./TODO.txt" % depth,
217 "cp %s/ANNOUNCE-0.1 ./ANNOUNCE.txt" % depth,
218 "cp %s/NEWS ./NEWS.txt" % depth,
219 "cp %s/DEDICATION ./DEDICATION.txt" % depth]);
220 my_system([ "make -C .. gifs"]);
224 banner= open('/tmp/lilybanner.html', 'w');
225 banner.write (footstr('../index.html'))
227 my_system(['BANNEROPT=\"-B /tmp/lilybanner.html\" %s/bin/out/make-docxx' % depth]);
228 # os.unlink( "/tmp/lilybanner.html");
233 result = result + glob.glob1('./', '*.' + a)
237 def join(inter, list):
238 return reduce (lambda x,y, i=inter: x + i + y, list)
242 list = get_glob( ['html', 'gif', 'ps.gz' , 'txt', 'midi'])
243 files = join (' ', list)
245 my_system( ['-tar zvhcf website.tar.gz ' + files + ' docxx/*'])
249 print 'This is %s\n' % id_str
252 my_system(['rm -f /tmp/gs*'])
254 def get_top_of_NEWS():
256 lines = i.readlines()
260 if regex.search('^\*\*\*\*\*\*', l) <> -1:
266 s = gulp_file('index.html')
267 s = regsub.sub ('top_of_NEWS', '<XMP>\n' + get_top_of_NEWS () + '\n</XMP>', s)
268 dump_file ('index.html', s)
271 files = get_glob(['html'])
275 if regex.search(makewebsite_id, s) <> -1:
278 s = regsub.sub ('</BODY>', footstr('index.html') + makewebsite_id + '</BODY>', s)
279 s = regsub.sub('<TITLE>\(.*\)</TITLE>$',
280 '<TITLE>LilyPond WWW: \\1</TITLE>', s)
285 def do_examples (examples, filename):
286 located_files = gen_examples (examples)
287 gen_list (examples, filename)
291 os.chdir (lilydirs.topdir + 'Documentation/out')
292 __main__.depth = "../../";
293 __main__.include_path = map(lambda p: __main__.depth + '/' +
294 p, __main__.include_path)
299 do_examples (examples, 'examples_output.html');
300 do_examples (mutopia_examples, 'mutopiaexamples_output.html');