X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/0ec4d83edf83be1754f258090723d19ae1955086..d9ec472869a2c33c469cad90a21b221f14f29af3:/word.plp diff --git a/word.plp b/word.plp index ca85070..41d2bd3 100644 --- a/word.plp +++ b/word.plp @@ -1,6 +1,20 @@ <(common.inc.plp)><: -my $wordlist = 'wordlist.eng.inc.pl'; +our $lang = $get{lang} || 'en'; +our $wordlistbase = "data/wordlist.$lang"; + +if ($Request and $Request =~ m{\A([^/]+)}) { + my $page = "word/$1.plp"; + utf8::downgrade($page); # unicode filename breaks contents encoding + if (-e $page) { + Include $page; + exit; + } +} + +my $wordlist = "$wordlistbase.inc.pl"; +my $limit = $get{v} // (exists $get{v} ? 4 : 3); + Html({ title => 'words cheat sheet', version => '1.0', @@ -9,86 +23,66 @@ Html({ language '], data => [$wordlist], - raw => <<'EOT', + raw => (exists $get{q} && <<'EOT') +EOT + . <<'EOT', + EOT }); +if (exists $get{debug}) { + say ''; +} :>

Words

Under construction. Zie ook dieren. +Omit translations to test.

<: my $table = do $wordlist or die $@ // $!; sub showimg { - my ($name) = @_; - my ($img) = $name =~ /^([\w -]+)/; + my ($id, $name) = @_; + my ($imgname) = $name =~ m{^([^/]+)}; $name =~ s/\w{4} [^aoeuiyc\W] [rl]?+ \K (?= [^aoeuiy\W] [rl]? [aoeuiy] \w)/­/gx; - $name =~ s{/(.*)}{ ($1)}g; + ($name, my @morenames) = split m{/}, $name; + $name =~ s{\( ([^/]+) \)}{$1}x; + $name .= " ($_)" for @morenames; my $hidden = $name =~ s/\?$//; - my $alt = $name; $name = "$name" if $name =~ s/\?$//; + $name = "
$name
"; - if ($img and -e ($img = "data/word/eng/$img.jpg")) { - my $alt = -l $img && readlink($img) =~ s/\.jpg$//r; - if ($alt) { - $name .= " ($alt)"; - } - else { - $alt = $name; - } - $name = "
$name
"; - $name .= sprintf '%s', $img, $alt; - } - elsif ($hidden) { - $name = "
$name?
"; + if ($id and -e (my $img = "data/word/en/$id.jpg")) { + $name .= sprintf '%s', $img, $imgname; } return sprintf '%s', $hidden && !exists $get{v} && ' hidden', $name; } @@ -96,12 +90,39 @@ sub showimg { sub printimgs { say ''; } -printimgs(@{$table->{''}}); +say '';