X-Git-Url: https://defaria.com/gitweb/?a=blobdiff_plain;f=web%2Fwebchord.cgi;h=e657db8e290629bd3952c07e3d105798dc755afd;hb=6f95d8724d498f936cbba64f96bf565c04fd0cc5;hp=a64b4c1531c1cc927acbd5c697fb3d74d989287c;hpb=4b532d27ad4ad7d71bb190f7974b3129ee114b22;p=songbook.git diff --git a/web/webchord.cgi b/web/webchord.cgi index a64b4c1..e657db8 100755 --- a/web/webchord.cgi +++ b/web/webchord.cgi @@ -19,7 +19,7 @@ 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'); @@ -68,38 +68,30 @@ sub error { 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 $title = getTitle ($song); my $musicfile = "/opt/media/$title.mp3"; - if (-r $musicfile) { - debug "Exists!"; - - return $title; - } else { - debug "Could not find $musicfile"; - - return undef; - } # if + 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 @@ -118,6 +110,7 @@ sub updateMusicpath ($$) { } # unless my $songbase = '/sdcard'; + my $title = getTitle $song; print $songfile "{musicpath:$songbase/SongBook/Media/$title.mp3}\n"; @@ -144,8 +137,8 @@ sub chopro2html ($$) { if (($chopro =~ /^{subtitle:(.*)}/mi) || ($chopro =~ /^{st:(.*)}/mi)) { $artist = $1; } # if - - print < $title @@ -158,24 +151,29 @@ sub chopro2html ($$) { END - $title = musicFileExists $song; + $title = getTitle $song; if ($title) { updateMusicpath $chopro, $song; } # if + my $titleLink = "$title"; print << "END"; - @@ -238,8 +236,7 @@ END } else { print "
Home
$title
+
$titleLink
+
+

Mark A: + not set + Mark B: + not set

"; print "\n"; - my($i); - for($i = 0; $i < @chords; $i++) { + for(my $i = 0; $i < @chords; $i++) { print ""; } print "\n\n"; @@ -250,7 +247,7 @@ END } # if } # if } # while - + print ""; } # chordpro2html
$chords[$i]