diff --git a/readme.md b/readme.md index ec4b760..2ea03f7 100644 --- a/readme.md +++ b/readme.md @@ -14,3 +14,5 @@ useful for development or proxyless deployments. - `log` stores the transaction log as CSV (`time,user,amount,comment`) - `products` stores the product list as CSV (`barcode,price,name`) +- `config` stores configuration parameters as ESV (`key=value`) + - `transaction_sound`: URL to sound played when creating a transaction diff --git a/strichliste.lua b/strichliste.lua index be31ed0..004d276 100755 --- a/strichliste.lua +++ b/strichliste.lua @@ -3,10 +3,12 @@ local function escape(s) return s:gsub("<", "<"):gsub("<", "<") end + local function urldecode(s) if s == nil then return nil end return s:gsub("+", " "):gsub("%%20", " ") end + local function urlencode(s) if s == nil then return nil end return s:gsub(" ", "%%20") @@ -90,7 +92,8 @@ local function respond(status, title, body)
]], escape(title), stylesheet, script, config.head_extra or "")) @@ -136,6 +139,7 @@ local function read_log() return tonumber(time), username, tonumber(amount), comment end end + local function read_products() local log = io.open("products", "r") if log == nil then @@ -159,6 +163,7 @@ local function balances() end return users end + local function last_txns() local users = {} for time, username, _, _ in read_log() do @@ -338,6 +343,23 @@ local function r_create_user() return redirect(string.format("/%s", urlencode(username))) end +local function r_products() + respond(200, "Product List", function() + print("Name | Price | Amount |
---|---|---|
%s | %.02f€ | %s |