diff options
Diffstat (limited to 'cgi')
| -rw-r--r-- | cgi/whisky-shelf.cgi | 17 | 
1 files changed, 13 insertions, 4 deletions
| diff --git a/cgi/whisky-shelf.cgi b/cgi/whisky-shelf.cgi index 668be4b..b27220b 100644 --- a/cgi/whisky-shelf.cgi +++ b/cgi/whisky-shelf.cgi @@ -1,9 +1,11 @@  require "json" -def shelf_contents(data) -  data.map { |bottle| +def shelf_contents(data, filter) +  data.select { |bottle| +    bottle["status"] == filter +  }.map { |bottle|      $cgi.div(class: "bottle") {  -      $cgi.h3 { bottle["name"] } + +      $cgi.h4 { bottle["name"] } +        $cgi.img(class: "bottle",                 src: "shelf/#{bottle["image"]}")      } @@ -15,7 +17,14 @@ data = JSON.parse(File.read("../inc/shelf.json"))  $page =    $cgi.div {      $cgi.h2 { "What's on my shelf?" } + -    $cgi.div { shelf_contents(data) } +    $cgi.div {  +      $cgi.h3 { "Open" } + +      shelf_contents(data, "open") + +      $cgi.h3 { "Unopened" } + +      shelf_contents(data, "new") + +      $cgi.h3 { "Finished" } + +      shelf_contents(data, "gone") +    }    }  # vim: set filetype=ruby: | 
