X-Git-Url: http://git.shiar.nl/sheet.git/blobdiff_plain/30bf0fcde3f7e44f1ec7bcfc8253dfce8f81e8e6..588ae20483b15e9accb6a14090f127ef87cbf4a5:/word/edit.plp diff --git a/word/edit.plp b/word/edit.plp index d8de602..8b9311c 100644 --- a/word/edit.plp +++ b/word/edit.plp @@ -1,6 +1,8 @@ <(../common.inc.plp)><: +my $editorurl = '/word/edit'; s{\Aedit(/|\z)}{} for $Request // (); + Html({ title => 'words cheat sheet admin', version => '1.0', @@ -21,7 +23,6 @@ my $db = eval { } or Abort('Database error', 501, $@); my $user = eval { - my $rootpath = '/word/edit'; if (defined $post{username}) { $cookie{login} = EncodeURI(join ':', @post{qw( username pass )}); } @@ -30,7 +31,7 @@ my $user = eval { if (AddCookie(CGI::Cookie->new( -name => 'login', -value => '', - -path => $rootpath, + -path => $editorurl, -expires => 'now', )->as_string)) { delete $cookie{login}; @@ -50,7 +51,7 @@ my $user = eval { my $httpcookie = CGI::Cookie->new( -name => 'login', -value => join(':', @{$found}{qw( username pass )}), - -path => $rootpath, + -path => $editorurl, ) or die "prepared object is empty\n"; AddCookie($httpcookie->as_string); } or Abort(["Unable to create login cookie", $@], 403); @@ -71,9 +72,10 @@ 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 => ['★', 'esperanto'], + eo => [qq'\N{BLACK STAR}', 'esperanto'], ru => ["\N{REGIONAL INDICATOR SYMBOL LETTER R}\N{REGIONAL INDICATOR SYMBOL LETTER U}", 'русский'], zh => ["\N{REGIONAL INDICATOR SYMBOL LETTER C}\N{REGIONAL INDICATOR SYMBOL LETTER N}", '中文'], la => ["\N{PUSHPIN}", 'latin'], @@ -88,7 +90,9 @@ my %wordcol = ( prio => [ {-label => 'Level', -select => sub { my ($row) = @_; - my @enum = qw[ essential basic common distinctive optional invisible ]; + my @enum = qw[ + essential ubiquitous basic common distinctive specialised rare invisible + ]; return { ('' => 'parent') x (defined $row->{ref}), map { $_ => $enum[$_] } 0 .. $#enum @@ -111,11 +115,12 @@ my %wordcol = ( ); if (my $search = $fields{q}) { - my %filter = (form => {ilike => '%'.$search.'%'}); + my %filter = $search eq '^' ? (cat => undef, ref => undef) : + (form => {ilike => '%'.parseinput($search).'%'}); my $results = $db->select(word => '*', \%filter); say '

Search

\n"; @@ -156,7 +161,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 Reference to delete." @@ -221,13 +226,13 @@ 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}; + $row->{prio} = defined $row->{ref} ? undef : 4 unless exists $row->{prio}; } eval { - my $imagerow = $row->{image} && decode_json(delete $row->{image}) || {}; + my $imagerow = $row->{image} && JSON->new->decode(delete $row->{image}) || {}; while (my ($col, $val) = each %{$imagerow}) { $row->{$col} = $val; } @@ -264,7 +269,7 @@ for my $col (@wordcols) { } if (not $row->{ref}) { - printf '
  • - +

    @@ -306,15 +311,15 @@ if ($row->{id}) { say '