M README => README +2 -0
@@ 20,3 20,5 @@ scripts:
generates an html file with game info
* pick.tcl DB-PATH
picks a random, unplayed, unignored game from the database
+* comment.tcl DB-PATH COMMENT GAMEURL ?GAMEURL ...?
+ sets the comment on GAMEURL to COMMENT
A => +35 -0
@@ 0,0 1,35 @@
#!/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 COMMENT GAME-URL ?GAME-URL ...?"
exit -1
}
if {[llength $argv] < 3} usage
set gameurls [lassign $argv dbpath comment]
if {[catch {sqlite3 db $dbpath -create false}]} {
fatal "can't open \"$dbpath\""
}
foreach url $gameurls {
if {![db exists {SELECT * FROM titles WHERE href = :url}]} {
puts stderr "game not in database: $url"
continue
}
db eval {
UPDATE titles SET comment = :comment
WHERE href = :url
}
}
M db/games.db => db/games.db +0 -0
M setup.tcl => setup.tcl +1 -1
@@ 23,7 23,7 @@ if {[catch {sqlite3 db $dbpath}]} {
}
db eval {
- CREATE TABLE titles(name TEXT NOT NULL, href TEXT NOT NULL PRIMARY KEY, played TEXT, ignore INT DEFAULT 0);
+ CREATE TABLE titles(name TEXT NOT NULL, href TEXT NOT NULL PRIMARY KEY, played TEXT, ignore INT NOT NULL DEFAULT 0, comment TEXT NOT NULL DEFAULT '');
CREATE INDEX titles_name ON titles(name);
CREATE INDEX titles_ignore ON titles(ignore);
}
M stats.tcl => stats.tcl +4 -1
@@ 34,11 34,14 @@ if {[llength $gameurls] == 0} {
continue
}
- lassign [db eval {SELECT name,played FROM titles WHERE href = :url}] name played
+ lassign [db eval {SELECT name,played,comment FROM titles WHERE href = :url}] name played comment
if {$played == ""} {
puts "$name: unplayed"
} else {
puts "$name: played $played"
}
+ if {$comment != ""} {
+ puts " comment: $comment"
+ }
}
}
M table.tcl => table.tcl +14 -6
@@ 19,8 19,8 @@ if {[catch {sqlite3 db $dbpath -create false}]} {
fatal "can't open \"$dbpath\""
}
-set unplayed [db eval {SELECT name,href FROM titles WHERE played ISNULL AND ignore = 0}]
-set played [db eval {SELECT name,href,played FROM titles WHERE played NOTNULL AND ignore = 0}]
+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>"
@@ 32,15 32,23 @@ puts "<body>"
puts " <h1>Unplayed Games</h1>"
puts " <ul>"
-foreach {name href} $unplayed {
- puts " <li><a href=\"$href\">$name</a></li>"
+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} $played {
- puts " <li><a href=\"$href\">$name</a> - played <code>$played</code></li>"
+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>"