]> git.donarmstrong.com Git - lilypond.git/blob - bin/make-website.in
release: 0.1.0
[lilypond.git] / bin / make-website.in
1 #!@PERL@ -w
2 # stupid script to generate WWW site.
3
4 use FileHandle;
5 use Getopt::Long;
6 my $lily_version;
7 my $footstr;
8 my $mw_id = "<!make_website!>";
9 my $id_str = "make-website 0.3";
10
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 $MAILADRESS=$ENV{MAILADRESS};
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 index</a>\n<hr>
44 <font size=-1>
45 This page was generated by <code>" . $id_str . "</code> from lilypond-$lily_version by
46 <p>
47 <address><br>$username <a href=mailto:$MAILADRESS>&lt<!bla>$MAILADRESS</a>&gt</address>
48 <p>" . `date` . "
49 <p></font>";
50 }
51     
52
53 # do something, check return status
54 sub my_system
55 {
56     my (@cmds) = @_;
57     foreach $cmd (@cmds) {
58         my ($ignoreret)=0;
59         if ( $cmd  =~ /^-/ ) {
60             $ignoreret = 1;
61             $cmd = substr ($cmd, 1);
62         }
63         
64         my $ret =  ( system ($cmd));
65         if ($ret) {
66             if ($ignoreret) {
67                 print STDERR "ignoring failed command \`$cmd\' (status $ret)\n";
68             }else {
69                 print STDERR "\nmake_website: failed on command \`$cmd\' (status $ret)\n";
70                 exit 2;
71             }
72         }
73     }
74 }
75
76
77 local $base="lilypond/";
78 local @examples=("twinkle", "multi", "wohltemperirt" ,"standchen", "toccata-fuga-E", 
79                  "scsii-menuetto", "collisions", "cadenza", "scales");
80
81 # rhythm, scales, 
82
83
84 sub gen_html
85 {
86     print "generating HTML\n";
87     my_system "$MAKE -kC .. html";
88 }
89
90 sub gen_examples
91 {
92     print "generating examples: \n";
93     my @todo=();
94     foreach $a (@examples) {
95         push @todo, "out/$a.ps.gz", "out/$a.gif", "out/$a.ly.txt";
96     }
97     
98     my_system ("$MAKE -C .. " . join(' ', @todo));
99 }
100
101 my @texstuff = ("mudela-man", "mudela-course");
102
103 sub gen_manuals
104 {
105     print "generating TeX doco list\n";
106     open HTMLLIST, ">tex_manuals.html";
107     print HTMLLIST "<HTML><TITLE>LilyPond manuals</title>\n" ;
108     print HTMLLIST "<BODY><h1>LilyPond manuals (in PostScript)</h1>";
109     print HTMLLIST "<ul>\n";
110     my @todo=();
111     foreach $a (@texstuff) {
112         push @todo , "out/$a.ps.gz";
113         print HTMLLIST "<li><a href=$a.ps.gz>$a.ps.gz</a>";
114     }
115     print HTMLLIST "</ul>";
116     
117     print HTMLLIST "</BODY></HTML>";
118     close HTMLLIST;
119
120     my_system( "$MAKE -C .. " .  join(' ', @todo));
121 }
122
123 sub gen_list
124 {
125     print "generating HTML list\n";
126     open HTMLLIST, ">example_output.html";
127     print HTMLLIST "<html><body><title>LilyPond examples</title>\n
128 These example files are taken from the LilyPond distribution.\n
129 LilyPond currently only outputs TeX and MIDI. The pictures and\n
130  PostScript files were generated using TeX, Ghostscript and some graphics tools. \n
131 The GIF files have been scaled to eliminate aliasing.";
132     foreach $a (@examples) {
133         $name=$a;
134         print HTMLLIST "<h1>example file: $name</h1>\n<XMP>\n";
135
136         open IF, "$depth/input/$a.ly";
137         input_record_separator IF "%}";
138         
139         $desc = <IF>;
140         close IF;
141         
142         print HTMLLIST "$desc\n</XMP>";
143
144         $inputf="$a.ly.txt";
145         $giff="$a.gif";
146         $jpegf="$a.jpeg";
147         $pngf = "$a.png";
148         $psf="$a.ps.gz";
149         $midif="$a.midi";
150         
151         print HTMLLIST "<ul>";
152
153         print HTMLLIST "<li><a href=$inputf> The input file</a>"
154             if ( -f $inputf );
155         
156         print HTMLLIST "<li><a href=$giff>The output (picture)</a>"     
157             if ( -f $giff );
158
159         print HTMLLIST "<li><a href=$psf>The output (PS)</a>\n"
160             if ( -f $psf );
161                 
162         print HTMLLIST "<li><a href=$midif>The output (MIDI)</a>\n" 
163             if ( -f $midif );
164         print HTMLLIST "</ul>";
165     }
166     print HTMLLIST "</BODY></HTML>";
167     close HTMLLIST;
168 }
169
170 sub edit_html
171 {
172     print STDERR "adding footer\n";
173
174     OUTER:
175     foreach $a (<*.html>) {
176         open H, "$a";
177         my $sep="</BODY>";
178         input_record_separator H $sep;
179         my $file="";
180         
181         while (<H>) { 
182             if (/$mw_id/) {
183                 close H;
184                 next OUTER;
185             }
186             $file .= $_; 
187
188         }
189         close H;
190
191         my $subst =  $footstr;
192         $subst .= $back if (! $a =~ /index.html/ );
193         $file =~ s/$sep/$subst$sep/g ;
194         $file =~ s/\.gif/\.$image/g;
195         open H, ">$a";
196         print H $mw_id;
197         print H $file;
198         close H;
199     }
200 }
201
202 sub copy_txt_file
203 {
204     my ($f) = @_;
205     my $d = $f;
206     $d =~ s!^.*\/!!;
207     if (! $f =~ /.txt$/) {
208         $d = "$f.txt";
209     }
210     print $f, $d;
211 }
212     
213 sub copy_files
214 {  
215     print "copying files\n";
216     print `ln -s $depth/out ./docxx` if ( ! -x "docxx" ) ;
217     my_system "cp $depth/TODO ./TODO.txt",
218     "cp $depth/ANNOUNCE ./ANNOUNCE.txt",
219     "cp $depth/NEWS ./NEWS.txt",
220     "cp $depth/DEDICATION ./DEDICATION.txt",
221     "cp ../lelie*gif .";
222 }
223
224 sub set_images
225 {
226     for $a (<*.gif>) {
227         if ($opt_png) {
228             my_system "gif2png -d $a";
229         }
230         if ($opt_jpeg) {
231             my $b=$a;
232             $b =~ s/.gif/.jpeg/;
233             my_system "cjpeg -o $b $a";
234         }
235     }
236 }
237
238 sub docxx_update
239 {
240     my_system "$MAKE -C $depth doc++";
241 }
242
243 sub do_tar
244 {
245      print "tarring.\n";
246      $files = join (' ', < *.html *.$image *.ps.gz *.txt *.midi docxx/*>);
247      my_system
248          "-$TAR zvhcf website.tar.gz $files;",
249 #        "gzip -f9 website.tar;";
250 }
251
252 sub identify
253 {
254     print STDERR "This is " . $id_str . "\n";
255     
256 }
257 sub main
258 {
259     identify;
260     GetOptions("jpeg", "gif", "png", "noexamples");
261
262     local $image="gif" ;
263     $image = "png" if ($opt_png);
264     $image = "jpeg" if ($opt_jpeg);
265     
266     $depth = "../";
267     my $cwd;
268     chomp($cwd = `pwd`);
269     die "need to be in directory Documentation\n" if ( ! ($cwd =~ /Documentation$/));
270     get_version;
271     set_html_footer;
272
273
274     $depth = "../../";
275
276     chdir ("out");
277     $ENV{"TEXINPUTS"} .= ":$depth/input/:";
278     $ENV{"LILYINCLUDE"} = "$depth/input/";
279
280
281     gen_html;
282     copy_files;
283     if (! $opt_noexamples) {
284         gen_examples;
285         gen_list;
286     }
287     gen_manuals;
288     set_images;
289
290     edit_html;
291     docxx_update;
292     do_tar;
293 }
294
295 main;