diff options
Diffstat (limited to 'cgi/home.cgi')
-rw-r--r-- | cgi/home.cgi | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cgi/home.cgi b/cgi/home.cgi index 509d188..422f76e 100644 --- a/cgi/home.cgi +++ b/cgi/home.cgi @@ -6,21 +6,24 @@ def next_collection uri = URI("https://waste-api.york.gov.uk/api/Collections/GetBinCollectionDataForUprn/***REMOVED***") resp = JSON.parse(Net::HTTP.get(uri))["services"].select { |c| Time.parse(c["nextCollection"]) > Time.now }.sort { |a, b| Time.parse(a["nextCollection"]) <=> Time.parse(b["nextCollection"]) }[0] + cdate = Time.parse(resp["nextCollection"]) + days = ((cdate - Time.now) / (60*60*24)).floor + case resp["service"] when "REFUSE" - "REFUSE" + "Refuse" when "RECYCLING" - "<font color=\"green\">RECYCLING</font>" + "<font color=\"green\">Recycling</font>" when "GARDEN" - "<font color=\"brown\">GARDEN WASTE</font>" + "<font color=\"brown\">Garden Waste</font>" end + - " on #{resp["nextCollection"].split('T')[0]}" + " needs to go out in #{days} day#{?s if days > 1} for collection on #{cdate.strftime("%A")}." end $page = $cgi.div { $cgi.h1 { "Welcome!" } } + $cgi.div { - $cgi.h2 { "Next Bin Collection" } + + $cgi.h2 { "Our Next Bin Collection" } + $cgi.p { next_collection } } + $cgi.div { |