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 """
16 from lilypython import *
21 makewebsite_id = "<!make_website!>";
22 id_str = "make-website 0.6";
25 mailaddress = "unknown"
31 __main__.lilyversion = version_tuple_to_str(lilydirs.version_tuple())
32 os.environ["TEXINPUTS"] = os.environ["TEXINPUTS"] + ":%s/input/:" % depth;
33 os.environ["LILYINCLUDE"] = "%s/input/" % depth;
34 os.environ["LILYTOP"] = depth;
35 __main__.mailaddress= os.environ['MAILADDRESS']
36 pw = pwd.getpwuid (os.getuid());
38 __main__.fullname= pw[4];
40 backstr = '\n<hr>Please take me <a href=%s>back to the index</a>\n\
41 of LilyPond -- The GNU Project Music typesetter\n\
43 This page was built using <code>%s</code> from lilypond-%s by <p>\n\
44 <address><br>%s <a href=mailto:%s&>><<!bla>%s</a>></address>\n\
49 return backstr % (index, id_str, lilyversion, fullname, mailaddress, mailaddress)
53 # do something, check return status
64 sys.stderr.write( "ignoring failed command \`%s\' (status %d)\n" % (cmd, ret))
66 sys.stderr.write( 'make-website: failed on command %s (status %d)\n' % (cmd, ret))
71 examples=["twinkle-pop",
89 print 'generating HTML'
90 my_system (["make -kC .. html"]);
94 print 'generating examples:\n'
95 list = map(lambda x: 'out/%s.ps.gz out/%s.gif out/%s.ly.txt' % (x,x,x), examples)
96 my_system (['make -C .. ' + join(' ', list)])
98 texstuff = ["mudela-man", "mudela-course"]
101 print 'generating TeX doco manuals'
102 list = open('tex_manuals.html', 'w')
103 list.write( "<HTML><TITLE>PostScript Manuals</TITLE>\n"
104 "<BODY><h1>LilyPond manuals (in PostScript)</h1>"
107 for stuff in texstuff:
108 todo = todo + ' out/' + stuff + '.ps.gz'
109 list.write("<li><a href=%s.ps.gz>%s.ps.gz</a>" % (stuff, stuff))
110 list.write('</ul></BODY></HTML>')
113 my_system (['make -C .. ' + todo])
115 def file_exist_b(name):
124 print "generating HTML list\n";
125 list = open('example_output.html', 'w')
126 list.write ('<html><TITLE>Rendered Examples</TITLE>\n'
127 '<body>These example files are taken from the LilyPond distribution.\n'
128 'LilyPond currently only outputs TeX and MIDI. The pictures and\n'
129 'PostScript files were generated using TeX, Ghostscript and some\n'
130 'graphics tools. The papersize used for these examples is A4. The GIF\n'
131 'files have been scaled to eliminate aliasing.\n');
134 header = read_mudela_header(ex + '.ly.txt')
135 def read_dict(s, default, h =header):
141 head = read_dict('title', ex)
142 composer = read_dict('composer', '')
143 desc = read_dict('description', '')
145 list.write('<h1>example file: %s</h1>' % head);
147 list.write('<h2>%s</h2>\n' % composer)
149 list.write('%s<p>' % desc)
151 def list_item(filename, desc, l = list):
152 if file_exist_b(filename):
153 l.write ('<li><a href=%s>%s</a>\n' % (filename, desc))
155 list_item(ex + '.ly.txt', 'The input')
156 for pageno in range(1,10):
157 f = ex + '-page%d.gif' % pageno
158 if not file_exist_b (f):
160 list_item(f, 'The output (picture, page %d)' % pageno)
161 list_item(ex + '.ps.gz', 'The output (gzipped PostScript)')
162 list_item(ex + '.midi', 'The output (MIDI)')
163 list.write ("</ul>");
165 list.write( "</BODY></HTML>");
169 print "copying files\n"
171 # my_system ("ln -s depth/out ./docxx" )
172 my_system([ "cp %s/TODO ./TODO.txt" % depth,
173 "cp %s/ANNOUNCE-0.1 ./ANNOUNCE.txt" % depth,
174 "cp %s/NEWS ./NEWS.txt" % depth,
175 "cp %s/DEDICATION ./DEDICATION.txt" % depth]);
176 my_system([ "make -C .. gifs"]);
180 banner= open('/tmp/lilybanner.html', 'w');
181 banner.write (footstr('../index.html'))
183 my_system(['BANNEROPT=\"-B /tmp/lilybanner.html\" %s/bin/out/make-docxx' % depth]);
184 # os.unlink( "/tmp/lilybanner.html");
189 result = result + glob.glob1('./', '*.' + a)
193 def join(inter, list):
194 return reduce (lambda x,y, i=inter: x + i + y, list)
198 list = get_glob( ['html', 'gif', 'ps.gz' , 'txt', 'midi'])
199 files = join (' ', list)
201 my_system( ['-tar zvhcf website.tar.gz ' + files + ' docxx/*'])
205 print 'This is %s\n' % id_str
208 my_system(['rm -f /tmp/gs*'])
210 def get_top_of_NEWS():
212 lines = i.readlines()
216 if regex.search('^\*\*\*\*\*\*', l) <> -1:
222 s = gulp_file('index.html')
223 s = regsub.sub ('top_of_NEWS', '<XMP>\n' + get_top_of_NEWS () + '\n</XMP>', s)
224 dump_file ('index.html', s)
227 files = get_glob(['html'])
231 if regex.search(makewebsite_id, s) <> -1:
234 s = regsub.sub ('</BODY>', footstr('index.html') + makewebsite_id + '</BODY>', s)
235 s = regsub.sub('<TITLE>\(.*\)</TITLE>$',
236 '<TITLE>LilyPond WWW: \\1</TITLE>', s)
242 os.chdir (lilydirs.topdir + 'Documentation/out')
243 __main__.depth = "../../";