+++ /dev/null
-<!DOCTYPE html>
-<title>Music</title>
-<meta charset="utf-8">
-<link rel="stylesheet" href="/music.css">
-
-<table border>
-<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 path>"><tmpl_var title></a><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_var format></tmpl_loop>
-</table>
package App::MusicExpo 0.001;
use v5.14;
+use strict;
use warnings;
use Audio::FLAC::Header qw//;
##################################################
+my $default_template;
+
our $prefix='/music/';
our $cache='cache.db';
our $caching=1;
-our $template='index.tmpl';
+our $template='';
GetOptions (
"template=s" => \$template,
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';
+<!DOCTYPE html>
+<title>Music</title>
+<meta charset="utf-8">
+<link rel="stylesheet" href="/music.css">
+
+<table border>
+<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 path>"><tmpl_var title></a><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_var format></tmpl_loop>
+</table>
+HTML
+
1;
__END__
=item B<--template> I<template>
-Path to the HTML::Template::Compiled template used for generating the music table. Defaults to 'index.tmpl'.
+Path to the HTML::Template::Compiled template used for generating the music table. If '' (empty), uses the default format. Is empty by default.
=item B<--prefix> I<prefix>
=head1 SYNOPSIS
- # Creates a table with the songs a.mp3 and b.flac using the template 'index.tmpl' and caching the tags in the file 'cache.db'. The download links point to /music/a.mp3 and /music/b.mp3
+ # Creates a table with the songs a.mp3 and b.flac using the default template and caching the tags in the file 'cache.db'. The download links point to /music/a.mp3 and /music/b.mp3
musicexpo a.mp3 b.flac
# Disables caching, and the download links point to /download/a.flac, /download/b.flac, /download/c.flac
=item B<--template> I<template>
-Path to the HTML::Template::Compiled template used for generating the music table. Defaults to 'index.tmpl'.
+Path to the HTML::Template::Compiled template used for generating the music table. If '' (empty), uses the default format. Is empty by default.
=item B<--prefix> I<prefix>