aboutsummaryrefslogtreecommitdiff
path: root/cgi/whisky-shelf.cgi
diff options
context:
space:
mode:
Diffstat (limited to 'cgi/whisky-shelf.cgi')
-rw-r--r--cgi/whisky-shelf.cgi40
1 files changed, 21 insertions, 19 deletions
diff --git a/cgi/whisky-shelf.cgi b/cgi/whisky-shelf.cgi
index b27220b..7645ba6 100644
--- a/cgi/whisky-shelf.cgi
+++ b/cgi/whisky-shelf.cgi
@@ -1,30 +1,32 @@
require "json"
def shelf_contents(data, filter)
- data.select { |bottle|
- bottle["status"] == filter
- }.map { |bottle|
- $cgi.div(class: "bottle") {
- $cgi.h4 { bottle["name"] } +
- $cgi.img(class: "bottle",
- src: "shelf/#{bottle["image"]}")
- }
- }.join
+ $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.div {
- $cgi.h2 { "What's on my shelf?" } +
- $cgi.div {
- $cgi.h3 { "Open" } +
- shelf_contents(data, "open") +
- $cgi.h3 { "Unopened" } +
- shelf_contents(data, "new") +
- $cgi.h3 { "Finished" } +
- shelf_contents(data, "gone")
- }
+ $cgi.h2 { "What's on my shelf?" } +
+ $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: