X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/73ee5a0c42f98006d42b04d5cc1635e25729373c..HEAD:/termcol.plp diff --git a/termcol.plp b/termcol.plp index 8e61fe0..f76e293 100644 --- a/termcol.plp +++ b/termcol.plp @@ -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 "\n";