mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2024-12-27 15:44:34 +00:00
css and rebrad
This commit is contained in:
parent
368af91f8f
commit
4961908376
4 changed files with 55 additions and 48 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
!/gnix.yaml
|
!/gnix.yaml
|
||||||
!/readme.md
|
!/readme.md
|
||||||
!/strichliste.lua
|
!/abrechenbarkeit.lua
|
||||||
!/.gitignore
|
!/.gitignore
|
||||||
!/collapse_log.lua
|
!/collapse_log.lua
|
||||||
|
|
|
@ -51,19 +51,20 @@ local path = os.getenv("PATH_INFO")
|
||||||
local method = os.getenv("REQUEST_METHOD")
|
local method = os.getenv("REQUEST_METHOD")
|
||||||
local query = parse_query(os.getenv("QUERY_STRING"))
|
local query = parse_query(os.getenv("QUERY_STRING"))
|
||||||
|
|
||||||
local stylesheet = [[
|
local stylesheet = io.open("a.css"):read("a")
|
||||||
/* body { background-color: #161616; }
|
-- local stylesheet = [[
|
||||||
h1, h2, h3, h4, h5, h6, p, label, a { color: #e2e2e2; } */
|
-- /* body { background-color: #161616; }
|
||||||
.amount-presets form { display: inline-block; width: 60px }
|
-- h1, h2, h3, h4, h5, h6, p, label, a { color: #e2e2e2; } */
|
||||||
.amount-pos { color: green; }
|
-- .amount-presets form { display: inline-block; width: 60px }
|
||||||
.amount-neg { color: red; }
|
-- .amount-pos { color: green; }
|
||||||
nav h2 { display: inline-block }
|
-- .amount-neg { color: red; }
|
||||||
.notif { padding: 0.5em; margin: 0.5em; background-color: #ddd; }
|
-- nav h2 { display: inline-block }
|
||||||
.notif.error { background-color: #faa; }
|
-- .notif { padding: 0.5em; margin: 0.5em; background-color: #ddd; }
|
||||||
.notif p { margin: 5px; }
|
-- .notif.error { background-color: #faa; }
|
||||||
form.box { border: 2px solid grey; padding: 0.5em; margin: 0.5em; display: inline-block; }
|
-- .notif p { margin: 5px; }
|
||||||
form h3 { margin: 5px; }
|
-- form.box { border: 2px solid grey; padding: 0.5em; margin: 0.5em; display: inline-block; }
|
||||||
]]
|
-- form h3 { margin: 5px; }
|
||||||
|
-- ]]
|
||||||
|
|
||||||
local script = [[
|
local script = [[
|
||||||
document.addEventListener("keypress", ev => {
|
document.addEventListener("keypress", ev => {
|
||||||
|
@ -91,10 +92,15 @@ local function respond(status, title, body)
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav>
|
<nav>
|
||||||
<h2><a href="/">Strichliste v2</a></h2>
|
<a class="logo" href="/">
|
||||||
<span><a href="/?log">Log</a></span>
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-receipt-cutoff" viewBox="0 0 16 16">
|
||||||
<span><a href="/?products">Products</a></span>
|
<path d="M3 4.5a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 1 1 0 1h-6a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5m0 2a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5M11.5 4a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1zm0 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z"/>
|
||||||
<span><a href="https://codeberg.org/metamuffin/strichliste">Source</a></span>
|
<path d="M2.354.646a.5.5 0 0 0-.801.13l-.5 1A.5.5 0 0 0 1 2v13H.5a.5.5 0 0 0 0 1h15a.5.5 0 0 0 0-1H15V2a.5.5 0 0 0-.053-.224l-.5-1a.5.5 0 0 0-.8-.13L13 1.293l-.646-.647a.5.5 0 0 0-.708 0L11 1.293l-.646-.647a.5.5 0 0 0-.708 0L9 1.293 8.354.646a.5.5 0 0 0-.708 0L7 1.293 6.354.646a.5.5 0 0 0-.708 0L5 1.293 4.354.646a.5.5 0 0 0-.708 0L3 1.293zm-.217 1.198.51.51a.5.5 0 0 0 .707 0L4 1.707l.646.647a.5.5 0 0 0 .708 0L6 1.707l.646.647a.5.5 0 0 0 .708 0L8 1.707l.646.647a.5.5 0 0 0 .708 0L10 1.707l.646.647a.5.5 0 0 0 .708 0L12 1.707l.646.647a.5.5 0 0 0 .708 0l.509-.51.137.274V15H2V2.118z"/>
|
||||||
|
</svg>
|
||||||
|
Abrechenbarkeit</a>
|
||||||
|
<a href="/?log">Log</a>
|
||||||
|
<a href="/?products">Products</a>
|
||||||
|
<a href="https://codeberg.org/metamuffin/strichliste">Source</a>
|
||||||
</nav>
|
</nav>
|
||||||
]], escape(title), stylesheet, script, config.head_extra or ""))
|
]], escape(title), stylesheet, script, config.head_extra or ""))
|
||||||
body()
|
body()
|
||||||
|
@ -223,7 +229,7 @@ local function r_user(username)
|
||||||
if method == "POST" then
|
if method == "POST" then
|
||||||
notif = r_user_post(username)
|
notif = r_user_post(username)
|
||||||
end
|
end
|
||||||
return respond(200, string.format("Strichliste: %s", username), function()
|
return respond(200, string.format("Abrechenbarheit: %s", username), function()
|
||||||
print(string.format("<h1>%s</h1>", username))
|
print(string.format("<h1>%s</h1>", username))
|
||||||
local balance = balances()[username]
|
local balance = balances()[username]
|
||||||
local last_txn = last_txns()[username]
|
local last_txn = last_txns()[username]
|
||||||
|
@ -236,29 +242,14 @@ local function r_user(username)
|
||||||
]])
|
]])
|
||||||
else
|
else
|
||||||
print(string.format([[
|
print(string.format([[
|
||||||
<p>Current balance: <span class="amount-%s">%.02f€</p>
|
<p><span class="balance">Current balance:</span><span class="amount-%s balance-value">%.02f€</p>
|
||||||
]], balance >= 0 and "pos" or "neg", balance / 100))
|
]], balance >= 0 and "pos" or "neg", balance / 100))
|
||||||
print(string.format([[
|
print(string.format([[
|
||||||
<p>Last transaction added %s ago. <a href="/%s?log">View user log</a>
|
<p>Last transaction added %s ago. <a href="/%s?log">View user log</a>
|
||||||
]], format_duration(os.time() - last_txn), username))
|
]], format_duration(os.time() - last_txn), username))
|
||||||
end
|
end
|
||||||
print([[
|
print([[<div class="transactions container">]])
|
||||||
<form class="transaction box" action="" method="POST">
|
print([[<div class="amount-presets box">]])
|
||||||
<h3>Create Transaction</h3>
|
|
||||||
<label for="amount">Amount: </label>
|
|
||||||
<input type="number" name="amount" id="amount" /><br/>
|
|
||||||
<label for="comment">Comment: </label>
|
|
||||||
<input type="text" name="comment" id="comment" /><br/>
|
|
||||||
<input type="submit" value="Update" />
|
|
||||||
</form>
|
|
||||||
<form class="transaction box" action="" method="POST" id="buy_product">
|
|
||||||
<h3>Buy Product</h3>
|
|
||||||
<label for="product">Product: </label>
|
|
||||||
<input type="text" name="product" id="product" /><br/>
|
|
||||||
<input type="submit" value="Buy" />
|
|
||||||
</form>
|
|
||||||
]])
|
|
||||||
print([[<div class="amount-presets">]])
|
|
||||||
for _, type in ipairs({ 1, -1 }) do
|
for _, type in ipairs({ 1, -1 }) do
|
||||||
for _, amount in ipairs({ 50, 100, 150, 200, 500, 1000 }) do
|
for _, amount in ipairs({ 50, 100, 150, 200, 500, 1000 }) do
|
||||||
print(string.format([[
|
print(string.format([[
|
||||||
|
@ -270,14 +261,30 @@ local function r_user(username)
|
||||||
]], amount * type, ({ [-1] = "-", [1] = "+" })[type], amount / 100,
|
]], amount * type, ({ [-1] = "-", [1] = "+" })[type], amount / 100,
|
||||||
({ [-1] = "neg", [1] = "pos" })[type]))
|
({ [-1] = "neg", [1] = "pos" })[type]))
|
||||||
end
|
end
|
||||||
print("<br/>")
|
|
||||||
end
|
end
|
||||||
print("</div>")
|
print("</div>")
|
||||||
|
print([[
|
||||||
|
<form class="transaction box" action="" method="POST">
|
||||||
|
<h3>Create Transaction</h3>
|
||||||
|
<label for="amount">Amount: </label>
|
||||||
|
<input type="number" name="amount" id="amount" />
|
||||||
|
<label for="comment">Comment: </label>
|
||||||
|
<input type="text" name="comment" id="comment" />
|
||||||
|
<input type="submit" value="Update" />
|
||||||
|
</form>
|
||||||
|
<form class="transaction box" action="" method="POST" id="buy_product">
|
||||||
|
<h3>Buy Product</h3>
|
||||||
|
<label for="product">Product: </label>
|
||||||
|
<input type="text" name="product" id="product" />
|
||||||
|
<input type="submit" value="Buy" />
|
||||||
|
</form>
|
||||||
|
]])
|
||||||
|
print("</div>")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function r_log(filter)
|
local function r_log(filter)
|
||||||
return respond(200, "Strichliste Log", function()
|
return respond(200, "Abrechnungen", function()
|
||||||
print("<table>")
|
print("<table>")
|
||||||
print("<tr><th>Time</th><th>Username</th><th>Amount</th><th>Comment</th></tr>")
|
print("<tr><th>Time</th><th>Username</th><th>Amount</th><th>Comment</th></tr>")
|
||||||
for time, username, amount, comment in read_log() do
|
for time, username, amount, comment in read_log() do
|
||||||
|
@ -312,19 +319,19 @@ local function r_log(filter)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function r_index()
|
local function r_index()
|
||||||
return respond(200, "Strichliste", function()
|
return respond(200, "Abrechenbarkeit", function()
|
||||||
print([[
|
print([[
|
||||||
<form action="/" method="GET" class="box">
|
<form action="/" method="GET" class="creation">
|
||||||
<h3>User Creation</h3>
|
<h3>User Creation</h3>
|
||||||
<label for="username">Username: </label>
|
<label for="username">Username: </label>
|
||||||
<input type="text" name="create_user" id="username" /><br/>
|
<input type="text" name="create_user" id="username" />
|
||||||
<input type="submit" value="Continue" />
|
<input type="submit" value="Continue" />
|
||||||
</form>
|
</form>
|
||||||
]])
|
]])
|
||||||
print("<ul>")
|
print("<ul>")
|
||||||
for username, balance in pairs(balances()) do
|
for username, balance in pairs(balances()) do
|
||||||
print(string.format([[
|
print(string.format([[
|
||||||
<li><a href="/%s">%s</a>: <span class="amount-%s">%.02f€</span></li>
|
<li><a href="/%s"><span class="name">%s</span> <span class="amount amount-%s">%.02f€</span></a></li>
|
||||||
]],
|
]],
|
||||||
urlencode(username),
|
urlencode(username),
|
||||||
escape(username),
|
escape(username),
|
||||||
|
@ -344,9 +351,9 @@ local function r_create_user()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function r_products()
|
local function r_products()
|
||||||
respond(200, "Strichliste Product List", function()
|
respond(200, "Abrechenbare Products", function()
|
||||||
print("<h1>Product List</h1>")
|
print("<h1>Product List</h1>")
|
||||||
print("<table><tr><th>Name</th><th>Price</th><th>Amount</th></tr>")
|
print("<table><tr><th>Name</th><th>Price</th><th>Barcode</th></tr>")
|
||||||
for barcode, price, name in read_products() do
|
for barcode, price, name in read_products() do
|
||||||
print(string.format([[
|
print(string.format([[
|
||||||
<tr><td>%s</td><td class="amount-%s">%.02f€</td><td>%s</td></tr>
|
<tr><td>%s</td><td class="amount-%s">%.02f€</td><td>%s</td></tr>
|
|
@ -1,2 +1,2 @@
|
||||||
http: { bind: "0.0.0.0:8080" }
|
http: { bind: "0.0.0.0:8080" }
|
||||||
handler: !cgi { bin: ./strichliste.lua }
|
handler: !cgi { bin: ./abrechenbarkeit.lua }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# Strichliste v2
|
# Abrechenbarkeit v2
|
||||||
|
|
||||||
A _simpler_ trust based ledger.
|
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
|
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).
|
stored in a number of files in the process working directory (See below).
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue