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",
101 print 'generating HTML'
102 my_system (["make -kC .. html"]);
106 print 'generating examples:\n'
107 list = map(lambda x: 'out/%s.ps.gz out/%s.gif out/%s.ly.txt' % (x,x,x), examples)
108 my_system (['make -C .. ' + join(' ', list)])
110 texstuff = ["mudela-man", "mudela-course"]
113 print 'generating TeX doco manuals'
114 list = open('tex_manuals.html', 'w')
115 list.write( "<HTML><TITLE>PostScript Manuals</TITLE>\n"
116 "<BODY><h1>LilyPond manuals (in PostScript)</h1>"
119 for stuff in texstuff:
120 todo = todo + ' out/' + stuff + '.ps.gz'
121 list.write("<li><a href=%s.ps.gz>%s.ps.gz</a>" % (stuff, stuff))
122 list.write('</ul></BODY></HTML>')
125 my_system (['make -C .. ' + todo])
127 def file_exist_b(name):
136 print "generating HTML list\n";
137 list = open('example_output.html', 'w')
138 list.write ('<html><TITLE>Rendered Examples</TITLE>\n'
139 '<body>These example files are taken from the LilyPond distribution.\n'
140 'LilyPond currently only outputs TeX and MIDI. The pictures and\n'
141 'PostScript files were generated using TeX, Ghostscript and some\n'
142 'graphics tools. The papersize used for these examples is A4. The GIF\n'
143 'files have been scaled to eliminate aliasing.\n');
146 header = read_mudela_header(ex + '.ly.txt')
147 def read_dict(s, default, h =header):
153 head = read_dict('title', ex)
154 composer = read_dict('composer', '')
155 desc = read_dict('description', '')
157 list.write('<h1>example file: %s</h1>' % head);
159 list.write('<h2>%s</h2>\n' % composer)
161 list.write('%s<p>' % desc)
163 def list_item(filename, desc, l = list):
164 if file_exist_b(filename):
165 l.write ('<li><a href=%s>%s</a>\n' % (filename, desc))
167 list_item(ex + '.ly.txt', 'The input')
168 for pageno in range(1,10):
169 f = ex + '-page%d.gif' % pageno
170 if not file_exist_b (f):
172 list_item(f, 'The output (picture, page %d)' % pageno)
173 list_item(ex + '.ps.gz', 'The output (gzipped PostScript)')
174 list_item(ex + '.midi', 'The output (MIDI)')
175 list.write ("</ul>");
177 list.write( "</BODY></HTML>");
181 print "copying files\n"
183 # my_system ("ln -s depth/out ./docxx" )
184 my_system([ "cp %s/TODO ./TODO.txt" % depth,
185 "cp %s/ANNOUNCE-0.1 ./ANNOUNCE.txt" % depth,
186 "cp %s/NEWS ./NEWS.txt" % depth,
187 "cp %s/DEDICATION ./DEDICATION.txt" % depth]);
188 my_system([ "make -C .. gifs"]);
192 banner= open('/tmp/lilybanner.html', 'w');
193 banner.write (footstr('../index.html'))
195 my_system(['BANNEROPT=\"-B /tmp/lilybanner.html\" %s/bin/out/make-docxx' % depth]);
196 # os.unlink( "/tmp/lilybanner.html");
201 result = result + glob.glob1('./', '*.' + a)
205 def join(inter, list):
206 return reduce (lambda x,y, i=inter: x + i + y, list)
210 list = get_glob( ['html', 'gif', 'ps.gz' , 'txt', 'midi'])
211 files = join (' ', list)
213 my_system( ['-tar zvhcf website.tar.gz ' + files + ' docxx/*'])
217 print 'This is %s\n' % id_str
220 my_system(['rm -f /tmp/gs*'])
222 def get_top_of_NEWS():
224 lines = i.readlines()
228 if regex.search('^\*\*\*\*\*\*', l) <> -1:
234 s = gulp_file('index.html')
235 s = regsub.sub ('top_of_NEWS', '<XMP>\n' + get_top_of_NEWS () + '\n</XMP>', s)
236 dump_file ('index.html', s)
239 files = get_glob(['html'])
243 if regex.search(makewebsite_id, s) <> -1:
246 s = regsub.sub ('</BODY>', footstr('index.html') + makewebsite_id + '</BODY>', s)
247 s = regsub.sub('<TITLE>\(.*\)</TITLE>$',
248 '<TITLE>LilyPond WWW: \\1</TITLE>', s)
254 os.chdir (lilydirs.topdir + 'Documentation/out')
255 __main__.depth = "../../";