word/memory: mirrored duplication of unpaired images
[sheet.git] / word.plp
index 41d2bd330aa80a5d78b2a81c3a9e08284900ffdd..f47c4f48ed167d63d4608d2d71c5e80e96dbae13 100644 (file)
--- a/word.plp
+++ b/word.plp
@@ -1,12 +1,13 @@
 <(common.inc.plp)><:
 
 our $lang = $get{lang} || 'en';
-our $wordlistbase = "data/wordlist.$lang";
+our $wordlistbase = "data/wordlist";
 
 if ($Request and $Request =~ m{\A([^/]+)}) {
        my $page = "word/$1.plp";
        utf8::downgrade($page); # unicode filename breaks contents encoding
        if (-e $page) {
+               $wordlistbase .= ".$lang";
                Include $page;
                exit;
        }
@@ -90,7 +91,7 @@ sub showimg {
 sub printimgs {
        say '<ul>';
        for my $row (@_) {
-               my ($id, $level, $title) = split /:/, $row, 3;
+               my ($id, $level, $title) = @{$row};
                $id or die "empty reference"; # assertion to prevent loops
                my @type;
                push @type, 'parent' if defined $table->{$id};
@@ -110,8 +111,8 @@ if (exists $get{q}) {
        if ($Request) {
                my @query = $Request;
                while (@query) {
-                       push @rows, grep { (split /:/)[1] <= $limit } @query;
-                       s/:.*// for @query;
+                       push @rows, grep { $_->[1] <= $limit } @query;
+                       $_ = $_->[0] for @query;
                        @query = map {$_ ? @{$_} : ()} @{$table}{@query};
                }
        }
@@ -122,7 +123,10 @@ if (exists $get{q}) {
        $table = {};
        printimgs(@rows);
 }
+elsif ($Request and $Request =~ /^\d+$/) {
+       printimgs([$Request]);
+}
 else {
-       printimgs($Request || $table->{''}->[0]);
+       printimgs($table->{''}->[0]);
 }
 say '</section>';