Use fragments for music player to allow linking
[app-musicexpo.git] / lib / App / MusicExpo.pm
index 32c780623351a5fe41b06d43554bd2a5d68a1fd9..c38d2b7f7b22ff56e6e884ab94be428f233f76a4 100644 (file)
@@ -3,7 +3,7 @@ use v5.14;
 use strict;
 use warnings;
 
-our $VERSION = '0.004';
+our $VERSION = '0.005';
 
 use Audio::FLAC::Header qw//;
 use HTML::Template::Compiled qw//;
@@ -123,6 +123,8 @@ sub normalizer{
        "$_[0]|".(stat $_[0])[9]
 }
 
+sub make_fragment{ join '-', map { lc =~ y/a-z0-9/_/csr } @_ }
+
 sub run {
        if ($cache) {
                tie my %cache, 'DB_File', $cache, O_RDWR|O_CREAT, 0644;
@@ -159,6 +161,7 @@ sub run {
                        }
                }
                delete $entry{$_} for qw/format file/;
+               $entry{fragment} = make_fragment @entry{qw/artist title/};
                push @files, \%entry
        }
 
@@ -180,7 +183,7 @@ $default_template = <<'HTML';
 <thead>
 <tr><th>Title<th>Artist<th>Album<th>Genre<th>Track<th>Year<th>Type
 <tbody><tmpl_loop files>
-<tr><td class="title"><tmpl_var title><td class="artist"><tmpl_var artist><td class="album"><tmpl_var album><td class="genre"><tmpl_var genre><td class="track"><tmpl_var tracknumber>/<tmpl_var tracktotal><td class="year"><tmpl_var year><td class="formats"><tmpl_loop formats><a href="<tmpl_var ...prefix><tmpl_var ESCAPE=URL file>"><tmpl_var format></a> </tmpl_loop></tmpl_loop>
+<tr><td class="title"><a href="#<tmpl_var fragment>" data-hash="#<tmpl_var fragment>"><tmpl_var title></a><td class="artist"><tmpl_var artist><td class="album"><tmpl_var album><td class="genre"><tmpl_var genre><td class="track"><tmpl_var tracknumber>/<tmpl_var tracktotal><td class="year"><tmpl_var year><td class="formats"><tmpl_loop formats><a href="<tmpl_var ...prefix><tmpl_var ESCAPE=URL file>"><tmpl_var format></a> </tmpl_loop></tmpl_loop>
 </table>
 HTML
 
@@ -238,7 +241,7 @@ Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright (C) 2013-2014 by Marius Gavrilescu
+Copyright (C) 2013-2015 by Marius Gavrilescu
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself, either Perl version 5.14.2 or,
This page took 0.010524 seconds and 4 git commands to generate.