#!/usr/bin/env lua local foods = require'foods' local qs = require'qs' local days = { "mon","tue","wed","thu","fri","sat","sun" } print"Content-type: text/html" print"" local prev_foods = {} local Q = {} if os.getenv'REQUEST_METHOD' == 'POST' then Q = qs.parse_qs(io.read()) local log = assert(io.open("/home/rebecca/pr/food/LOG", "a+")) log:write(os.date("%Y-%m-%dT%H:%M:%S")) for i=0,13 do local prev_food = assert(tonumber(Q[tostring(i)])) prev_foods[i] = prev_food log:write(" "..prev_food) end log:write("\n") log:close() else for i=0,13 do prev_foods[i] = 1 end end local counts = {} for i = 0,13 do counts[i] = (counts[i] or 0) + 1 end local start_day = tonumber(Q.start or 1) local function ok(fi, si) return true end local function sel(sel_ix) local opts = {} for food_ix,food in ipairs(foods) do if food_ix == prev_foods[sel_ix] then table.insert(opts, '' ) elseif ok(food_ix, sel_ix) then table.insert(opts, '' ) end end return '' end local function row(n) local d = 1+((n+start_day-1)%7) return '