word/edit: allow unnamed and/or untranslated entries
authorMischa POSLAWSKY <perl@shiar.org>
Mon, 25 Oct 2021 19:14:25 +0000 (21:14 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 9 Nov 2021 03:14:15 +0000 (04:14 +0100)
Alternative variants can be populated without textual distinction, for
example sexual dimorphism without specific terms, identified by category
override alone.

Probably still a good idea to describe eventually, but this is optional
metadata for visual presentations.

tools/word.pg.sql
word/edit.plp

index a142ebc6cab2215e16012ebccb52f4cbf33cb8d1..821814d1f18a828d983a479a137e9ef32173f905 100644 (file)
@@ -8,9 +8,9 @@ CREATE TABLE login (
 );
 
 CREATE TABLE word (
-       form       text        NOT NULL,
+       form       text,
        alt        text[],
-       lang       text        NOT NULL DEFAULT 'en',
+       lang       text                 DEFAULT 'en',
        cat        integer              REFERENCES word (id),
        ref        integer              REFERENCES word (id),
        prio       smallint             DEFAULT '1'
index f755f25752b76744373b4573147563c2c91214d4..5957b1a9b6a9541bb75b4a162d9190d3a5bf0c60 100644 (file)
@@ -72,6 +72,7 @@ my $user = eval {
 };
 
 my %lang = (
+       '' => ['(reference)'],
        nl => ["\N{REGIONAL INDICATOR SYMBOL LETTER N}\N{REGIONAL INDICATOR SYMBOL LETTER L}", 'nederlands'],
        en => ["\N{REGIONAL INDICATOR SYMBOL LETTER G}\N{REGIONAL INDICATOR SYMBOL LETTER B}", 'english'],
        eo => [qq'<span style="color:green">\N{BLACK STAR}</span>', 'esperanto'],
@@ -158,7 +159,7 @@ elsif (defined $post{form}) {{
        my $imagecol = $row->{image};  # backup image subcolumns
        ref $_ eq 'HASH' and $_ = encode_json($_) for values %{$row};
 
-       if (!$row->{form}) {
+       if (!$row->{form} and $row->{lang}) {
                if ($row->{ref} ne 'delete') {
                        Alert("Empty title",
                                "Confirm removal by setting <em>Reference</em> to <q>delete</q>."
@@ -223,7 +224,7 @@ elsif (defined $post{form}) {{
        }
 }}
 else {
-       $row->{lang} //= $user->{editlang}->[0];
+       $row->{lang} //= $user->{editlang}->[0] unless exists $row->{lang};
        $row->{$_} = $get{$_} for keys %get;
        $row->{prio} = defined $row->{ref} ? undef : 1 unless exists $row->{prio};
 }