]> git.donarmstrong.com Git - lilypond.git/blob - bin/make-website.in
release: 0.1.15
[lilypond.git] / bin / make-website.in
1 #!@PERL@ -w
2 # stupid script to generate WWW site. -*-Perl-*-
3
4 use FileHandle;
5 use Getopt::Long;
6
7 my $lily_version;
8 my $footstr;
9 my $mw_id = "<!make_website!>";
10 my $id_str = "make-website 0.4";
11 my $TAR="tar";
12 my $MAKE="make";
13
14 sub get_version
15 {
16     my ($vstr)=("");
17     open V, "$depth/VERSION";
18     while (<V>) {
19         s/#.*$//g;
20         next if (/^ *$/);
21         s/^/\$/;
22         s/= *(.*)$/=\"$1\";/;
23         $vstr .= $_;
24     }
25     eval ($vstr);
26     
27     $lily_version= "$TOPLEVEL_MAJOR_VERSION.$TOPLEVEL_MINOR_VERSION.$TOPLEVEL_PATCH_LEVEL$TOPLEVEL_MY_PATCH_LEVEL";
28     
29     # stupid checks.
30     $lily_version= "$TOPLEVEL_MAJOR_VERSION.$TOPLEVEL_MINOR_VERSION.$TOPLEVEL_PATCH_LEVEL$TOPLEVEL_MY_PATCH_LEVEL";
31
32
33     close V;
34 }
35
36 sub set_html_footer
37 {
38     my $MAILADDRESS=$ENV{MAILADDRESS};
39     my @pw=(getpwuid($<));
40     my $username=$pw[6];
41
42     $footstr = 
43         "\n<hr>Please take me <a href=index.html>back to the LilyPond index</a>\n<hr>
44 <font size=-1>
45 This page was built using <code>" . $id_str . "</code> from lilypond-"
46     . $lily_version . 
47         " by<p>
48 <address><br>$username <a href=mailto:" 
49     . $MAILADDRESS . ">&lt<!bla>" . $MAILADDRESS ."</a>&gt</address>
50 <p></font>";
51 }
52     
53
54 # do something, check return status
55 sub my_system
56 {
57     my (@cmds) = @_;
58     foreach $cmd (@cmds) {
59         my ($ignoreret)=0;
60         if ( $cmd  =~ /^-/ ) {
61             $ignoreret = 1;
62             $cmd = substr ($cmd, 1);
63         }
64         
65         my $ret =  ( system ($cmd));
66         if ($ret) {
67             if ($ignoreret) {
68                 print STDERR "ignoring failed command \`$cmd\' (status $ret)\n";
69             }else {
70                 print STDERR "\nmake_website: failed on command \`$cmd\' (status $ret)\n";
71                 exit 2;
72             }
73         }
74     }
75 }
76
77
78 local $base="lilypond/";
79
80 local @examples=("twinkle-pop", "twinkle", "multi", "wtk1-fugue2",
81                  #"standchen-16", 
82                  #"standchen-20", 
83                  "wtk1-prelude1",
84                  "toccata-fuga-E", 
85                  "scsii-menuetto",
86                  "cadenza", "scales", 
87                 "rhythm", 
88                  "gallina");
89
90
91 sub gen_html
92 {
93     print "generating HTML\n";
94     my_system "$MAKE -kC .. html";
95 }
96
97 sub gen_examples
98 {
99     print "generating examples: \n";
100     my @todo=();
101     foreach $a (@examples) {
102         push @todo, "out/$a.ps.gz", "out/$a.gif", "out/$a.ly.txt";
103     }
104     
105     my_system ("$MAKE -C .. " . join(' ', @todo));
106 }
107
108 my @texstuff = ("mudela-man", "mudela-course");
109
110 sub gen_manuals
111 {
112     print "generating TeX doco list\n";
113     open HTMLLIST, ">tex_manuals.html";
114     print HTMLLIST "<HTML><TITLE>PostScript Manuals</TITLE>\n" ;
115     print HTMLLIST "<BODY><h1>LilyPond manuals (in PostScript)</h1>";
116     print HTMLLIST "<ul>\n";
117     my @todo=();
118     foreach $a (@texstuff) {
119         push @todo , "out/$a.ps.gz";
120         print HTMLLIST "<li><a href=$a.ps.gz>$a.ps.gz</a>";
121     }
122     print HTMLLIST "</ul>";
123     
124     print HTMLLIST "</BODY></HTML>";
125     close HTMLLIST;
126
127     my_system( "$MAKE -C .. " .  join(' ', @todo));
128 }
129
130 sub gen_list
131 {
132     print "generating HTML list\n";
133     open HTMLLIST, ">example_output.html";
134
135     print HTMLLIST "<html><body><TITLE>Rendered Examples</TITLE>\n
136 These example files are taken from the LilyPond distribution.
137 LilyPond currently only outputs TeX and MIDI. The pictures and
138 PostScript files were generated using TeX, Ghostscript and some
139 graphics tools.  The papersize used for these examples is A4.  The GIF
140 files have been scaled to eliminate aliasing."; 
141
142
143
144     foreach $a (@examples)
145     {
146         $name=$a; print HTMLLIST "<h1>example file: $name</h1>\n<XMP>\n";
147
148         open IF, "$depth/input/$a.ly";
149         input_record_separator IF "\n}";
150         
151         $desc = <IF>;
152         close IF;
153         
154         print HTMLLIST "$desc\n</XMP>";
155
156         $inputf="$a.ly.txt";
157         $giff="$a.gif";
158         $jpegf="$a.jpeg";
159         $pngf = "$a.png";
160         $psf="$a.ps.gz";
161         $midif="$a.midi";
162         
163         print HTMLLIST "<ul>";
164
165         print HTMLLIST "<li><a href=$inputf> The input file</a>"
166             if ( -f $inputf );
167         
168         print HTMLLIST "<li><a href=$giff>The output (picture)</a>"     
169             if ( -f $giff );
170
171         print HTMLLIST "<li><a href=$psf>The output (PS)</a>\n"
172             if ( -f $psf );
173                 
174         print HTMLLIST "<li><a href=$midif>The output (MIDI)</a>\n" 
175             if ( -f $midif );
176         print HTMLLIST "</ul>";
177     }
178     print HTMLLIST "</BODY></HTML>";
179     close HTMLLIST;
180 }
181
182 sub edit_html
183 {
184     print STDERR "adding footer\n";
185
186     OUTER:
187     foreach $a (<*.html>) {
188         open H, "$a";
189         my $sep="</BODY>";
190         input_record_separator H $sep;
191         my $file="";
192         
193         while (<H>) { 
194             if (/$mw_id/) {
195                 close H;
196                 next OUTER;
197             }
198             $file .= $_; 
199
200         }
201         close H;
202
203         my $subst =  $footstr;
204         $subst .= $back if (! $a =~ /index.html/ );
205         $file =~ s/$sep/$subst$sep/g ;
206         $file =~ s/\.gif/\.$image/g;
207         $file =~ s!<TITLE>(.*)</TITLE>!<TITLE>LilyPond WWW: $1</TITLE>!g;
208         open H, ">$a";
209         print H $mw_id;
210         
211         print H $file;
212         close H;
213     }
214 }
215
216 sub copy_txt_file
217 {
218     my ($f) = @_;
219     my $d = $f;
220     $d =~ s!^.*\/!!;
221     if (! $f =~ /.txt$/) {
222         $d = "$f.txt";
223     }
224     print, $d;
225 }
226     
227 sub top_of_NEWS
228 {
229     open NEWS, "NEWS.txt";
230     input_record_separator NEWS "****";
231     $desc = <NEWS>;
232     chop ($desc);
233     close NEWS;
234
235     return $desc;
236 }
237
238 sub edit_index
239 {
240     $ton = top_of_NEWS();
241     $ton = "\n<XMP>\n$ton\n</XMP>\n";
242     open INDEX, "index.html";
243     input_record_separator NEWS undef;
244     $index = <INDEX>;
245     close INDEX;
246     $index =~ s/top_of_NEWS/$ton/;
247     open INDEX, ">index.html";
248     print INDEX $index;
249     close INDEX;
250 }
251
252
253 sub copy_files
254 {  
255     print "copying files\n";
256     my_system "ln -s $depth/out ./docxx" if ( ! -x "docxx" ) ;
257     my_system "cp $depth/TODO ./TODO.txt",
258     "cp $depth/ANNOUNCE ./ANNOUNCE.txt",
259     "cp $depth/NEWS ./NEWS.txt",
260     "cp $depth/DEDICATION ./DEDICATION.txt";
261     my_system "make -C .. gifs";
262     
263 }
264
265 sub set_images
266 {
267     for $a (<*.gif>) {
268         if ($opt_png) {
269             my_system "gif2png -d $a";
270         }
271         if ($opt_jpeg) {
272             my $b=$a;
273             $b =~ s/.gif/.jpeg/;
274             my_system "cjpeg -o $b $a";
275         }
276     }
277 }
278
279 sub docxx_update
280 {
281     open BANNER, ">/tmp/lilybanner.html";
282     my $ban = $footstr;
283     $ban =~ s!index.html!../index.html!g;
284     print BANNER $ban;
285     close BANNER;
286     my_system "$MAKE -C $depth docxx-opts=\"-p -S -k -B /tmp/lilybanner.html\" doc++";
287     # should add a cute header.
288 }
289
290 sub do_tar
291 {
292      print "tarring.\n";
293      $files = join (' ', < *.html *.$image *.ps.gz *.txt *.midi docxx/*>);
294      my_system
295          "-$TAR zvhcf website.tar.gz $files;",
296 #        "gzip -f9 website.tar;";
297 }
298
299 sub identify
300 {
301     print STDERR "This is " . $id_str . "\n";
302     
303 }
304 sub main
305 {
306     identify;
307     GetOptions("jpeg", "gif", "png", "noexamples");
308
309     local $image="gif" ;
310     $image = "png" if ($opt_png);
311     $image = "jpeg" if ($opt_jpeg);
312     
313     $depth = "../";
314     my $cwd;
315     chomp($cwd = `pwd`);
316     die "need to be in directory Documentation\n" if ( ! ($cwd =~ /Documentation$/));
317     get_version;
318     print "lily v. " . $lily_version . "\n";
319     set_html_footer;
320
321
322     $depth = "../../";
323
324     chdir ("out");
325     $ENV{"TEXINPUTS"} .= ":$depth/input/:";
326     $ENV{"LILYINCLUDE"} = "$depth/input/";
327
328
329     gen_html;
330     copy_files;
331
332     if (! $opt_noexamples) {
333         gen_examples;
334         gen_list;
335         gen_manuals;
336     }
337     set_images;
338
339     edit_html;
340     edit_index;
341     docxx_update;
342     do_tar;
343 }
344
345 main;