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/" % depth;
45 os.environ["LILYTOP"] = depth;
46 __main__.mailaddress= os.environ['MAILADDRESS']
47 pw = pwd.getpwuid (os.getuid());
49 __main__.fullname= pw[4];
51 backstr = '\n<hr>Please take me <a href=%s>back to the index</a>\n\
52 of LilyPond -- The GNU Project Music typesetter\n\
54 This page was built using <code>%s</code> from lilypond-%s by <p>\n\
55 <address><br>%s <a href=mailto:%s&>><<!bla>%s</a>></address>\n\
60 return backstr % (index, id_str, lilyversion, fullname, mailaddress, mailaddress)
64 # do something, check return status
75 sys.stderr.write( "ignoring failed command \`%s\' (status %d)\n" % (cmd, ret))
77 sys.stderr.write( 'make-website: failed on command %s (status %d)\n' % (cmd, ret))
82 examples=["twinkle-pop",
100 print 'generating HTML'
101 my_system (["make -kC .. html"]);
105 print 'generating examples:\n'
106 list = map(lambda x: 'out/%s.ps.gz out/%s.gif out/%s.ly.txt' % (x,x,x), examples)
107 my_system (['make -C .. ' + join(' ', list)])
109 texstuff = ["mudela-man", "mudela-course"]
112 print 'generating TeX doco manuals'
113 list = open('tex_manuals.html', 'w')
114 list.write( "<HTML><TITLE>PostScript Manuals</TITLE>\n"
115 "<BODY><h1>LilyPond manuals (in PostScript)</h1>"
118 for stuff in texstuff:
119 todo = todo + ' out/' + stuff + '.ps.gz'
120 list.write("<li><a href=%s.ps.gz>%s.ps.gz</a>" % (stuff, stuff))
121 list.write('</ul></BODY></HTML>')
124 my_system (['make -C .. ' + todo])
126 def file_exist_b(name):
135 print "generating HTML list\n";
136 list = open('example_output.html', 'w')
137 list.write ('<html><TITLE>Rendered Examples</TITLE>\n'
138 '<body>These example files are taken from the LilyPond distribution.\n'
139 'LilyPond currently only outputs TeX and MIDI. The pictures and\n'
140 'PostScript files were generated using TeX, Ghostscript and some\n'
141 'graphics tools. The papersize used for these examples is A4. The GIF\n'
142 'files have been scaled to eliminate aliasing.\n');
145 header = read_mudela_header(ex + '.ly.txt')
146 def read_dict(s, default, h =header):
152 head = read_dict('title', ex)
153 composer = read_dict('composer', '')
154 desc = read_dict('description', '')
156 list.write('<h1>example file: %s</h1>' % head);
158 list.write('<h2>%s</h2>\n' % composer)
160 list.write('%s<p>' % desc)
162 def list_item(filename, desc, l = list):
163 if file_exist_b(filename):
164 l.write ('<li><a href=%s>%s</a>\n' % (filename, desc))
166 list_item(ex + '.ly.txt', 'The input')
167 for pageno in range(1,10):
168 f = ex + '-page%d.gif' % pageno
169 if not file_exist_b (f):
171 list_item(f, 'The output (picture, page %d)' % pageno)
172 list_item(ex + '.ps.gz', 'The output (gzipped PostScript)')
173 list_item(ex + '.midi', 'The output (MIDI)')
174 list.write ("</ul>");
176 list.write( "</BODY></HTML>");
180 print "copying files\n"
182 # my_system ("ln -s depth/out ./docxx" )
183 my_system([ "cp %s/TODO ./TODO.txt" % depth,
184 "cp %s/ANNOUNCE-0.1 ./ANNOUNCE.txt" % depth,
185 "cp %s/NEWS ./NEWS.txt" % depth,
186 "cp %s/DEDICATION ./DEDICATION.txt" % depth]);
187 my_system([ "make -C .. gifs"]);
191 banner= open('/tmp/lilybanner.html', 'w');
192 banner.write (footstr('../index.html'))
194 my_system(['BANNEROPT=\"-B /tmp/lilybanner.html\" %s/bin/out/make-docxx' % depth]);
195 # os.unlink( "/tmp/lilybanner.html");
200 result = result + glob.glob1('./', '*.' + a)
204 def join(inter, list):
205 return reduce (lambda x,y, i=inter: x + i + y, list)
209 list = get_glob( ['html', 'gif', 'ps.gz' , 'txt', 'midi'])
210 files = join (' ', list)
212 my_system( ['-tar zvhcf website.tar.gz ' + files + ' docxx/*'])
216 print 'This is %s\n' % id_str
219 my_system(['rm -f /tmp/gs*'])
221 def get_top_of_NEWS():
223 lines = i.readlines()
227 if regex.search('^\*\*\*\*\*\*', l) <> -1:
233 s = gulp_file('index.html')
234 s = regsub.sub ('top_of_NEWS', '<XMP>\n' + get_top_of_NEWS () + '\n</XMP>', s)
235 dump_file ('index.html', s)
238 files = get_glob(['html'])
242 if regex.search(makewebsite_id, s) <> -1:
245 s = regsub.sub ('</BODY>', footstr('index.html') + makewebsite_id + '</BODY>', s)
246 s = regsub.sub('<TITLE>\(.*\)</TITLE>$',
247 '<TITLE>LilyPond WWW: \\1</TITLE>', s)
253 os.chdir (lilydirs.topdir + 'Documentation/out')
254 __main__.depth = "../../";