From 75c564d81acda3f119514960b110f6628deca31e Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 17 Aug 2013 23:57:49 +0300 Subject: [PATCH] Move the default format inside App::MusicExpo --- MANIFEST | 1 - index.tmpl | 11 ----------- lib/App/MusicExpo.pm | 23 ++++++++++++++++++++--- musicexpo | 4 ++-- 4 files changed, 22 insertions(+), 17 deletions(-) delete mode 100644 index.tmpl 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