File: make_index.pl

package info (click to toggle)
libgd-graph-perl 1.54~ds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 800 kB
  • sloc: perl: 5,097; makefile: 52; sh: 7
file content (62 lines) | stat: -rw-r--r-- 1,431 bytes parent folder | download | duplicates (3)
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
#!/usr/local/bin/perl -w
use strict;
use CGI qw/:standard *table/;

# Create an index file for all the samples.

my $EXT = shift || "png";

my %titles = (
    sample1 => 'Bar charts',
    sample2 => 'Area charts',
    sample3 => 'Points charts',
    sample4 => 'Lines and Points charts',
    sample5 => 'Lines charts',
    sample6 => 'Mixed charts',
    sample7 => 'Miscellaneous things',
    sample9 => 'Pie charts',
);

my %links;

foreach my $sgroup (sort keys %titles)
{
    open HTML, ">$sgroup.html" or die $!;

    print HTML start_html($titles{$sgroup}),
		h1($titles{$sgroup}), start_table();

    my @samples = map  { $_->[0] }
		  sort { $a->[1] <=> $b->[1] } 
		  map  { s/\.pl$//; [$_, /${sgroup}(\d+)/] } glob "${sgroup}[1-9].pl";

    foreach my $sample (@samples)
    {
	my @images = reverse sort  glob "${sample}*.$EXT";
	warn ("No $EXT sample images found for $sample.pl") unless @images;
	foreach my $img (@images)
	{
	    if (-f $img)
	    {
		print HTML Tr(
		    td(a({href => "$sample.pl"},"$sample.pl")),
		    td(img({src => "$img", border => 0}))
		    );
	    } else {
		    warn("$img error: $!");
	    }
	}
    }

    print HTML end_table(), end_html();
}

open(HTML, ">index.html") or die $!;
print HTML start_html('GD::Graph examples'),
    h1('GD::Graph examples');
foreach my $sgroup (sort keys %titles)
{
    print HTML p(a({href => "$sgroup.html"}, $titles{$sgroup}) );
}
print HTML end_html();