forked from MutopiaProject/MutopiaProject
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mutopia_HTMLGen.pm
650 lines (538 loc) · 22.3 KB
/
Mutopia_HTMLGen.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
#!/usr/bin/perl -w
#
# Mutopia_HTMLGen.pm
# Subroutines to help with generating HTML pages from html-in/* files.
package Mutopia_HTMLGen;
# use strict; # Must declare variables with "my" or "use vars"
use Mutopia_Archive; # helpful subroutines
use POSIX qw(strftime);
use Time::Local;
use utf8;
use vars qw(%RDF_DATA);
my %RDF_DATA;
my $OUTPUT_FILE;
# makeHTML(\%RDF_DATA)
# Read *.html-in, fill with generated data, and write *.html
#
sub makeHTML($) {
my $rdf_ref = shift;
%RDF_DATA = %$rdf_ref;
chdir "html-in" or die "cannot chdir to html-in: $!";
my @infiles = glob("*.html-in");
chdir "..";
for my $infile(@infiles) {
open (IN, "<:utf8", "html-in/$infile") or die "cannot open $infile: $!";
local $_ = join "", <IN>;
close IN;
# stick warning message in
my $msg = <<________EOM;$msg=~s/^ {8}//gm;s/<head/\n$msg\n<head/;
<!--*********************************************************
** Automatically generated from $infile.
** Any changes made to this file will be lost!
*********************************************************-->
________EOM
($OUTPUT_FILE = $infile) =~ s/\.html-in$/.html/
or die "invalid filename: $infile";
replace_placeholders(\$_);
open OUT, ">:utf8", "$OUTPUT_FILE" or die "cannot open >$OUTPUT_FILE: $!";
print OUT $_;
close OUT;
undef $OUTPUT_FILE;
}
chdir "html-in" or die "cannot chdir to html-in: $!";
@infiles = glob("*.rss-in");
chdir "..";
for my $infile(@infiles) {
open (IN, "<:utf8", "html-in/$infile") or die "cannot open $infile: $!";
local $_ = join "", <IN>;
close IN;
($OUTPUT_FILE = $infile) =~ s/\.rss-in$/.rss/
or die "invalid filename: $infile";
replace_placeholders(\$_);
open OUT, ">:utf8", "$OUTPUT_FILE" or die "cannot open >$OUTPUT_FILE: $!";
print OUT $_;
close OUT;
undef $OUTPUT_FILE;
}
}
# replace_placeholders(\$html)
# Replaces placeholders like [[ code ]] with generated HTML
#
sub replace_placeholders($) {
my $html = shift;
# Execute the contents of [[ ]] brackets in the HTML, and substitute
# the value returned. The trickery with "eval" is to ensure that we
# see the error messages generated, if there were any.
1 while $$html =~ s(\[\[(.*?)\]\])(
my $return;
eval "\$return = (sub{$1})->()";
die $@ if $@;
$return;
)ges;
}
###################################################################
# Subroutines to generate useful fragments of HTML. The variable
# %RDF_DATA contains the collection data, and $OUTPUT_FILE contains
# the name of the file currently being outputted to.
###################################################################
sub BROWSE_BY_COMPOSER {
my %comps = Mutopia_Archive::getData("datafiles/composers.dat");
my $html = "";
for my $k (sort {Mutopia_Archive::byComposer($a,$b)} keys %comps) {
# How many pieces by this composer?
open (SEARCHCACHE, '<:utf8', 'datafiles/searchcache.dat')
or die "cannot open datafiles/searchcache.dat: $!";
my $noofpieces = 0;
my $finish = 0;
do {
chomp(my $templine = <SEARCHCACHE>);
if ($templine =~ /^composerK:$k/) { $noofpieces++ }
if ($templine =~ /^date/) { $finish = 1 }
} until (($finish == 1) || (eof SEARCHCACHE));
close(SEARCHCACHE);
$html .= "<a href='cgibin/make-table.cgi?Composer=$k'>";
$html .= $comps{$k} . "</a> [$noofpieces]<br />\n";
}
return $html;
}
sub BROWSE_BY_INSTRUMENT {
my %insts = Mutopia_Archive::getData("datafiles/instruments.dat");
my $html = "";
for my $k (sort {Mutopia_Archive::byInstrument($a,$b)} keys %insts) {
# How many pieces for this instrument?
open (SEARCHCACHE, '<:utf8', 'datafiles/searchcache.dat')
or die "cannot open datafiles/searchcache.dat: $!";
my $noofpieces = 0;
my $finish = 0;
do {
chomp(my $templine = <SEARCHCACHE>);
if ( ($templine =~ /^instruments:/) &&
( $templine =~ /$k/ )) { $noofpieces++ }
if (($k eq "Harp") and ($templine =~ /Harpsichord/)) { $noofpieces-- }
if ($templine =~ /^licence/) { $finish = 1 }
} until (($finish == 1) || (eof SEARCHCACHE));
close(SEARCHCACHE);
$html .= "<a href='cgibin/make-table.cgi?Instrument=$k'>";
$html .= $insts{$k} . "</a> [$noofpieces]<br />\n";
}
return $html;
}
sub BROWSE_BY_STYLE {
my %styles = Mutopia_Archive::getData("datafiles/styles.dat");
my $html = "";
for my $k (sort keys %styles) {
# How many pieces in this style?
open (SEARCHCACHE, '<:utf8', 'datafiles/searchcache.dat')
or die "cannot open datafiles/searchcache.dat: $!";
my $noofpieces = 0;
my $finish = 0;
do {
chomp(my $templine = <SEARCHCACHE>);
if ($templine =~ /^style:$styles{$k}/) { $noofpieces++ }
if ($templine =~ /^title/) { $finish = 1 }
} until (($finish == 1) || (eof SEARCHCACHE));
close(SEARCHCACHE);
$html .= "<a href='cgibin/make-table.cgi?Style=$k'>";
$html .= $styles{$k} . "</a> [$noofpieces]<br />\n";
}
return $html;
}
sub BROWSE_COLLECTIONS {
open (COLLECTIONS, '<:utf8', 'datafiles/collections.dat');
my $lineread;
my $colname;
my $coldesc;
my $html = "<ul>\n";
do {
chomp($lineread = <COLLECTIONS>);
$lineread =~ /^(\w+):([\w\W]+):/;
$colname = $1;
$coldesc = $2;
$html .= "<li><a href=\"cgibin/make-table.cgi?collection=";
$html .= $colname . "&preview=1\">" . $coldesc . "</a></li>\n";
} until (eof COLLECTIONS);
$html .= "</ul>\n";
close (COLLECTIONS);
return $html;
}
sub COMPOSER_OPTIONS {
my %comps = Mutopia_Archive::getData("datafiles/composers.dat");
my $html = "";
for my $k (sort {Mutopia_Archive::byComposer($a,$b)} keys %comps) {
$html .= "<option value='$k'>" . $comps{$k} . "</option>\n";
}
return $html;
}
sub COMPOSER_LIST {
my %comps = Mutopia_Archive::getData("datafiles/composers.dat");
my $html = "";
for my $k (sort {Mutopia_Archive::byComposer($a,$b)} keys %comps) {
$html .= $k . ", ";
}
return substr($html, 0, -2);
}
sub INSTRUMENT_OPTIONS {
my %insts = Mutopia_Archive::getData("datafiles/instruments.dat");
my $html = "";
for my $k (sort {Mutopia_Archive::byInstrument($a,$b)} keys %insts) {
$html .= "<option value='$k'>" . $insts{$k} . "</option>\n";
}
return $html;
}
sub STYLE_OPTIONS {
my %styles = Mutopia_Archive::getData("datafiles/styles.dat");
my $html = "";
for my $k (sort keys %styles) {
$html .= "<option value='$k'>" . $styles{$k} . "</option>\n";
}
return $html;
}
sub STYLE_LIST {
my %styles = Mutopia_Archive::getData("datafiles/styles.dat");
my $html = "";
for my $k (sort keys %styles) {
$html .= $k . ", ";
}
return substr($html, 0, -2);
}
sub NUMBER_OF_PIECES {
# returns the number of pieces (counted from musiccache.dat)
open (CACHE, '<:utf8', 'datafiles/musiccache.dat');
chomp(my $headerlength = <CACHE>);
my $numberofpieces = 0;
while (1) {
chomp(my $templine = <CACHE>);
if ($templine =~ /^[0-9]+:[0-9]+$/) { $numberofpieces++ }
last if $templine eq "**********";
}
close(CACHE);
return $numberofpieces;
}
sub LATEST_ADDITIONS($) {
# returns HTML of links to the most recent pieces.
# argument is the number of pieces to display
#order by ID, most recent first
my @recent = sort {
$a->{id} =~ /-(\d+)$/ or die "invalid id: ", $a->{id};
my $idA = $1;
$b->{id} =~ /-(\d+)$/ or die "invalid id: ", $b->{id};
my $idB = $1;
return $idB <=> $idA;
} values %RDF_DATA;
# generate HTML listing for most recent pieces
my $html = "";
my $last_piece = (shift) - 1;
for my $piece(@recent[0 .. $last_piece]) {
my($date, $id) = $piece->{id} =~ m|-(\d+/\d+/\d+)-(\d+)$|
or die "invalid id: " . $piece->{id};
$html .= "<b>$date</b> - ";
$html .= "<a href='cgibin/piece-info.cgi?id=$id'>";
$html .= $piece->{title} . ", ";
if ($piece->{composer} !~ /^(Anonymous|Traditional)$/) {
$html .= "by ";
}
$html .= $piece->{composer};
$html .= " - " . $piece->{opus} . " for " . $piece->{for};
$html .= "</a><br />\n";
}
return $html;
}
sub LATEST_ADDITIONS_RSS($) {
# returns XML of links to the most recent pieces.
# argument is the number of pieces to display
#order by ID, most recent first
my @recent = sort {
$a->{id} =~ /-(\d+)$/ or die "invalid id: ", $a->{id};
my $idA = $1;
$b->{id} =~ /-(\d+)$/ or die "invalid id: ", $b->{id};
my $idB = $1;
return $idB <=> $idA;
} values %RDF_DATA;
# generate XML listing for most recent pieces
my $xml = "<pubDate>". strftime("%a, %d %b %Y %T %z", localtime()) . "</pubDate>\n";
my ($fy, $fm, $fd) = $recent[0]->{id} =~ m|-(\d+)/(\d+)/(\d+)-\d+$|;
$xml .= "<lastBuildDate>" . strftime("%a, %d %b %Y %T %z", localtime(timelocal(0, 0, 0, $fd, $fm - 1, $fy))) . "</lastBuildDate>\n\n";
my $last_piece = (shift) - 1;
for my $piece(@recent[0 .. $last_piece]) {
my($y, $m, $d, $id) = $piece->{id} =~ m|-(\d+)/(\d+)/(\d+)-(\d+)$|
or die "invalid id: " . $piece->{id};
$xml .= "<item>\n";
$xml .= "<title>" . $piece->{composer} . ": " . $piece->{title} . "</title>\n";
$xml .= "<link>http://www.mutopiaproject.org/cgibin/piece-info.cgi?id=" . $id . "</link>\n";
$xml .= "<guid>http://www.mutopiaproject.org/cgibin/piece-info.cgi?id=" . $id . "</guid>\n";
$xml .= "<description>" . $piece->{title} . ", ";
if ($piece->{composer} !~ /^(Anonymous|Traditional)$/) {
$xml .= "by ";
}
$xml .= $piece->{composer};
$xml .= " - " . $piece->{opus} . " for " . $piece->{for};
$xml .= "</description>\n";
$xml .= "<pubDate>" . strftime("%a, %d %b %Y %T %z", localtime(timelocal(0, 0, 0, $d, $m - 1, $y))) . "</pubDate>\n";
$xml .= "</item>\n\n";
}
return $xml;
}
sub ALL_PIECES {
# returns HTML of links to all pieces in the archive (made from the cache)
my $html = "";
open (CACHE, '<:utf8', 'datafiles/musiccache.dat');
chomp (my $headerlength = <CACHE>);
seek CACHE, $headerlength, 0;
until (eof CACHE) {
chomp (my $checkline = <CACHE>);
if ($checkline ne "**********") { print "ERROR in the datafile - rebuild cache"; }
chomp (my $idno = <CACHE>);
chomp (my $midrif = <CACHE>);
chomp (my $musicnm = <CACHE>);
chomp (my $lyfile = <CACHE>);
chomp (my $midfile = <CACHE>);
chomp (my $a4psfile = <CACHE>);
chomp (my $a4pdffile = <CACHE>);
chomp (my $letpsfile = <CACHE>);
chomp (my $letpdffile = <CACHE>);
chomp (my $pngfile = <CACHE>);
chomp (my $pngheight = <CACHE>);
chomp (my $pngwidth = <CACHE>);
chomp (my $title = <CACHE>);
chomp (my $composer = <CACHE>);
chomp (my $opus = <CACHE>);
chomp (my $lyricist = <CACHE>);
chomp (my $instrument = <CACHE>);
chomp (my $date = <CACHE>);
chomp (my $style = <CACHE>);
chomp (my $metre = <CACHE>);
chomp (my $arranger = <CACHE>);
chomp (my $source = <CACHE>);
chomp (my $copyright = <CACHE>);
chomp (my $id = <CACHE>);
chomp (my $maintainer = <CACHE>);
chomp (my $maintaineremail = <CACHE>);
chomp (my $maintainerweb = <CACHE>);
chomp (my $extrainfo = <CACHE>);
chomp (my $lilypondversion = <CACHE>);
chomp (my $collections = <CACHE>);
chomp (my $printurl = <CACHE>);
if ($opus eq "") { $opus = " " }
my $compLessDates;
if (index($composer, "(") > 0) {
$compLessDates = substr($composer, 0, index($composer, "(") - 1);;
} else {
$compLessDates = $composer;
}
$html .= "<tr><td>".$compLessDates."</td><td><a href=\"cgibin/piece-info.cgi?id=".$idno."\">";
$html .= $title."</a></td><td>".$opus."</td><td>".$instrument."</td></tr>\n";
}
close(CACHE);
return $html;
}
sub HEAD($) {
# returns nice index, to go at top of document. Puts main body
# of document in a table. Must be used with TAIL.
my $dontlinkto = shift;
my $html = <<____EOH; $html =~ s/^ *//gm; # trim leading whitespace
<div class="header_section">
<table class="invisible"><tr>
<td><img src="images/logo-small.png" alt="Mutopia Project Logo" width="186" height="61" /></td>
<td style="font-weight: bold;">All music in the Mutopia Project is free to download, print out, perform and distribute.<br />
[[ NUMBER_OF_PIECES() ]]
pieces of music are now available.</td>
<td>
Save our bandwidth - use a mirror!<br />
<!--<a href="http://www.ibiblio.org/mutopia/" title="Mirror in the USA">USA</a> |-->
<a href="http://www.mutopiaproject.org/" title="Main site in Canada"><b>Canada</b></a> |
<!-- <a href="http://mutopia.planetmirror.com/" title="Mirror in Australia">Australia</a> | -->
<!-- <a href="http://gd.tuwien.ac.at/art/Mutopia/" title="Mirror in Austria">Austria</a> | -->
<a href="http://eremita.di.uminho.pt/mutopia/" title="Mirror in Portugal">Portugal</a><!--<br />
<a href="ftp://ibiblio.org/pub/multimedia/mutopia/" title="FTP in USA">Mutopia Archive via FTP</a>-->
</td>
</tr>
<tr><td colspan="3" style="padding: 5px; border-top: 1px solid black;">
[[ INDEX("$dontlinkto") ]]
</td></tr></table>
[[ BREAK() ]]
____EOH
return $html;
}
sub HEAD_DE($) {
# returns nice index, to go at top of document. Puts main body
# of document in a table. Must be used with TAIL.
my $dontlinkto = shift;
my $html = <<____EOH; $html =~ s/^ *//gm; # trim leading whitespace
<table width="100%" border="0"><tr><td> </td></tr></table>
<table border="1" width="95%" cellpadding="10" cellspacing="0"
bgcolor="#edfaff" align="center" summary="Logo des Mutopia-Projektes
und Links zu Mirrorsites"><tr>
<td align="center"><img src="images/logo-small.png" alt="Logo des Mutopia-Projektes"
width="186" height="61" /></td>
<td align="center"><b>Die gesamte Musik aus dem Mutopia-Projekt kann frei
heruntergeladen, ausgedruckt, aufgeführt und weitergegeben werden. Bisher
sind <i>[[ NUMBER_OF_PIECES() ]]</i> Musikstücke vorhanden!</b></td>
<td align="center">
<table border="0" cellpadding="0" cellspacing="2">
<tr><td align="center"><a href="http://www.MutopiaProject.org/">http://www.MutopiaProject.org/</a>
</td><td align="center"><a href="http://www.MutopiaProject.org/"><img src="images/can.png" width="32" height="16" border="0" alt="Use server in Canada" /></a></td></tr>
<tr><td align="center"><a href="http://ibiblio.org/mutopia/">http://ibiblio.org/mutopia/</a>
</td><td align="center"><a href="http://ibiblio.org/mutopia/"><img src="images/usa.png" width="32" height="17" border="0" alt="Use server in the USA" /></a></td></tr>
<tr><td align="center"><a href="http://mutopia-gd.tuwien.ac.at/">http://mutopia-gd.tuwien.ac.at/</a>
</td><td align="center"><a href="http://mutopia-gd.tuwien.ac.at/"><img src="images/eu.png" width="32" height="21" border="0" alt="Use server in the EU" /></a></td></tr>
<tr><td align="center"><a href="http://mutopia.planetmirror.com/">http://mutopia.planetmirror.com/</a>
</td><td align="center"><a href="http://mutopia.planetmirror.com/"><img src="images/aus.png" width="32" height="16" border="0" alt="Use server in Australia" /></a></td></tr></table>
</td>
</tr>
<tr><td colspan="3" align="center">
[[ INDEX_DE("$dontlinkto") ]]
[[ BREAK() ]]
____EOH
return $html;
}
sub INDEXHEAD {
# I thought I'd stick this in here rather than in index.html-in as
# we might want to put it differently in the CD version. Possibly.
# I don't know - feel free to move it back!
my $html = <<____EOH; $html =~ s/^ *//gm; # trim leading whitespace
<div class="index_rhs_cont">
<div class="index_rhs">
<form action="cgibin/make-table.cgi" method="get">
<p style="text-align: center;">
<input type="text" name="searchingfor" size="20" />
<input type="submit" value="Search" />
</p>
</form>
<p><b>Browse by composer:</b> <a href="cgibin/make-table.cgi?Composer=BachJS">Bach</a>, <a href="cgibin/make-table.cgi?Composer=BeethovenLv">Beethoven</a>, <a href="cgibin/make-table.cgi?Composer=ChopinFF">Chopin</a>, <a href="cgibin/make-table.cgi?Composer=DiabelliA">Diabelli</a>, <a href="cgibin/make-table.cgi?Composer=HandelGF">Handel</a>, <a href="cgibin/make-table.cgi?Composer=MozartWA">Mozart</a>, <a href="cgibin/make-table.cgi?Composer=SchumannR">Schumann</a>, <a href="cgibin/make-table.cgi?Composer=SorF">Sor</a>. <a href="browse.html#byComposer">[Full list of composers]</a></p>
<p><b>Browse by instrument:</b> <a href="cgibin/make-table.cgi?Instrument=Piano">Piano</a>, <a href="cgibin/make-table.cgi?Instrument=Voice">Vocal</a>, <a href="cgibin/make-table.cgi?Instrument=Organ">Organ</a>, <a href="cgibin/make-table.cgi?Instrument=Violin">Violin</a>, <a href="cgibin/make-table.cgi?Instrument=Guitar">Guitar</a>, <a href="cgibin/make-table.cgi?Instrument=Orchestra">Orchestra</a>. <a href="browse.html#byInstrument">[Full list of instruments]</a></p>
<p style="text-align: center;"><b><a href="piece-list.html">List all music</a></b></p>
</div>
<div class="index_rhs">
<h4 style="text-align: center;">Latest additions [<a href="latestadditions.html">More...</a>]</h4>
<p>
[[ LATEST_ADDITIONS(8) ]]
</p>
</div>
</div>
____EOH
return $html;
}
sub INDEXHEAD_DE {
my $html = <<____EOH; $html =~ s/^ *//gm; # trim leading whitespace
<p align="center"><b>Latest additions</b> (<a href="latestadditions.html">
more...</a>)</p>
<p>
[[ LATEST_ADDITIONS(6) ]]
</p>
</td>
<td align="center">
<form action="cgibin/make-table.cgi" method="get">
<input type="text" name="searchingfor" size="30" />
<input type="submit" value="Search" />
</form>
<p><a href="piece-list.de.html">Alle Stücke anzeigen </a></p>
<p>Alternatively try an <a href="advsearch.de.html">advanced search</a>,<br />
or browse by... <a href="browse.de.html#byComposer">Composer</a>,
<a href="browse.de.html#byInstrument">Instrument</a><br />
or <a href="browse.de.html#byStyle">Musical Style</a></p>
<!--<p><a href="http://www.cs.helsinki.fi/group/cbrahms/demoengine/">Search by melody with C-Brahms melody-based search</a></p>-->
[[ BREAK() ]]
____EOH
return $html;
}
sub BREAK {
# When using HEAD and TAIL, use BREAK to start a new table.
my $html = <<____EOH; $html =~ s/^ *//gm; # trim leading whitespace
</div>
<div class="main_section">
____EOH
return $html;
}
sub TAIL($) {
# returns index and disclaimer for bottom of document. Puts
# main body of document in a "window". Must be used with HEAD.
my $dontlinkto = shift;
my $html = <<____EOH; $html =~ s/^ *//gm; # trim leading whitespace
[[ BREAK() ]]
<p class="link_list">
[[ INDEX("$dontlinkto") ]]
</p>
<p class="disclaimer">Disclaimer: The Mutopia
Project is run by volunteers, and the material within it is provided
"as-is". NO WARRANTY of any kind is made, including fitness
for any particular purpose.<br />No claim is made as to the accuracy or the
factual, editorial or musical correctness of any of the material
provided here.</p>
</div>
____EOH
return $html;
}
sub TAIL_DE($) {
# returns index and disclaimer for bottom of document. Puts
# main body of document in a "window". Must be used with HEAD.
my $dontlinkto = shift;
my $html = <<____EOH; $html =~ s/^ *//gm; # trim leading whitespace
[[ BREAK() ]]
<!-- XXX Valid XHTML button -->
<p align="center">
[[ INDEX_DE("$dontlinkto") ]]
</p>
<p><font size="-1em"><b>Disclaimer: The Mutopia
Project is run by volunteers, and the material within it is provided
"as-is". NO WARRANTY of any kind is made, including fitness
for any particular purpose. No claim is made as to the accuracy or the
factual, editorial or musical correctness of any of the material
provided here.</b></font></p>
</td></tr></table>
<!-- Spacer table -->
<table width="100%" border="0"><tr><td> </td></tr></table>
____EOH
return $html;
}
sub INDEX($) {
my $dontlinkto = shift;
my $html = "";
my $currpage = 0;
my @pages = ("index", "Home",
"browse", "Browse the Archive",
"advsearch", "Advanced Search",
"legal", "License Details",
"contribute", "How to Contribute",
"projects", "In Progress",
"contact", "Contact and Discussion");
# We don't want the current page to be made a link
for($currpage = 0; $currpage < (@pages); $currpage += 2) {
if ($pages[$currpage] eq $dontlinkto) {
$html = $html . $pages[$currpage+1];
} else {
$html = $html . "<a href=\"" . $pages[$currpage] . ".html\">" .
$pages[$currpage+1] . "</a>";
}
# The last link on the line doesn't want a "|" after it; the rest do
if ($currpage != (@pages) - 2) { $html = $html . " |\n" }
else { $html = $html . "\n" }
}
return $html;
}
sub INDEX_DE($) {
my $dontlinkto = shift;
my $html = "";
my $currpage = 0;
my @pages = ("index", "Startseite",
"browse", "Archiv durchblättern",
"advsearch", "Erweiterte Suche",
"help", "Hilfe",
"legal", "Rechtliche Angelegenheiten",
"contribute", "Etwas beitragen",
"newsletters", "Newsletter",
"projects", "In Arbeit");
# We don't want the current page to be made a link
for($currpage = 0; $currpage < (@pages); $currpage += 2) {
if ($pages[$currpage] eq $dontlinkto) {
$html = $html . $pages[$currpage+1];
} else {
$html = $html . "<a href=\"" . $pages[$currpage] . ".de.html\">" .
$pages[$currpage+1] . "</a>";
}
# The last link on the line doesn't want a "|" after it; the rest do
if ($currpage != (@pages) - 2) { $html = $html . " |\n" }
else { $html = $html . "\n" }
}
return $html;
};
1;