]> git.donarmstrong.com Git - lilypond.git/blobdiff - bin/make_website
release: 0.0.70pre
[lilypond.git] / bin / make_website
index ce8c6bb7936407ecbfd0538dd462eaa2b95a30f3..096d700280b806c95224ae5b3976e09a60cc6669 100755 (executable)
@@ -2,9 +2,11 @@
 # stupid script to generate WWW site.
 
 use FileHandle;
+use Getopt::Long;
 my $lily_version;
 my $footstr;
 my $mw_id = "<!make_website!>";
+
 sub get_version
 {
     my ($vstr)=("");
@@ -49,17 +51,29 @@ sub my_system
 {
     my (@cmds) = @_;
     foreach $cmd (@cmds) {
+       my ($ignoreret)=0;
+       if ( $cmd  =~ /^-/ ) {
+           $ignoreret = 1;
+           $cmd = substr ($cmd, 1);
+       }
+       
        my $ret =  ( system ($cmd));
        if ($ret) {
-           print STDERR "\nmake_website: failed on command \`$cmd\' (status $ret)\n";
-           exit 2;
+           if ($ignoreret) {
+               print STDERR "ignoring failed command \`$cmd\' (status $ret)\n";
+           }else {
+               print STDERR "\nmake_website: failed on command \`$cmd\' (status $ret)\n";
+               exit 2;
+           }
        }
     }
 }
 
 
 local $base="lilypond/";
-local @examples=("wohltemperirt" ,"standchen", "scsii-menuetto", "rhythm", "collisions");
+local @examples=("multi", "wohltemperirt" ,"standchen", "toccata-fuga-E", "scsii-menuetto", "collisions");
+
+# rhythm, scales, 
 
 
 sub gen_html
@@ -68,6 +82,25 @@ sub gen_html
     my_system "make -kC .. html";
 }
 
+sub ps_to_gif 
+{
+    my ($a)=@_;
+    if (! -f "$a.ps" ) {
+       my_system("gunzip -c $a.ps.gz > $a.ps");
+    }
+    my_system "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE  $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif";
+}
+
+
+sub ps_to_jpeg
+{ 
+    my ($a)=@_;
+    my $in = "$a.ps";
+    
+    my_system "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE  $in -c quit |pnmscale 0.5| cjpeg -grayscale > $a.jpeg";
+}
+
 sub gen_examples
 {
     print "generating examples: \n";
@@ -82,19 +115,22 @@ sub gen_examples
        if ( ! -f "$a.ly.txt" ) {
            my_system "ln $depth/input/$a.ly ./$a.ly.txt";
        }
-       if ( ! -f "$a.ps.gz" ) {
+       if (! -f "$a.dvi" ) {
            my_system "lilypond $a;",
-           "$tex",
-           "dvips -o $a.ps $texfile;";
-
+           "$tex", "-mv $texfile.dvi $a.dvi";
+       }  
+       if ( ! -f "$a.ps.gz" && ! -f "$a.ps" ) {
+           my_system "dvips -o $a.ps $a.dvi";
        }
 
-       my_system "mv lelie.midi $a.midi; "     if ( -f "lelie.midi" );
+       my_system "mv lelie.midi $a.midi; " if ( -f "lelie.midi" );
 
        # generate the pixmap at twice the size, then rescale (for antialiasing)
        if ( ! -f "$a.gif" ) {
-           my_system "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE  $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif",
-            "gzip $a.ps";
+           ps_to_gif($a);
+       }
+       if ( ! -f "$a.ps.gz" ) {
+           my_system "gzip -f $a.ps";
        }   
     }
 }
@@ -104,7 +140,11 @@ sub gen_list
 {
     print "generating HTML list\n";
     open HTMLLIST, ">example_output.html";
-    print HTMLLIST "<html><body><title>LilyPond examples</title>\n";
+    print HTMLLIST "<html><body><title>LilyPond examples</title>\n
+These example files are taken from the LilyPond distribution.\n
+LilyPond currently only outputs TeX and MIDI. The pictures and\n
+ PostScript files were generated using TeX, Ghostscript and some graphics tools. \n
+The GIF files have been scaled to eliminate aliasing.";
     foreach $a (@examples) {
        $name=$a;
        print HTMLLIST "<h1>example file: $name</h1>\n<XMP>\n";
@@ -119,20 +159,28 @@ sub gen_list
 
        $inputf="$a.ly.txt";
        $giff="$a.gif";
+       $jpegf="$a.jpeg";
+       $pngf = "$a.png";
        $psf="$a.ps.gz";
        $midif="$a.midi";
        
-       print HTMLLIST "<ul>
-<li><a href=$inputf> The input file</a>
-<li><a href=$giff>The output (gif)</a>
-<li><a href=$psf>The output (PS)</a>\n";
+       print HTMLLIST "<ul>";
+
+       print HTMLLIST "<li><a href=$inputf> The input file</a>"
+           if ( -f $inputf );
        
-       print HTMLLIST "<li><a href=$midif>The output (MIDI)</a>\n"
+       print HTMLLIST "<li><a href=$giff>The output (picture)</a>"     
+           if ( -f $giff );
+
+       print HTMLLIST "<li><a href=$psf>The output (PS)</a>\n"
+           if ( -f $psf );
+               
+       print HTMLLIST "<li><a href=$midif>The output (MIDI)</a>\n" 
            if ( -f $midif );
        print HTMLLIST "</ul>";
     }
     print HTMLLIST "</BODY></HTML>";
-       close HTMLLIST;
+    close HTMLLIST;
 }
 
 sub edit_html
@@ -159,13 +207,14 @@ sub edit_html
        my $subst =  $footstr;
        $subst .= $back if (! $a =~ /index.html/ );
        $file =~ s/$sep/$subst$sep/g ;
-       
+       $file =~ s/\.gif/\.$image/g;
        open H, ">$a";
        print H $mw_id;
        print H $file;
        close H;
     }
 }
+
 sub copy_files
 {  
     print "copying files\n";
@@ -175,6 +224,20 @@ sub copy_files
     "cp ../lelie*gif .";
 }
 
+sub set_images
+{
+    for $a (<*.gif>) {
+       if ($opt_png) {
+           my_system "gif2png -d $a";
+       }
+       if ($opt_jpeg) {
+           my $b=$a;
+           $b =~ s/.gif/.jpeg/;
+           my_system "cjpeg -o $b $a";
+       }
+    }
+}
+
 sub docxx_update
 {
     my_system "make -C $depth doc++";
@@ -183,13 +246,25 @@ sub docxx_update
 sub do_tar
 {
      print "tarring.\n";
+     $files = join (' ', < *.html *.$image *.ps.gz *.txt *.midi docxx/*>);
      my_system
-        " tar vhcf website.tar *.html *.gif *.ps.gz *.txt *.midi docxx/*;",
+        "-tar vhcf website.tar $files;",
         "gzip -f9 website.tar;";
 }
-
+sub identify
+{
+    print STDERR "make_website 0.1\n";
+    
+}
 sub main
 {
+    identify;
+    GetOptions("jpeg", "gif", "png", "noexamples");
+
+    local $image="gif" ;
+    $image = "png" if ($opt_png);
+    $image = "jpeg" if ($opt_jpeg);
+    
     $depth = "../";
     my $cwd;
     chomp($cwd = `pwd`);
@@ -206,11 +281,16 @@ sub main
 
 
     gen_html;
-    gen_examples;
-    gen_list;
     copy_files;
+    if (! $opt_noexamples) {
+       gen_examples;
+       gen_list;
+    }
+    set_images;
+
     edit_html;
     docxx_update;
     do_tar;
 }
+
 main;