From 95267d4f67d75e452bdfe9f92260dd0a65a9b39e Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sun, 1 Jun 2014 11:42:56 +0300 Subject: [PATCH] Add JSON --- lib/App/MusicExpo.pm | 10 ++++++++-- t/musicexpo-cache.t | 4 +++- t/musicexpo.t | 2 ++ 3 files changed, 13 insertions(+), 3 deletions(-) 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 -- 2.39.2