]> git.donarmstrong.com Git - lilypond.git/blob - bin/make_website
release: 0.0.63
[lilypond.git] / bin / make_website
1 #!/usr/bin/perl -w
2
3
4 use FileHandle;
5
6 # do something, check return status
7 sub my_system
8 {
9     my (@cmds) = @_;
10     foreach $cmd (@cmds) {
11         my      $ret =  ( system ($cmd))/256;
12         if ($ret) {
13             print STDERR "\nmake_website: failed on command \`$cmd\' (status $ret)\n";
14             exit 2;
15         }
16     }
17 }
18
19 sub set_hrefs
20 {
21     while (<HTMLIN>) {
22         s#href=([A-Za-z.]+)#href=$base/$1#g;
23         print HTMLOUT $_;
24     }
25 }
26
27 sub all_refs
28 {
29     print "resetting refs.\n";
30
31     foreach $a (<*.html>)
32     {
33         rename $a, "$a~";
34         open HTMLIN, "$a~";
35         open HTMLOUT, ">$a";
36         set_hrefs;
37     }
38 }
39
40 local $base="lilypond/";
41 local @examples=("wohltemperirt" ,"standchen", "scsii-menuetto", "rhythm", "collisions");
42
43
44 sub gen_html
45 {
46     print "generating HTML\n";
47     my_system "make -kC .. html";
48 }
49
50 sub gen_examples
51 {
52     print "generating examples: \n";
53     foreach $a (@examples) {
54         $texfile="lelie";
55         $tex = "tex $texfile";
56         if ($a eq "standchen" || $a eq "scsii-menuetto" ) {
57             $tex = "latex $a";
58             $texfile = "$a";
59         }
60         
61         if ( ! -f "$a.ly.txt" ) {
62             my_system "ln $depth/input/$a.ly ./$a.ly.txt";
63         }
64         if ( ! -f "$a.ps.gz" ) {
65             my_system "lilypond $a;",
66             "$tex",
67             "dvips -o $a.ps $texfile;";
68
69         }
70
71         my_system "mv lelie.midi $a.midi; "     if ( -f "lelie.midi" );
72
73         # generate the pixmap at twice the size, then rescale (for antialiasing)
74         if ( ! -f "$a.gif" ) {
75             my_system "gs -q -sDEVICE=ppmraw -sOutputFile=- -r200 -dNOPAUSE  $a.ps -c quit |pnmscale 0.5| ppmtogif > $a.gif",
76              "gzip $a.ps";
77         }   
78     }
79 }
80
81
82 sub gen_list
83 {
84     print "generating HTML list\n";
85     open HTMLLIST, ">example_output.html";
86     print HTMLLIST "<title>LilyPond examples</title>\n";
87     foreach $a (@examples) {
88         $name=$a;
89         print HTMLLIST "<h1>example file: $name</h1>\n<XMP>\n";
90
91         open IF, "$depth/input/$a.ly";
92         input_record_separator IF "%}";
93         
94         $desc = <IF>;
95         close IF;
96         
97         print HTMLLIST "$desc\n</XMP>";
98
99         $inputf="$a.ly.txt";
100         $giff="$a.gif";
101         $psf="$a.ps.gz";
102         $midif="$a.midi";
103         
104         print HTMLLIST "<ul>
105 <li><a href=$inputf> The input file</a>
106 <li><a href=$giff>The output (gif)</a>
107 <li><a href=$psf>The output (PS)</a>\n";
108         
109         print HTMLLIST "<li><a href=$midif>The output (MIDI)</a>\n"
110             if ( -f $midif );
111         print HTMLLIST "</ul>";
112     }
113         close HTMLLIST;
114 }
115 sub copy_files
116 {  
117     print "copying files\n";
118     print `ln -s $depth/out ./docxx` if ( ! -x "docxx" ) ;
119     my_system "cp $depth/TODO ./TODO.txt",
120     "cp $depth/NEWS ./NEWS.txt",
121     "cp ../lelie*gif .";
122 }
123
124 sub docxx_update
125 {
126     my_system "make -C $depth doc++";
127 }
128
129 sub
130     do_tar
131 {
132      print "tarring.\n";
133      my_system
134          " tar vhcf website.tar *.html *.gif *.ps.gz *.ly.txt *.midi docxx/*;",
135          "gzip -f9 website.tar;";
136 }
137
138 $depth = "../../";
139 $ENV{"TEXINPUTS"} .= ":$depth/input/:";
140 $ENV{"LILYINCLUDE"} = "$depth/input/";
141 my $cwd;
142 chomp($cwd = `pwd`);
143
144 die "need to be in directory Documentation\n" if ( ! ($cwd =~ /Documentation$/));
145 chdir ("out");
146
147
148 gen_html;
149 gen_examples;
150 gen_list;
151 copy_files;
152 docxx_update;
153 do_tar;