3 # make-website.py -- implement The lilypond WWW site
5 # source file of the GNU LilyPond music typesetter
7 # (c) 1997 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 """
21 lilypath = os.environ['LILYPOND_SOURCEDIR'] + '/'
23 lilypath = os.environ['HOME'] + 'musix/current'
24 lilypath = lilypath + '/bin/'
25 sys.path.append(lilypath)
27 from lilypython import *
32 makewebsite_id = "<!make_website!>";
33 id_str = "make-website 0.7";
36 mailaddress = "unknown"
42 __main__.lilyversion = version_tuple_to_str(lilydirs.version_tuple())
43 os.environ["TEXINPUTS"] = os.environ["TEXINPUTS"] + ":%s/input/:" % depth;
44 os.environ["LILYINCLUDE"] = "%s/input/:%s/mutopia/:%s/mutopia/J.S.Bach" \
46 os.environ["LILYTOP"] = depth;
47 __main__.mailaddress= os.environ['MAILADDRESS']
48 pw = pwd.getpwuid (os.getuid());
50 __main__.fullname= pw[4];
52 backstr = '\n<hr>Please take me <a href=%s>back to the index</a>\n\
53 of LilyPond -- The GNU Project Music typesetter\n\
55 This page was built using <code>%s</code> from lilypond-%s by <p>\n\
56 <address><br>%s <a href=mailto:%s><<!bla>%s</a>></address>\n\
61 return backstr % (index, id_str, lilyversion, fullname, mailaddress, mailaddress)
65 # do something, check return status
76 sys.stderr.write( "ignoring failed command \`%s\' (status %d)\n" % (cmd, ret))
78 sys.stderr.write( 'make-website: failed on command %s (status %d)\n' % (cmd, ret))
83 examples=["twinkle-pop",
94 mutopia_examples = [ "wtk1-fugue2",
104 print 'generating HTML'
105 my_system (["make -kC .. html"]);
108 def gen_examples(inputs):
109 print 'generating examples:\n'
110 list = map(lambda x: 'out/%s.ps.gz out/%s.gif out/%s.ly.txt' % (x,x,x), inputs)
111 my_system (['make -C .. ' + join(' ', list)])
114 def gen_list(inputs, filename):
115 print "generating HTML list %s\n" % filename;
116 list = open(filename, 'w')
117 list.write ('<html><TITLE>Rendered Examples</TITLE>\n'
118 '<body>These example files are taken from the LilyPond distribution.\n'
119 'LilyPond currently only outputs TeX and MIDI. The pictures and\n'
120 'PostScript files were generated using TeX, Ghostscript and some\n'
121 'graphics tools. The papersize used for these examples is A4. The GIF\n'
122 'files have been scaled to eliminate aliasing.\n');
125 header = read_mudela_header(ex + '.ly.txt')
126 def read_dict(s, default, h =header):
132 head = read_dict('title', ex)
133 composer = read_dict('composer', '')
134 desc = read_dict('description', '')
136 list.write('<h1>example file: %s</h1>' % head);
138 list.write('<h2>%s</h2>\n' % composer)
140 list.write('%s<p>' % desc)
142 def list_item(filename, desc, l = list):
143 if file_exist_b(filename):
144 l.write ('<li><a href=%s>%s</a>\n' % (filename, desc))
146 list_item(ex + '.ly.txt', 'The input')
147 for pageno in range(1,10):
148 f = ex + '-page%d.gif' % pageno
149 if not file_exist_b (f):
151 list_item(f, 'The output (picture, page %d)' % pageno)
152 list_item(ex + '.ps.gz', 'The output (gzipped PostScript)')
153 list_item(ex + '.midi', 'The output (MIDI)')
154 list.write ("</ul>");
156 list.write( "</BODY></HTML>");
159 texstuff = ["mudela-man", "mudela-course"]
162 print 'generating TeX doco manuals'
163 list = open('tex_manuals.html', 'w')
164 list.write( "<HTML><TITLE>PostScript Manuals</TITLE>\n"
165 "<BODY><h1>LilyPond manuals (in PostScript)</h1>"
168 for stuff in texstuff:
169 todo = todo + ' out/' + stuff + '.ps.gz'
170 list.write("<li><a href=%s.ps.gz>%s.ps.gz</a>" % (stuff, stuff))
171 list.write('</ul></BODY></HTML>')
174 my_system (['make -C .. ' + todo])
176 def file_exist_b(name):
184 print "copying files\n"
186 # my_system ("ln -s depth/out ./docxx" )
187 my_system([ "cp %s/TODO ./TODO.txt" % depth,
188 "cp %s/ANNOUNCE-0.1 ./ANNOUNCE.txt" % depth,
189 "cp %s/NEWS ./NEWS.txt" % depth,
190 "cp %s/DEDICATION ./DEDICATION.txt" % depth]);
191 my_system([ "make -C .. gifs"]);
195 banner= open('/tmp/lilybanner.html', 'w');
196 banner.write (footstr('../index.html'))
198 my_system(['BANNEROPT=\"-B /tmp/lilybanner.html\" %s/bin/out/make-docxx' % depth]);
199 # os.unlink( "/tmp/lilybanner.html");
204 result = result + glob.glob1('./', '*.' + a)
208 def join(inter, list):
209 return reduce (lambda x,y, i=inter: x + i + y, list)
213 list = get_glob( ['html', 'gif', 'ps.gz' , 'txt', 'midi'])
214 files = join (' ', list)
216 my_system( ['-tar zvhcf website.tar.gz ' + files + ' docxx/*'])
220 print 'This is %s\n' % id_str
223 my_system(['rm -f /tmp/gs*'])
225 def get_top_of_NEWS():
227 lines = i.readlines()
231 if regex.search('^\*\*\*\*\*\*', l) <> -1:
237 s = gulp_file('index.html')
238 s = regsub.sub ('top_of_NEWS', '<XMP>\n' + get_top_of_NEWS () + '\n</XMP>', s)
239 dump_file ('index.html', s)
242 files = get_glob(['html'])
246 if regex.search(makewebsite_id, s) <> -1:
249 s = regsub.sub ('</BODY>', footstr('index.html') + makewebsite_id + '</BODY>', s)
250 s = regsub.sub('<TITLE>\(.*\)</TITLE>$',
251 '<TITLE>LilyPond WWW: \\1</TITLE>', s)
257 os.chdir (lilydirs.topdir + 'Documentation/out')
258 __main__.depth = "../../";
263 gen_examples(examples);
264 gen_list(examples, 'examples_output.html');
266 gen_examples(mutopia_examples);
267 gen_list(mutopia_examples, 'mutopiaexamples_output.html');