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.9";
46 make = "make -f Makefile";
47 mailaddress = "unknown"
52 include_path=[ 'input', 'mutopia' , 'mutopia/J.S.Bach', 'mutopia/Coriolan',
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) +':'+ os.environ["LILYINCLUDE"];
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",
109 mutopia_examples = [ "wtk1-fugue2",
120 print 'generating HTML'
121 my_system (["make -f Makefile -kC .. html"]);
124 def gen_examples(inputs):
125 print 'generating examples:\n'
129 located = multiple_find ([i + '.ly'], include_path) [0]
131 print 'continuing dazed & confused (%s) ' % i
133 outputs.append (located)
134 if not file_exist_b(i + '.dvi'):
135 my_system (['ly2dvi %s' % located])
136 if not file_exist_b(i + '.ly.txt'):
137 os.link (located, i + ".ly.txt")
138 list = map(lambda x: 'out/%s.ps.gz out/%s.gif' % (x,x), inputs)
139 my_system (['make -C .. ' + join(' ', list)])
143 def gen_list(inputs, filename):
144 print "generating HTML list %s\n" % filename;
145 list = open(filename, 'w')
146 list.write ('<html><TITLE>Rendered Examples</TITLE>\n'
147 '<body>These example files are taken from the LilyPond distribution.\n'
148 'LilyPond currently only outputs TeX and MIDI. The pictures and\n'
149 'PostScript files were generated using TeX, Ghostscript and some\n'
150 'graphics tools. The papersize used for these examples is A4. The GIF\n'
151 'files have been scaled to eliminate aliasing.\n');
155 header = read_mudela_header(ex + '.ly.txt')
157 def read_dict(s, default, h =header):
163 head = read_dict('title', ex)
164 composer = read_dict('composer', '')
165 desc = read_dict('description', '')
167 list.write('<h1>example file: %s</h1>' % head);
169 list.write('<h2>%s</h2>\n' % composer)
171 list.write('%s<p>' % desc)
173 def list_item(filename, desc, l = list):
174 if file_exist_b(filename):
175 l.write ('<li><a href=%s>%s</a>\n' % (filename, desc))
177 list_item(ex + '.ly.txt', 'The input')
178 for pageno in range(1,10):
179 f = ex + '-page%d.gif' % pageno
180 if not file_exist_b (f):
182 list_item(f, 'The output (picture, page %d)' % pageno)
183 list_item(ex + '.ps.gz', 'The output (gzipped PostScript)')
184 list_item(ex + '.midi', 'The output (MIDI)')
185 list.write ("</ul>");
187 list.write( "</BODY></HTML>");
190 texstuff = ["mudela-man", "introduction"]
193 print 'generating TeX doco manuals'
194 list = open('tex_manuals.html', 'w')
195 list.write( "<HTML><TITLE>PostScript Manuals</TITLE>\n"
196 "<BODY><h1>LilyPond manuals (in PostScript)</h1>"
199 for stuff in texstuff:
200 todo = todo + ' out/' + stuff + '.ps.gz'
201 list.write("<li><a href=%s.ps.gz>%s.ps.gz</a>" % (stuff, stuff))
202 list.write('</ul></BODY></HTML>')
205 my_system (['make -C .. ' + todo])
207 def file_exist_b(name):
215 print "copying files\n"
217 # my_system ("ln -s depth/out ./docxx" )
218 my_system([ "cp %s/TODO ./TODO.txt" % depth,
219 "cp %s/ANNOUNCE-0.1 ./ANNOUNCE-0.1.txt" % depth,
220 "cp %s/NEWS ./NEWS.txt" % depth,
221 "cp %s/DEDICATION ./DEDICATION.txt" % depth]);
222 my_system([ "make -C .. gifs"]);
226 banner= open('/tmp/lilybanner.html', 'w');
227 banner.write (footstr('../index.html'))
229 my_system(['BANNEROPT=\"-B /tmp/lilybanner.html\" %s/bin/make-docxx' % depth]);
230 # os.unlink( "/tmp/lilybanner.html");
235 result = result + glob.glob1('./', '*.' + a)
239 def join(inter, list):
240 return reduce (lambda x,y, i=inter: x + i + y, list)
244 list = get_glob( ['html', 'gif', 'ps.gz' , 'txt', 'midi'])
245 files = join (' ', list)
247 my_system( ['-tar zvhcf website.tar.gz ' + files + ' docxx/*'])
251 print 'This is %s\n' % id_str
254 my_system(['-rm -f /tmp/gs*'])
256 def get_top_of_NEWS():
258 lines = i.readlines()
262 if regex.search('^\*\*\*\*\*\*', l) <> -1:
268 s = gulp_file('index.html')
269 s = regsub.sub ('top_of_NEWS', '<XMP>\n' + get_top_of_NEWS () + '\n</XMP>', s)
270 dump_file ('index.html', s)
273 files = get_glob(['html'])
277 if regex.search(makewebsite_id, s) <> -1:
280 s = regsub.sub ('</BODY>', footstr('index.html') + makewebsite_id + '</BODY>', s)
281 s = regsub.sub('<TITLE>\(.*\)</TITLE>$',
282 '<TITLE>LilyPond WWW: \\1</TITLE>', s)
287 def do_examples (examples, filename):
288 located_files = gen_examples (examples)
289 gen_list (examples, filename)
293 os.chdir (lilydirs.topdir + 'WWW')
295 my_system (['-rm ../WWW/*.pod ../WWW/*.xpm ../WWW/*.doc',
296 'ln ../Documentation/*.pod ../Documentation/*.doc ../Documentation/*.xpm .']);
297 os.chdir (lilydirs.topdir + 'WWW/out')
298 __main__.depth = "../../";
299 __main__.include_path = map(lambda p: __main__.depth + '/' +
300 p, __main__.include_path)
305 do_examples (examples, 'examples_output.html');
306 do_examples (mutopia_examples, 'mutopiaexamples_output.html');