blob: 8933109f983534f67f0f4d0c46abfb6086884bf2 (
plain)
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
|
require "json"
def shelf_contents(data, filter)
$cgi.div {
data.select { |bottle|
bottle["status"] == filter
}.map { |bottle|
$cgi.div(class: "bottle") {
$cgi.h4 { bottle["name"] } +
$cgi.a(href: "shelf/#{bottle["image"]}") {
$cgi.img(class: "bottle",
src: "shelf/#{bottle["image"]}")
}
}
}.join
}
end
data = JSON.parse(File.read("../inc/shelf.json"))
$page =
$cgi.h2 { "What's on my shelf?" } +
$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:
|