From: Marius Gavrilescu Date: Sun, 1 Jun 2014 08:42:56 +0000 (+0300) Subject: Add JSON X-Git-Tag: 0.003002~7 X-Git-Url: http://git.ieval.ro/?p=app-musicexpo.git;a=commitdiff_plain;h=95267d4f67d75e452bdfe9f92260dd0a65a9b39e Add JSON --- diff --git a/lib/App/MusicExpo.pm b/lib/App/MusicExpo.pm index 60c5c08..32715ae 100644 --- a/lib/App/MusicExpo.pm +++ b/lib/App/MusicExpo.pm @@ -15,6 +15,7 @@ use DB_File qw//; use File::Basename qw/fileparse/; use Fcntl qw/O_RDWR O_CREAT/; use Getopt::Long; +use JSON; use Storable qw/thaw freeze/; ################################################## @@ -128,7 +129,10 @@ sub run { push @files, \%entry } - $ht->param(files=>[sort { $a->{title} cmp $b->{title} } @files], prefix => $prefix); + my $json = JSON->new->utf8->canonical->encode({files => \@files, prefix => $prefix}); + $json =~ s//>/g; + $ht->param(files=>[sort { $a->{title} cmp $b->{title} } @files], prefix => $prefix, json => $json); print $ht->output; } @@ -142,8 +146,10 @@ $default_template = <<'HTML'; TitleArtistAlbumGenreTrackYearType -/ +/ + + HTML 1; diff --git a/t/musicexpo-cache.t b/t/musicexpo-cache.t index 1f464ed..ac4afc4 100644 --- a/t/musicexpo-cache.t +++ b/t/musicexpo-cache.t @@ -32,8 +32,10 @@ is $out, <<'OUT', 'output is correct'; TitleArtistAlbumGenreTrackYearType -SilenceL'autre endroitElectro01/092005FLAC MP3 +CelluleSilenceL'autre endroitElectro01/092005FLAC MP3 + + OUT ok -e $file, 'cache exists'; diff --git a/t/musicexpo.t b/t/musicexpo.t index fcd4e69..919a59c 100644 --- a/t/musicexpo.t +++ b/t/musicexpo.t @@ -25,4 +25,6 @@ is $out, <<'OUT', 'output is correct'; TitleArtistAlbumGenreTrackYearType + + OUT