From: Mischa POSLAWSKY Date: Sun, 24 May 2020 04:15:57 +0000 (+0200) Subject: word edit: copycat button to save and start a similar entry X-Git-Tag: v1.13~261 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/0413875f8fe365d37a245d337344970f33666efc word edit: copycat button to save and start a similar entry Option to retain language and category. --- diff --git a/writer.plp b/writer.plp index 59bacac..37424a8 100644 --- a/writer.plp +++ b/writer.plp @@ -51,10 +51,13 @@ my @wordcols = ( thumb => 'Convert options', wptitle => 'Wikipedia', ); -my $find = $Request ? {id => $Request} : undef; +my ($find) = map {{id => $_}} $fields{id} || $Request || (); my $row; -if ($ENV{REQUEST_METHOD} eq 'POST') { +if (exists $get{copy}) { + $row = {%fields{ qw(lang cat) }}; +} +elsif ($ENV{REQUEST_METHOD} eq 'POST') { $row = {%post{ pairkeys @wordcols }}; $_ = length ? $_ : undef for values %{$row}; eval { @@ -90,19 +93,18 @@ if ($ENV{REQUEST_METHOD} eq 'POST') { "Failed to convert source image, error code ".($status >> 8), ], "@cmds"); } - - $row = {map {$_ => $row->{$_}} qw(lang cat)} if not $Request; } elsif ($find) { $row = $db->select(word => '*', $find)->hash or Abort("Word not found", 404); } -my $title = $row ? "entry #$row->{id}" : 'new entry'; +my $title = $row->{id} ? "entry #$row->{id}" : 'new entry'; :>

Words <:= $title :>

-
+ +
<: @@ -111,7 +113,7 @@ for my $col (pairs @wordcols) { $val = '{'.join(',', map {s/,/\\,/gr} @{$val}).'}' if ref $val eq 'ARRAY'; printf '
' . '
', - $col->key, $col->value, $val; + $col->key, $col->value, Entity($val); -e and printf ' %s', $_, $row->{form} for $col->key eq 'source' ? "data/word/org/$row->{id}.jpg" : $col->key eq 'thumb' ? "data/word/eng/$row->{form}.jpg" : @@ -120,5 +122,8 @@ for my $col (pairs @wordcols) { } :>
-

+

+ + +