From a7868afbcfd3b42242957059b4a245512e0927b9 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 30 Oct 2024 14:15:18 +0100 Subject: [PATCH] styling --- readme.md | 9 +++++++-- strichliste.lua | 17 +++++++++++------ 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/readme.md b/readme.md index 9c7205a..ec4b760 100644 --- a/readme.md +++ b/readme.md @@ -3,9 +3,14 @@ A _simpler_ trust based ledger. The entire application is contained within `strichliste.lua`. This script -implements CGI. It was tested against Lua version 5.4.7. The "database" will be -written to a file named `log` in the working directory. +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). The repository also contains a configuration file for the [gnix http server](https://codeberg.org/metamuffin/gnix) (`gnix.yaml`) which is useful for development or proxyless deployments. + +## Data Files + +- `log` stores the transaction log as CSV (`time,user,amount,comment`) +- `products` stores the product list as CSV (`barcode,price,name`) diff --git a/strichliste.lua b/strichliste.lua index c3ce80e..927a08a 100755 --- a/strichliste.lua +++ b/strichliste.lua @@ -41,7 +41,9 @@ local stylesheet = [[ .amount-neg { color: red; } nav h2 { display: inline-block } .notif { padding: 0.5em; margin: 0.5em; background-color: #ddd; } - .notif p { margin: 5px } + .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 = [[ @@ -160,7 +162,7 @@ local function r_user() return respond_error("failed to open log") end local time = os.time() - log:write(string.format("%d,%s,%s,%s\n", time, username, amount, comment)) + log:write(string.format("%d,%s,%d,%s\n", time, username, amount, comment)) log:flush() log:close() notif = string.format( @@ -185,7 +187,8 @@ local function r_user() print(string.format("

Current balance: %.02f€

", balance >= 0 and "pos" or "neg", balance / 100)) print([[ -
+ +

Create Transaction


@@ -216,8 +219,9 @@ local function r_log() print("") print("") for time, username, amount, comment in read_log() do - print(string.format("", time, escape(username), - amount / 100, escape(comment))) + print(string.format("", time, + escape(username), + amount >= 0 and "pos" or "neg", amount / 100, escape(comment))) end print("
TimeUsernameAmountComment
%d%s%.02f€%s
%d%s%.02f€%s
") end) @@ -226,7 +230,8 @@ end local function r_index() return respond(200, "Users", function() print([[ - + +

User Creation