X-Git-Url: http://git.shiar.net/sheet.git/blobdiff_plain/30bf0fcde3f7e44f1ec7bcfc8253dfce8f81e8e6..refs/tags/v1.19:/word.plp?ds=inline
diff --git a/word.plp b/word.plp
index 9fa1aaa..aedca9d 100644
--- a/word.plp
+++ b/word.plp
@@ -1,124 +1,27 @@
<(common.inc.plp)><:
-if ($Request and $Request =~ m{\A([^/]+)}) {
- my $page = "word/$1.plp";
- if (-e $page) {
- Include $page;
- exit;
- }
-}
-
-my $lang = $get{lang} || 'en';
-my $wordlist = "data/wordlist.$lang.inc.pl";
-my $limit = $get{v} // (exists $get{v} ? 4 : 3);
-
-Html({
- title => 'words cheat sheet',
- version => '1.0',
- description => "Visual words",
- keywords => [qw'
- language
- '],
- data => [$wordlist],
- 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 ($id, $name) = @_;
- my ($imgname) = $name =~ m{^([^/]+)};
- $name =~ s/\w{4} [^aoeuiyc\W] [rl]?+ \K (?= [^aoeuiy\W] [rl]? [aoeuiy] \w)//gx;
- ($name, my @morenames) = split m{/}, $name;
- $name =~ s{\( ([^/]+) \)}{$1}x;
- $name .= " ($_)" for @morenames;
- my $hidden = $name =~ s/\?$//;
- $name = "$name
" if $name =~ s/\?$//;
- $name = "$name";
-
- if ($id and -e (my $img = "data/word/en/$id.jpg")) {
- $name .= sprintf '
', $img, $imgname;
- }
- return sprintf '%s', $hidden && !exists $get{v} && ' hidden', $name;
-}
-
-sub printimgs {
- say '';
- for my $row (@_) {
- my ($id, $level, $title) = split /:/, $row, 3;
- my @type;
- push @type, 'parent' if defined $table->{$id};
- push @type, 'large' if $level =~ s/c$//;
- push @type, 'level'.($level || 0);
- printf '- ', @type ? sprintf ' class="%s"', join ' ', @type : '';
- print showimg($id, $title) if $level <= $limit;
- printimgs(@{$_}) for $table->{$id} // ();
- print '
';
- }
- say '
';
-}
-
-say '';
-if (exists $get{q}) {
- my @rows;
- if ($Request) {
- my @query = $Request;
- while (@query) {
- push @rows, grep { (split /:/)[1] <= $limit } @query;
- s/:.*// for @query;
- @query = map {$_ ? @{$_} : ()} @{$table}{@query};
- }
- }
- else {
- @rows = map {ref ? @$_ : $_} values %{$table}; # flatten categories
- }
- @rows = sort { rand <=> .5 } @rows;
- $table = {};
- printimgs(@rows);
+my ($name) = $Request ? $Request =~ m{\A(\w+)} : 'finder';
+if (-e (my $page = "word/$name.plp")) {
+ utf8::downgrade($page); # unicode filename breaks contents encoding
+ Include $page;
+}
+elsif (-e "word/$name.js") {
+ Html({
+ raw => join("\n",
+ (map {qq()}
+ 'put.min.js', 'quiz.js', "$name.js",
+ ),
+ (map {qq()}
+ grep {-e} "word/$name.css"
+ ),
+ ),
+ });
+ say 'Words
';
+ say '';
+ say "";
}
else {
- printimgs($Request || $table->{''}->[0]);
+ Html();
+ say 'Words
';
+ die ["Page $name
not found"];
}
-say '';