use File::Basename qw/fileparse/;
use Fcntl qw/O_RDWR O_CREAT/;
use Getopt::Long;
+use JSON;
use Storable qw/thaw freeze/;
##################################################
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;
+ $json =~ s/>/>/g;
+ $ht->param(files=>[sort { $a->{title} cmp $b->{title} } @files], prefix => $prefix, json => $json);
print $ht->output;
}
<thead>
<tr><th>Title<th>Artist<th>Album<th>Genre<th>Track<th>Year<th>Type
<tbody><tmpl_loop files>
-<tr><td><a href=<tmpl_var title><td><tmpl_var artist><td><tmpl_var album><td><tmpl_var genre><td><tmpl_var tracknumber>/<tmpl_var tracktotal><td><tmpl_var year><td><tmpl_loop formats><a href="<tmpl_var ...prefix><tmpl_var ESCAPE=URL file>"><tmpl_var format></a> </tmpl_loop></tmpl_loop>
+<tr><td><tmpl_var title><td><tmpl_var artist><td><tmpl_var album><td><tmpl_var genre><td><tmpl_var tracknumber>/<tmpl_var tracktotal><td><tmpl_var year><td><tmpl_loop formats><a href="<tmpl_var ...prefix><tmpl_var ESCAPE=URL file>"><tmpl_var format></a> </tmpl_loop></tmpl_loop>
</table>
+
+<pre id="json" style="display: none"><tmpl_var ESCAPE=0 json></pre>
HTML
1;
<thead>
<tr><th>Title<th>Artist<th>Album<th>Genre<th>Track<th>Year<th>Type
<tbody>
-<tr><td><a href=Cellule<td>Silence<td>L'autre endroit<td>Electro<td>01/09<td>2005<td><a href="/music/empty.flac">FLAC</a> <a href="/music/empty.mp3">MP3</a>
+<tr><td>Cellule<td>Silence<td>L'autre endroit<td>Electro<td>01/09<td>2005<td><a href="/music/empty.flac">FLAC</a> <a href="/music/empty.mp3">MP3</a>
</table>
+
+<pre id="json" style="display: none">{"files":[{"album":"L'autre endroit","artist":"Silence","file":"empty.flac","format":"FLAC","formats":[{"file":"empty.flac","format":"FLAC"},{"file":"empty.mp3","format":"MP3"}],"genre":"Electro","title":"Cellule","tracknumber":"01","tracktotal":"09","year":"2005"}],"prefix":"/music/"}</pre>
OUT
ok -e $file, 'cache exists';