lilypond-0.1.56
[lilypond.git] / bin / make_website
blob89fafd7c246acbc0a248866d6825795ba53cd4b5
1 #!/usr/bin/perl -w
2 # stupid script to generate WWW site.
4 use FileHandle;
5 use Getopt::Long;
6 my $lily_version;
7 my $footstr;
8 my $mw_id = "<!make_website!>";
10 sub get_version
12 my ($vstr)=("");
13 open V, "$depth/.version";
14 while (<V>) {
15 s/#.*$//g;
16 next if (/^ *$/);
17 s/^/\$/;
18 s/= *(.*)$/=\"$1\";/;
19 $vstr .= $_;
21 eval ($vstr);
23 $lily_version= "$TOPLEVEL_MAJOR_VERSION.$TOPLEVEL_MINOR_VERSION.$TOPLEVEL_PATCH_LEVEL$TOPLEVEL_MY_PATCH_LEVEL";
25 # stupid checks.
26 $lily_version= "$TOPLEVEL_MAJOR_VERSION.$TOPLEVEL_MINOR_VERSION.$TOPLEVEL_PATCH_LEVEL$TOPLEVEL_MY_PATCH_LEVEL";
29 close V;
32 sub set_html_footer
34 my $MAILADRESS=$ENV{MAILADRESS};
35 my @pw=(getpwuid($<));
36 my $username=$pw[6];
38 $footstr =
39 "\n<hr>Please take me <a href=index.html>back to the index</a>\n<hr>
40 <font size=-1>
41 This page was generated by <code>make_website</code> from lilypond-$lily_version by
42 <p>
43 <address><br>$username <a href=mailto:$MAILADRESS>&lt<!bla>$MAILADRESS</a>&gt</address>
44 <p>" . `date` . "
45 <p></font>";
49 # do something, check return status
50 sub my_system
52 my (@cmds) = @_;
53 foreach $cmd (@cmds) {
54 my ($ignoreret)=0;
55 if ( $cmd =~ /^-/ ) {
56 $ignoreret = 1;
57 $cmd = substr ($cmd, 1);
60 my $ret = ( system ($cmd));
61 if ($ret) {
62 if ($ignoreret) {
63 print STDERR "ignoring failed command \`$cmd\' (status $ret)\n";
64 }else {
65 print STDERR "\nmake_website: failed on command \`$cmd\' (status $ret)\n";
66 exit 2;
73 local $base="lilypond/";
74 local @examples=("multi", "wohltemperirt" ,"standchen", "toccata-fuga-E",
75 "scsii-menuetto", "collisions", "cadenza", "scales", "book");
77 # rhythm, scales,
80 sub gen_html
82 print "generating HTML\n";
83 my_system "make -kC .. html";
86 sub ps_to_gif
88 my ($a)=@_;
90 if (! -f "$a.ps" ) {
91 my_system("gunzip -c $a.ps.gz > $a.ps");
93 my_system "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif";
97 sub ps_to_jpeg
99 my ($a)=@_;
100 my $in = "$a.ps";
102 my_system "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE $in -c quit |pnmscale 0.5| cjpeg -grayscale > $a.jpeg";
105 sub gen_examples
107 print "generating examples: \n";
108 foreach $a (@examples) {
109 $texfile="lelie";
110 $tex = "tex $texfile";
111 if ($a eq "standchen" || $a eq "scsii-menuetto" || $a eq "book" ) {
112 $tex = "latex $a";
113 $texfile = "$a";
116 if ( ! -f "$a.ly.txt" ) {
117 my_system "ln $depth/input/$a.ly ./$a.ly.txt";
119 if (! -f "$a.dvi" ) {
120 my_system "lilypond $a;",
121 "$tex", "-mv $texfile.dvi $a.dvi";
123 if ( ! -f "$a.ps.gz" && ! -f "$a.ps" ) {
124 my_system "dvips -o $a.ps $a.dvi";
127 my_system "mv lelie.midi $a.midi; " if ( -f "lelie.midi" );
129 # generate the pixmap at twice the size, then rescale (for antialiasing)
130 if ( ! -f "$a.gif" ) {
131 ps_to_gif($a);
133 if ( ! -f "$a.ps.gz" ) {
134 my_system "gzip -f $a.ps";
140 sub gen_list
142 print "generating HTML list\n";
143 open HTMLLIST, ">example_output.html";
144 print HTMLLIST "<html><body><title>LilyPond examples</title>\n
145 These example files are taken from the LilyPond distribution.\n
146 LilyPond currently only outputs TeX and MIDI. The pictures and\n
147 PostScript files were generated using TeX, Ghostscript and some graphics tools. \n
148 The GIF files have been scaled to eliminate aliasing.";
149 foreach $a (@examples) {
150 $name=$a;
151 print HTMLLIST "<h1>example file: $name</h1>\n<XMP>\n";
153 open IF, "$depth/input/$a.ly";
154 input_record_separator IF "%}";
156 $desc = <IF>;
157 close IF;
159 print HTMLLIST "$desc\n</XMP>";
161 $inputf="$a.ly.txt";
162 $giff="$a.gif";
163 $jpegf="$a.jpeg";
164 $pngf = "$a.png";
165 $psf="$a.ps.gz";
166 $midif="$a.midi";
168 print HTMLLIST "<ul>";
170 print HTMLLIST "<li><a href=$inputf> The input file</a>"
171 if ( -f $inputf );
173 print HTMLLIST "<li><a href=$giff>The output (picture)</a>"
174 if ( -f $giff );
176 print HTMLLIST "<li><a href=$psf>The output (PS)</a>\n"
177 if ( -f $psf );
179 print HTMLLIST "<li><a href=$midif>The output (MIDI)</a>\n"
180 if ( -f $midif );
181 print HTMLLIST "</ul>";
183 print HTMLLIST "</BODY></HTML>";
184 close HTMLLIST;
187 sub edit_html
189 print STDERR "adding footer\n";
191 OUTER:
192 foreach $a (<*.html>) {
193 open H, "$a";
194 my $sep="</BODY>";
195 input_record_separator H $sep;
196 my $file="";
198 while (<H>) {
199 if (/$mw_id/) {
200 close H;
201 next OUTER;
203 $file .= $_;
206 close H;
208 my $subst = $footstr;
209 $subst .= $back if (! $a =~ /index.html/ );
210 $file =~ s/$sep/$subst$sep/g ;
211 $file =~ s/\.gif/\.$image/g;
212 open H, ">$a";
213 print H $mw_id;
214 print H $file;
215 close H;
219 sub copy_files
221 print "copying files\n";
222 print `ln -s $depth/out ./docxx` if ( ! -x "docxx" ) ;
223 my_system "cp $depth/TODO ./TODO.txt",
224 "cp $depth/NEWS ./NEWS.txt",
225 "cp ../lelie*gif .";
228 sub set_images
230 for $a (<*.gif>) {
231 if ($opt_png) {
232 my_system "gif2png -d $a";
234 if ($opt_jpeg) {
235 my $b=$a;
236 $b =~ s/.gif/.jpeg/;
237 my_system "cjpeg -o $b $a";
242 sub docxx_update
244 my_system "make -C $depth doc++";
247 sub do_tar
249 print "tarring.\n";
250 $files = join (' ', < *.html *.$image *.ps.gz *.txt *.midi docxx/*>);
251 my_system
252 "-tar vhcf website.tar $files;",
253 "gzip -f9 website.tar;";
255 sub identify
257 print STDERR "make_website 0.1\n";
260 sub main
262 identify;
263 GetOptions("jpeg", "gif", "png", "noexamples");
265 local $image="gif" ;
266 $image = "png" if ($opt_png);
267 $image = "jpeg" if ($opt_jpeg);
269 $depth = "../";
270 my $cwd;
271 chomp($cwd = `pwd`);
272 die "need to be in directory Documentation\n" if ( ! ($cwd =~ /Documentation$/));
273 get_version;
274 set_html_footer;
277 $depth = "../../";
279 chdir ("out");
280 $ENV{"TEXINPUTS"} .= ":$depth/input/:";
281 $ENV{"LILYINCLUDE"} = "$depth/input/";
284 gen_html;
285 copy_files;
286 if (! $opt_noexamples) {
287 gen_examples;
288 gen_list;
290 set_images;
292 edit_html;
293 docxx_update;
294 do_tar;
297 main;