From: Steinar H. Gunderson Date: Thu, 7 Apr 2005 14:28:06 +0000 (+0000) Subject: Add a (hidden) script for showing song ratings. X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=74d491c65da42e950c25ac21b85f211ef56735c6 Add a (hidden) script for showing song ratings. --- diff --git a/html/songratings.pl b/html/songratings.pl new file mode 100755 index 0000000..c8be12d --- /dev/null +++ b/html/songratings.pl @@ -0,0 +1,34 @@ +#! /usr/bin/perl + +use ccbs; +use strict; +use warnings; + +my $cgi = new CGI; +my $machine = $cgi->param('machine'); + +my $dbh = ccbs::db_connect(); + +my $songs_raw = ccbs::db_fetch_all($dbh, 'SELECT song,title,playmode,difficulty,feetrating FROM songratings NATURAL JOIN songs WHERE machine=? ORDER BY machine,song', $machine); + +my @songs = (); + +my $last_song = -1; +my $show_challenge = 0; +for my $song (@$songs_raw) { + if ($song->{'song'} != $last_song) { + push @songs, { song => $song->{'song'}, title => $song->{'title'} }; + } + + my $key = $song->{'playmode'} . '_' . $song->{'difficulty'}; + $songs[$#songs]->{$key} = $song->{'feetrating'}; + $last_song = $song->{'song'}; + + $show_challenge = 1 if ($song->{'difficulty'} eq 'challenge'); +} + +ccbs::print_header(); +ccbs::process_template('songratings.tmpl', 'Sanger', { + songs => \@songs, +}); +$dbh->disconnect; diff --git a/html/templates/songratings.tmpl b/html/templates/songratings.tmpl new file mode 100644 index 0000000..5297c71 --- /dev/null +++ b/html/templates/songratings.tmpl @@ -0,0 +1,50 @@ +[%# vim:set filetype=html: %] + +
+ + + +[% IF show_challenge %] + + +[% ELSE %] + + +[% END %] + + + + + + + +[% IF show_challenge %] + +[% END %] + + + +[% IF show_challenge %] + +[% END %] + +[% FOR s = songs %] + + + + + + +[% IF show_challenge %] + +[% END %] + + + +[% IF show_challenge %] + +[% END %] + +[% END %] +
SingleDoubleSingleDouble
SangBSDECSDEC
[% s.title %][% s.single_beginner %][% s.single_standard %][% s.single_difficult %][% s.single_expert %][% s.single_challenge %][% s.double_standard %][% s.double_difficult %][% s.double_expert %][% s.double_challenge %]
+