~aleteoryx/bundlemania

ref: 2a09b9a3e081e43c7aedbb2692ae65df9da82305 bundlemania/s/table -rwxr-xr-x 1.3 KiB
2a09b9a3Aleteoryx comment in s/pick 9 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/env tclsh

package require sqlite3

proc fatal {reason {code -1}} {
  puts stderr "$argv0: fatal: $reason"
  exit $code
}

proc usage {} {
  global argv0
  puts stderr "usage: $argv0 DB-PATH"
  exit -1
}
if {[llength $argv] != 1} usage
set dbpath [lindex $argv 0]

if {[catch {sqlite3 db $dbpath -create false}]} {
  fatal "can't open \"$dbpath\""
}

set unplayed [db eval {SELECT name,href,comment FROM titles WHERE played ISNULL AND ignore = 0}]
set played   [db eval {SELECT name,href,played,comment FROM titles WHERE played NOTNULL AND ignore = 0}]

puts "<!DOCTYPE html>"
puts "<html>"
puts "<head>"
puts "  <meta charset=utf-8 />"
puts "  <title>Game Stats</title>"
puts "</head>"
puts "<body>"

puts "  <h1>Unplayed Games</h1>"
puts "  <ul>"
foreach {name href comment} $unplayed {
  if {$comment == ""} {
    puts "    <li><a href=\"$href\">$name</a></li>"
  } else {
    puts "    <li><a href=\"$href\">$name</a><p>$comment</p></li>"
  }
}
puts "  </ul>"

puts "  <h1>Played Games</h1>"
puts "  <ul>"
foreach {name href played comment} $played {
  if {$comment == ""} {
    puts "    <li><a href=\"$href\">$name</a> - played <code>$played</code></li>"
  } else {
    puts "    <li><a href=\"$href\">$name</a> - played <code>$played</code><p>$comment</p></li>"
  }
}
puts "  </ul>"

puts "</body>"
puts "</html>"