diff options
author | Nat Lasseter <user@4574.co.uk> | 2025-03-31 14:10:14 +0100 |
---|---|---|
committer | Nat Lasseter <user@4574.co.uk> | 2025-03-31 14:10:14 +0100 |
commit | 0006b2b65be99283cb7c8a8d3fbe9fcb8b7b3e2d (patch) | |
tree | 0627a40e1e286a97fa26d3d30e67ba58cd77e20a | |
parent | 5f233a800153be1cc498036dd8ffcff2481063e6 (diff) |
[Bracket API] complete api
-rw-r--r-- | cgi/bracket-api.cgi | 71 | ||||
-rwxr-xr-x | cgi/user.cgi | 3 |
2 files changed, 39 insertions, 35 deletions
diff --git a/cgi/bracket-api.cgi b/cgi/bracket-api.cgi index 6332301..d174b27 100644 --- a/cgi/bracket-api.cgi +++ b/cgi/bracket-api.cgi @@ -3,39 +3,44 @@ require 'json' puzzles = [ { "completionText" => "31st March 1998:", - "puzzleDate" => "2025-03-30", - "completionURL" => "https://en.wikipedia.org/wiki/Mozilla", - "solutions" => { - "Olive or grape plant, maybe" => "vine", - "Castrated male bovine" => "Bullock", - "1995 Sandra Bullock movie \"The ___\"": "Net", - "\"___ old fox\"" => "sly", - "Water meadows" => "ings", - "Mean" => "Par", - "Parents or siblings, for short" => "fam", - "Owls are famously this" => "Wise", - "Shrink" => "contract", - "Euclid's mathematical treatise" => "elements", - "\"No ____s!\": Wise words for superheroes" => "cape", - "________ table of the elements" => "periodic", - "A timed contract with a periodic payment" => "lease", - "Image made from smaller pieces" => "Mosaic", - "The Mosaic Killer" => "Mozilla", - "The start" => "source", - "\"You make a better ____ than a window!\"" => "door", - "\"____ wide!\"" => "open", - "One might enter this to open a door" => "code", - "One of the five senses" => "taste", - "In favour of" => "pro", - "The taste of protons" => "sour", - "Strong curved structure" => "arch", - "Monarch" => "king", - "Timmy never actually fell down one of these" => "well", - "Blood sucking skin dwellers" => "lice" - }, - "initialPuzzle" => "[1995 Sandra [Castrated male bo[Olive or grape plant, maybe]] movie \"The ___\"]s[\"No ____s!\": [Owls are [[Mean]ents or sibl[Water meadows], for short]ou[\"___ old fox\"] this] words for superheroes] re[A timed [Shrink] with a [________ table of the [Euclid's mathematical treatise]] payment]s [The [Image made from smaller pieces] Killer] [The start] [One might enter this to open a [\"You make a better ____ than a window!\"]] under an [\"____ wide!\"] [The [One of the five senses] of [In favour of]tons]ce [Blood suc[Mon[Strong curved structure]] skin d[Timmy never actually fell down one of these]ers]nse.", - "puzzleSolution" => "Netscape releases Mozilla source code under an open source license." + "puzzleDate" => "2025-03-30", + "completionURL" => "https://en.wikipedia.org/wiki/Mozilla", + "solutions" => { + "Olive or grape plant, maybe" => "vine", + "Castrated male bovine" => "Bullock", + "1995 Sandra Bullock movie \"The ___\"": "Net", + "\"___ old fox\"" => "sly", + "Water meadows" => "ings", + "Mean" => "Par", + "Parents or siblings, for short" => "fam", + "Owls are famously this" => "Wise", + "Shrink" => "contract", + "Euclid's mathematical treatise" => "elements", + "\"No ____s!\": Wise words for superheroes" => "cape", + "________ table of the elements" => "periodic", + "A timed contract with a periodic payment" => "lease", + "Image made from smaller pieces" => "Mosaic", + "The Mosaic Killer" => "Mozilla", + "The start" => "source", + "\"You make a better ____ than a window!\"" => "door", + "\"____ wide!\"" => "open", + "One might enter this to open a door" => "code", + "One of the five senses" => "taste", + "In favour of" => "pro", + "The taste of protons" => "sour", + "Strong curved structure" => "arch", + "Monarch" => "king", + "Timmy never actually fell down one of these" => "well", + "Blood sucking skin dwellers" => "lice" + }, + "initialPuzzle" => "[1995 Sandra [Castrated male bo[Olive or grape plant, maybe]] movie \"The ___\"]s[\"No ____s!\": [Owls are [[Mean]ents or sibl[Water meadows], for short]ou[\"___ old fox\"] this] words for superheroes] re[A timed [Shrink] with a [________ table of the [Euclid's mathematical treatise]] payment]s [The [Image made from smaller pieces] Killer] [The start] [One might enter this to open a [\"You make a better ____ than a window!\"]] under an [\"____ wide!\"] [The [One of the five senses] of [In favour of]tons]ce [Blood suc[Mon[Strong curved structure]] skin d[Timmy never actually fell down one of these]ers]nse.", + "puzzleSolution" => "Netscape releases Mozilla source code under an open source license." } ] -$pdata = JSON.generate(puzzles) +path = $cgi.path_info.split(?/) +$pdata = if path.length == 3 + JSON.generate(puzzles.select { |puz| puz["puzzleDate"] == path[2] }) +else + JSON.generate(puzzles) +end diff --git a/cgi/user.cgi b/cgi/user.cgi index 27e8a24..535e580 100755 --- a/cgi/user.cgi +++ b/cgi/user.cgi @@ -93,6 +93,5 @@ when /^\/stuff-i-want/ page("Stuff I Want") when /^\/bracket-api/ load "bracket-api.cgi" - $cgi.out("text/plain") { "path_info: #{$cgi.path_info}" } - #$cgi.out("application/json") { $pdata } + $cgi.out("application/json") { $pdata } end |