X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fwebchord.cgi;h=e657db8e290629bd3952c07e3d105798dc755afd;hb=4ae5216dbffc19a2acedd5ac6a24229140bf39a1;hp=47c5255815f2df996c84c32d1841ba22805ac927;hpb=14ad2485f77e44566ebc155fe6a8fac85dbc2c94;p=songbook.git
diff --git a/web/webchord.cgi b/web/webchord.cgi
index 47c5255..e657db8 100755
--- a/web/webchord.cgi
+++ b/web/webchord.cgi
@@ -12,7 +12,6 @@
# 2003-08-03 Version 1.1 Uses stylesheets
# 2014-02-05 Added things particular to my implementation of Songbook at
# http://defaria.com/songbook
-
use strict;
use warnings;
@@ -20,14 +19,14 @@ use CGI qw(:standard);
use CGI::Carp qw (fatalsToBrowser);
use File::Basename;
-my ($chopro, $output, $i);
+my ($chopro, $i);
my $documentRoot = "/web";
my $debug = param ('debug');
my $infile = param ('chordpro');
unless (-f $infile) {
- $infile = '/opt/songbook/Songs/' . $infile;
+ $infile = '/opt/songbook/Andrew/' . $infile;
unless (-f $infile) {
$infile = '/web/xmas/' . param ('chordpro');
@@ -41,90 +40,83 @@ unless (-f $infile) {
sub debug ($) {
my ($msg) = @_;
-
+
return unless $debug;
-
+
print "Debug: $msg
";
-
+
return;
} # debug
-sub warning ($) {
+sub warning ($) {
my ($msg) = @_;
debug "warning";
print "Warning $msg
";
- return;
+ return;
} # warning
sub error {
my ($msg) = @_;
-
+
print "
\n$msg\n
" . ""; - + exit; } # error +sub getTitle ($) { + my ($song) = @_; + + return fileparse ($song, qr/\.pro/); +} # getTitle + sub musicFileExists ($) { my ($song) = @_; debug "ENTER musicFileExists ($song)"; - - my $title = fileparse ($song, qr/\.pro/); - my $musicfile = "/opt/songbook/Media/$title.mp3"; - - if (-r $musicfile) { - debug "Exists!"; - - return $title; - } else { - debug "Could not find $musicfile"; - - return undef; - } # if + + my $title = getTitle ($song); + my $musicfile = "/opt/media/$title.mp3"; + + return -r $musicfile; } # musicFileExists sub updateMusicpath ($$) { my ($chopro, $song) = @_; - my $title = musicFileExists $song; - # If there's no corresponding music file then do nothing - return unless $title; - + return unless musicFileExists $song; + # If the .pro file already has musicpath then do nothing - if ($chopro =~ /\{musicpath:.*\}/) { - debug "$song already has musicpath"; - } # if - return if $chopro =~ /\{musicpath:.*\}/; # Otherwise append the musicpath my $songfile; - + open $songfile, '>>', $song or undef $songfile; - + unless (defined $songfile) { my $msg = "Unable to open $song for append - $!