index: release v1.18 with only altgr index linked
[sheet.git] / termcol.plp
index 8e61fe049516075e8df0b531cdadfe651ea708c7..f76e293a31e3dcfbf4173abcfe3efe352f138569 100644 (file)
@@ -1,8 +1,27 @@
 <(common.inc.plp)><:
 
+if (my ($name) = $Request =~ /(.+)\.gpl\z/) {
+       my $palettes = Data('termcol');
+       my $palette = $palettes->{$name}
+               or Abort("Palette '$name' not found", 404);
+       ref $palette ne 'ARRAY'
+               or Abort("Group contains multiple palettes: ".join(', ', @{$palette}));
+
+       $header{content_type} = 'text/x-gimp-gpl';
+       say 'GIMP Palette';
+       say 'Name: ', $palette->{name} // $name;
+       say 'Columns: 8';
+       say '#';
+       for (@{ $palette->{list} }) {
+               my ($rgb, $name) = split /:/, $_, 3;
+               say join ' ', unpack('C*', pack 'H6', $rgb), $name;
+       }
+       exit;
+}
+
 Html({
        title => ($Request ? 'terminal colour' : 'colour palettes') . ' cheat sheet',
-       version => '1.1',
+       version => '1.4',
        description => [!$Request ? "Comparison of various colour palettes." : (
                "Index of all terminal/console colour codes,",
                "with an example result of various environments.",
@@ -16,7 +35,7 @@ Html({
 });
 
 my @draw = map { [$_, s/\W+\z//] } grep { $_ } split m(/),
-       $get{img} // exists $get{img} && 'indi.png';
+       $get{img} // exists $get{img} && 'compile.png';
 
 my @termlist;
 push @termlist, split /\W+/, $Request || 'default';
@@ -44,8 +63,7 @@ use Shiar_Sheet::Colour 1.04;
 use List::Util qw( min max );
 use POSIX qw( ceil );
 
-my $palettes = do 'termcol.inc.pl';
-die "Cannot open palette data: $_\n" for $@ || $! || ();
+my $palettes = Data('termcol');
 
 sub colcell {
        my $name = shift // return "<td>\n";