X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/ea5b27f93e87b819504b4cbcdf5aa7e47cff0175..f88a74c510e90c9c864d37bfaaf23fefa1a0fbdc:/word.plp
diff --git a/word.plp b/word.plp
index 493bde9..f47c4f4 100644
--- a/word.plp
+++ b/word.plp
@@ -1,7 +1,19 @@
<(common.inc.plp)><:
-my $lang = $get{lang} || 'en';
-my $wordlist = "data/wordlist.$lang.inc.pl";
+our $lang = $get{lang} || 'en';
+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;
+ }
+}
+
+my $wordlist = "$wordlistbase.inc.pl";
my $limit = $get{v} // (exists $get{v} ? 4 : 3);
Html({
@@ -79,7 +91,8 @@ sub showimg {
sub printimgs {
say '
';
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};
push @type, 'large' if $level =~ s/c$//;
@@ -98,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};
}
}
@@ -110,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 '';