From: Marius Gavrilescu Date: Sat, 17 Aug 2013 20:57:49 +0000 (+0300) Subject: Move the default format inside App::MusicExpo X-Git-Tag: 0.002~9 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=75c564d81acda3f119514960b110f6628deca31e;p=app-musicexpo.git Move the default format inside App::MusicExpo --- diff --git a/MANIFEST b/MANIFEST index b627054..40b0c0a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -5,6 +5,5 @@ README t/App-MusicExpo.t lib/App/MusicExpo.pm musicexpo -index.tmpl empty.mp3 empty.flac diff --git a/index.tmpl b/index.tmpl deleted file mode 100644 index cc275ad..0000000 --- a/index.tmpl +++ /dev/null @@ -1,11 +0,0 @@ - -Music - - - - - - -
TitleArtistAlbumGenreTrackYearType -
/ -
diff --git a/lib/App/MusicExpo.pm b/lib/App/MusicExpo.pm index 1595f71..3194665 100644 --- a/lib/App/MusicExpo.pm +++ b/lib/App/MusicExpo.pm @@ -1,5 +1,6 @@ package App::MusicExpo 0.001; use v5.14; +use strict; use warnings; use Audio::FLAC::Header qw//; @@ -17,10 +18,12 @@ use Storable qw/thaw freeze/; ################################################## +my $default_template; + our $prefix='/music/'; our $cache='cache.db'; our $caching=1; -our $template='index.tmpl'; +our $template=''; GetOptions ( "template=s" => \$template, @@ -86,11 +89,25 @@ sub run { push @files, thaw mp3info $file if $file =~ /.mp3$/i; } - my $ht=HTML::Template::Compiled->new(filename => $template); + my $ht=HTML::Template::Compiled->new( $template eq '' ? (scalarref => \$default_template) : (filename => $template)); $ht->param(files=>[sort { $a->{title} cmp $b->{title} } @files]); print $ht->output; } +$default_template = <<'HTML'; + +Music + + + + + + +
TitleArtistAlbumGenreTrackYearType +
/ +
+HTML + 1; __END__ @@ -122,7 +139,7 @@ where the title is a download link. =item B<--template> I