diff --git a/.gitignore b/.gitignore index 3564e40..ffe2fa3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ /* !/gnix.yaml !/readme.md -!/strichliste.lua +!/abrechenbarkeit.lua !/.gitignore !/collapse_log.lua diff --git a/strichliste.lua b/abrechenbarkeit.lua similarity index 79% rename from strichliste.lua rename to abrechenbarkeit.lua index fbdfbb5..dc3685b 100755 --- a/strichliste.lua +++ b/abrechenbarkeit.lua @@ -51,19 +51,20 @@ local path = os.getenv("PATH_INFO") local method = os.getenv("REQUEST_METHOD") local query = parse_query(os.getenv("QUERY_STRING")) -local stylesheet = [[ - /* body { background-color: #161616; } - h1, h2, h3, h4, h5, h6, p, label, a { color: #e2e2e2; } */ - .amount-presets form { display: inline-block; width: 60px } - .amount-pos { color: green; } - .amount-neg { color: red; } - nav h2 { display: inline-block } - .notif { padding: 0.5em; margin: 0.5em; background-color: #ddd; } - .notif.error { background-color: #faa; } - .notif p { margin: 5px; } - form.box { border: 2px solid grey; padding: 0.5em; margin: 0.5em; display: inline-block; } - form h3 { margin: 5px; } -]] +local stylesheet = io.open("a.css"):read("a") +-- local stylesheet = [[ +-- /* body { background-color: #161616; } +-- h1, h2, h3, h4, h5, h6, p, label, a { color: #e2e2e2; } */ +-- .amount-presets form { display: inline-block; width: 60px } +-- .amount-pos { color: green; } +-- .amount-neg { color: red; } +-- nav h2 { display: inline-block } +-- .notif { padding: 0.5em; margin: 0.5em; background-color: #ddd; } +-- .notif.error { background-color: #faa; } +-- .notif p { margin: 5px; } +-- form.box { border: 2px solid grey; padding: 0.5em; margin: 0.5em; display: inline-block; } +-- form h3 { margin: 5px; } +-- ]] local script = [[ document.addEventListener("keypress", ev => { @@ -91,10 +92,15 @@ local function respond(status, title, body) ]], escape(title), stylesheet, script, config.head_extra or "")) body() @@ -223,7 +229,7 @@ local function r_user(username) if method == "POST" then notif = r_user_post(username) end - return respond(200, string.format("Strichliste: %s", username), function() + return respond(200, string.format("Abrechenbarheit: %s", username), function() print(string.format("

%s

", username)) local balance = balances()[username] local last_txn = last_txns()[username] @@ -236,29 +242,14 @@ local function r_user(username) ]]) else print(string.format([[ -

Current balance: %.02f€

+

Current balance:%.02f€

]], balance >= 0 and "pos" or "neg", balance / 100)) print(string.format([[

Last transaction added %s ago. View user log ]], format_duration(os.time() - last_txn), username)) end - print([[ -

-

Create Transaction

- -
- -
- -
-
-

Buy Product

- -
- -
- ]]) - print([[
]]) + print([[
]]) + print([[
]]) for _, type in ipairs({ 1, -1 }) do for _, amount in ipairs({ 50, 100, 150, 200, 500, 1000 }) do print(string.format([[ @@ -270,14 +261,30 @@ local function r_user(username) ]], amount * type, ({ [-1] = "-", [1] = "+" })[type], amount / 100, ({ [-1] = "neg", [1] = "pos" })[type])) end - print("
") end print("
") + print([[ +
+

Create Transaction

+ + + + + +
+
+

Buy Product

+ + + +
+ ]]) + print("
") end) end local function r_log(filter) - return respond(200, "Strichliste Log", function() + return respond(200, "Abrechnungen", function() print("") print("") for time, username, amount, comment in read_log() do @@ -312,19 +319,19 @@ local function r_log(filter) end local function r_index() - return respond(200, "Strichliste", function() + return respond(200, "Abrechenbarkeit", function() print([[ - +

User Creation

-
+ ]]) print("
TimeUsernameAmountComment
") + print("
NamePriceAmount
") for barcode, price, name in read_products() do print(string.format([[ diff --git a/gnix.yaml b/gnix.yaml index 5f8470c..8815f2a 100644 --- a/gnix.yaml +++ b/gnix.yaml @@ -1,2 +1,2 @@ http: { bind: "0.0.0.0:8080" } -handler: !cgi { bin: ./strichliste.lua } +handler: !cgi { bin: ./abrechenbarkeit.lua } diff --git a/readme.md b/readme.md index 2ea03f7..4785d95 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,8 @@ -# Strichliste v2 +# Abrechenbarkeit v2 A _simpler_ trust based ledger. -The entire application is contained within `strichliste.lua`. This script +The entire application is contained within `abrechenbarkeit.lua`. This script implements CGI. It was tested against Lua version 5.4.7. Application data is stored in a number of files in the process working directory (See below).
NamePriceBarcode
%s%.02f€%s