diff options
author | Yorhel <git@yorhel.nl> | 2015-09-17 16:31:04 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2015-09-17 16:31:04 +0200 |
commit | a8ece1d324bbbbb675224af97cf5dcb15580d577 (patch) | |
tree | 72f7bd8a1d5536615130550e62ef0f671ac5aff7 /lib | |
parent | a16c4bbbbd97fecb7a02a535efce0fefb1424ca9 (diff) |
Rename jsonEncode/Decode to C-style naming
CamelCase is used for methods, C-style names for functions. I'm just
nitpicking now.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VNDB/Func.pm | 10 | ||||
-rw-r--r-- | lib/VNDB/Handler/Staff.pm | 4 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNEdit.pm | 12 |
3 files changed, 13 insertions, 13 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index dd3f292e..40af8e73 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -11,7 +11,7 @@ use VNDBUtil; our @EXPORT = (@VNDBUtil::EXPORT, qw| clearfloat cssicon tagscore mt minage fil_parse fil_serialize parenttags childtags charspoil imgpath imgurl fmtvote - jsonEncode jsonDecode script_json json_validate + json_encode json_decode script_json json_validate mtvoiced mtani mtvnlen mtrlstat mtvnlstat mtbloodt |); @@ -210,18 +210,18 @@ sub fmtvote { my $JSON = JSON::XS->new; $JSON->canonical(1); -sub jsonEncode ($) { +sub json_encode ($) { $JSON->encode(@_); } -sub jsonDecode ($) { +sub json_decode ($) { $JSON->decode(@_); } # Insert JSON-encoded data as script, arguments: id, object sub script_json { script id => $_[0], type => 'application/json'; - my $js = jsonEncode $_[1]; + my $js = json_encode $_[1]; $js =~ s/</\\u003C/g; # escape HTML tags like </script> and <!-- lit $js; end; @@ -236,7 +236,7 @@ sub script_json { # responsibility of the JS code to handle the interface with the user. sub json_validate { my($frm, $name, @fields) = @_; - my $data = eval { jsonDecode $frm->{$name} }; + my $data = eval { json_decode $frm->{$name} }; goto error if $@ || ref $data ne 'ARRAY'; my %known_fields = map +($_->{field},1), @fields; for my $i (0..$#$data) { diff --git a/lib/VNDB/Handler/Staff.pm b/lib/VNDB/Handler/Staff.pm index 2840442b..5496af11 100644 --- a/lib/VNDB/Handler/Staff.pm +++ b/lib/VNDB/Handler/Staff.pm @@ -189,7 +189,7 @@ sub edit { my %b4 = !$sid ? () : ( (map { $_ => $s->{$_} } qw|name original gender lang desc l_wp l_site l_twitter l_anidb ihid ilock|), primary => $s->{aid}, - aliases => jsonEncode [ + aliases => json_encode [ map +{ aid => $_->{id}, name => $_->{name}, orig => $_->{original} }, sort { $a->{name} cmp $b->{name} } @{$s->{aliases}} ], @@ -231,7 +231,7 @@ sub edit { $_->{aid} *= $old_aliases{$_->{aid}} ? 1 : 0 for (sort { $a->{name} cmp $b->{name} } @$aliases); } if(!$frm->{_err}) { - $frm->{aliases} = jsonEncode $aliases; + $frm->{aliases} = json_encode $aliases; $frm->{ihid} = $frm->{ihid} ?1:0; $frm->{ilock} = $frm->{ilock}?1:0; $frm->{aid} = $frm->{primary} if $sid; diff --git a/lib/VNDB/Handler/VNEdit.pm b/lib/VNDB/Handler/VNEdit.pm index e7350d16..1a607e73 100644 --- a/lib/VNDB/Handler/VNEdit.pm +++ b/lib/VNDB/Handler/VNEdit.pm @@ -89,11 +89,11 @@ sub edit { my %b4 = !$vid ? () : ( (map { $_ => $v->{$_} } qw|title original desc alias length l_wp l_encubed l_renai image img_nsfw ihid ilock|), - credits => jsonEncode [ + credits => json_encode [ map { my $c = $_; +{ map { $_ => $c->{$_} } qw|aid role note| } } sort { $a->{aid} <=> $b->{aid} || $a->{role} cmp $b->{role} } @{$v->{credits}} ], - seiyuu => jsonEncode [ + seiyuu => json_encode [ map { my $c = $_; +{ map { $_ => $c->{$_} } qw|aid cid note| } } sort { $a->{aid} <=> $b->{aid} || $a->{cid} <=> $b->{cid} } @{$v->{seiyuu}} ], @@ -134,8 +134,8 @@ sub edit { my (@credits, @seiyuu); if(!$nosubmit && !$frm->{_err}) { eval { # catch json decoding errors - my $raw_c = $frm->{credits} ? jsonDecode $frm->{credits} : []; - my $raw_s = $frm->{seiyuu} ? jsonDecode $frm->{seiyuu} : []; + my $raw_c = $frm->{credits} ? json_decode $frm->{credits} : []; + my $raw_s = $frm->{seiyuu} ? json_decode $frm->{seiyuu} : []; # ensure submitted alias IDs exist within database my @alist = map $_->{aid}, @$raw_c, @$raw_s; @@ -183,8 +183,8 @@ sub edit { $frm->{vnrelations} = join '|||', map $_->[0].','.$_->[1].','.($_->[2]?1:0).','.$_->[3], sort { $a->[1] <=> $b->[1]} @{$relations}; $frm->{img_nsfw} = $frm->{img_nsfw} ? 1 : 0; $frm->{screenshots} = join ' ', map sprintf('%d,%d,%d', $_->[0], $_->[1]?1:0, $_->[2]), sort { $a->[0] <=> $b->[0] } @$screenshots; - $frm->{credits} = jsonEncode \@credits; - $frm->{seiyuu} = jsonEncode \@seiyuu; + $frm->{credits} = json_encode \@credits; + $frm->{seiyuu} = json_encode \@seiyuu; # weed out duplicate aliases my %alias; |