aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgi/whisky-shelf.cgi17
-rw-r--r--inc/shelf.json22
2 files changed, 24 insertions, 15 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:
diff --git a/inc/shelf.json b/inc/shelf.json
index 4a6491a..f5787d1 100644
--- a/inc/shelf.json
+++ b/inc/shelf.json
@@ -2,56 +2,56 @@
{
"name": "Elements of Islay Cask Edit",
"image": "eoicaskedit.jpg",
- "state": "open"
+ "status": "open"
},
{
"name": "Ardbeg Eureka",
"image": "ardbegeureka.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Lancaster Spirits 10 Month Old PX",
"image": "lancasterpx10mo.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Little Brown Dog Ardmore",
"image": "lbdardmore.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Ledaig Sinclair Series Rioja Cask",
"image": "ledaigrioja.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Lindores Exclusive Cask",
"image": "lindoresexclusive.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Raasay Dun Cana",
"image": "raasayduncana.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Springbank 10 Year Old",
"image": "springbank10.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Uncharted Whisky Higher Ground",
"image": "unchartedhg.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Wormtub 10 Year Old",
"image": "wormtub10.jpg",
- "state": "new"
+ "status": "new"
},
{
"name": "Drago Whiskey 5 Year Old",
"image": "drago5yo.jpg",
- "state": "new"
+ "status": "new"
}
]