From c08f6520ece85c4238d6484237ebe9d1fa0adae8 Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 4 Dec 2023 23:39:38 +0100 Subject: [PATCH] termcol: export gimp palette on .gpl requests --- termcol.plp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/termcol.plp b/termcol.plp index 5f89c3f..f76e293 100644 --- a/termcol.plp +++ b/termcol.plp @@ -1,5 +1,24 @@ <(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.4', -- 2.30.0