Add a backend for showing songs and the best scores on them.
authorSteinar H. Gunderson <sesse@samfundet.no>
Fri, 18 Feb 2005 13:35:19 +0000 (13:35 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Fri, 18 Feb 2005 13:35:19 +0000 (13:35 +0000)
html/song.pl [new file with mode: 0755]
html/templates/song.tmpl [new file with mode: 0644]

diff --git a/html/song.pl b/html/song.pl
new file mode 100755 (executable)
index 0000000..1b1be39
--- /dev/null
@@ -0,0 +1,20 @@
+#! /usr/bin/perl
+
+use ccbs;
+use strict;
+use warnings;
+
+my $cgi = new CGI;
+my $id = $cgi->param('id');
+
+my $dbh = ccbs::db_connect();
+
+my $song = $dbh->selectrow_hashref('SELECT * FROM songs WHERE song=?', undef, $id);
+my $scores = ccbs::db_fetch_all($dbh, 'SELECT * FROM scores NATURAL JOIN players NATURAL JOIN tournaments WHERE song=? ORDER BY score DESC', $id);
+
+ccbs::print_header();
+ccbs::process_template('song.tmpl', $song->{'title'}, {
+       song => $song,
+       scores => $scores
+});
+$dbh->disconnect;
diff --git a/html/templates/song.tmpl b/html/templates/song.tmpl
new file mode 100644 (file)
index 0000000..5de46c0
--- /dev/null
@@ -0,0 +1,30 @@
+[%# vim:set filetype=html: %]
+  <h2>Generelle fakta</h2>
+
+  <div>
+    <ul>
+      <li>Tittel: [% song.title %]</li>
+      <li>Artist: [% song.artist %]</li>
+      <li>Tempo: [% song.minbpm %]-[% song.maxbpm %] bpm</li>
+    </ul>
+  </div>
+
+  <h2>Beste scores</h2>
+
+  <div>
+    <table>
+      <tr>
+        <th>Spiller</th>
+        <th>Poengsum</th>
+        <th>Arrangement</th>
+      </tr>
+      
+[% FOR s = scores %]
+      <tr>
+        <td>[% s.nick %]</td>
+        <td>[% s.score %]</td>
+        <td>[% s.tournamentname %]</td>
+      </tr>
+[% END %]
+    </table>
+  </div>