3 our $lang = $get{lang} || 'en';
4 our $wordlistbase = "data/wordlist";
6 if ($Request and $Request =~ m{\A([^/]+)}) {
8 my $page = "word/$name.plp";
9 $wordlistbase .= ".$lang";
11 utf8::downgrade($page); # unicode filename breaks contents encoding
16 raw => join("\n", map qq(<script src="/word/$_"></script>),
17 'put.min.js', 'quiz.js', "$name.js",
22 say '<section id="gallery"></section>';
23 say "<script>new Word\u$name('/$wordlistbase.json')</script>";
28 my $limit = $get{v} // (exists $get{v} ? 5 : 3);
31 title => 'words cheat sheet',
33 description => "Visual words",
37 data => ["$wordlistbase.inc.pl"],
38 raw => exists $get{q} ? <<'EOT' : undef,
41 grid-row: span 1 !important;
42 grid-column: span 1 !important;
45 /* keep hover position */
48 transform: translate(50%, 50%);
51 font-size: 0 !important;
53 .gallery figure:active > figcaption {
55 font-size: 175% !important;
61 if (exists $get{debug}) {
63 include 'word-debug.css';
71 Zie ook <a href="/dieren">dieren</a>.
72 <a href="?q">Omit translations</a> to test.
76 my $table = Data($wordlistbase);
80 my ($imgname) = $name =~ m{^([^/]+)};
81 $name =~ s/\w{4} [^aoeuiyc\W] [rl]?+ \K (?= [^aoeuiy\W] [rl]? [aoeuiy] \w)/­/gx;
82 ($name, my @morenames) = split m{/}, $name;
83 $name =~ s{\( ([^/]+) \)}{<small>$1</small>}x;
84 $name .= " <small>($_)</small>" for @morenames;
85 my $hidden = $name =~ s/\?$//;
86 $name = "<q>$name</q>" if $name =~ s/\?$//;
87 $name = "<figcaption>$name</figcaption>";
89 if ($id and -e (my $img = "data/word/32/$id.jpg")) {
90 $name .= sprintf '<img src="/%s" alt="%s" />', $img, $imgname;
92 return sprintf '<figure%s>%s</figure>', $hidden && !exists $get{v} && ' hidden', $name;
98 my ($id, $level, $title) = @{$row};
99 $id or die "empty reference"; # assertion to prevent loops
101 push @type, 'parent' if defined $table->{$id};
102 push @type, 'large' if $level =~ s/c$//;
103 push @type, 'level'.($level || 0);
104 printf '<li%s>', @type ? sprintf ' class="%s"', join ' ', @type : '';
105 print showimg($id, $title) if $level <= $limit;
106 printimgs(@{$_}) for $table->{$id} // ();
112 say '<section class="gallery">';
113 if (exists $get{q}) {
116 my @query = $Request;
118 push @rows, grep { $_->[1] <= $limit } @query;
119 $_ = $_->[0] for @query;
120 @query = map {$_ ? @{$_} : ()} @{$table}{@query};
124 @rows = map {ref ? @$_ : $_} values %{$table}; # flatten categories
126 @rows = sort { rand <=> .5 } @rows;
130 elsif ($Request and $Request =~ /^\d+$/) {
131 printimgs([$Request]);
134 printimgs($table->{''}->[0]);