aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiley L. <riley@e926.de>2025-10-29 17:29:05 +0100
committerRiley L. <riley@e926.de>2025-10-29 17:29:05 +0100
commit394dc3477cf9bf26d1bba85724c23643b61a47af (patch)
treea8c712eafa9d782e14c29ae15389ceeb665f5b79
parenta5ef0b8966ee8e09bbacdd8b17d5295afdcfefc2 (diff)
downloadabrechenbarkeit-394dc3477cf9bf26d1bba85724c23643b61a47af.tar
abrechenbarkeit-394dc3477cf9bf26d1bba85724c23643b61a47af.tar.bz2
abrechenbarkeit-394dc3477cf9bf26d1bba85724c23643b61a47af.tar.zst
add option to disable showing balancs on `/`
-rwxr-xr-xabrechenbarkeit.lua17
-rw-r--r--readme.md2
-rw-r--r--style.css6
3 files changed, 21 insertions, 4 deletions
diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua
index 4b04dd3..5421d5a 100755
--- a/abrechenbarkeit.lua
+++ b/abrechenbarkeit.lua
@@ -116,6 +116,12 @@ local script = io.open("script.js"):read("a")
local can_print = false
+local function parse_boolean(str)
+ str = string.lower(str)
+
+ return str == "on" or str == "true" or str == "yes" or str == "enable"
+end
+
local function format(template, params)
params = params or {}
if template == nil then return "NIL TEMPLATE" end
@@ -681,7 +687,9 @@ local function r_log(filter)
end)
end
-local function r_users(show_special, filter_negative)
+local function r_users(show_special, filter_negative, show_balances)
+ local show_balances = not parse_boolean(config.disable_balances) or show_balances
+
if filter_negative ~= nil then
filter_negative = tonumber(filter_negative) or 0
end
@@ -748,6 +756,7 @@ local function r_users(show_special, filter_negative)
local show_user = function(user)
local is_spu = user.name:sub(1, 1) == "@"
local filter_out = query.prefix ~= nil and user.name:sub(1, 1):lower() ~= query.prefix
+
if is_spu == show_special and
((filter_negative ~= nil and user.balance < filter_negative)
or (filter_negative == nil and (not filter_out))) then
@@ -759,7 +768,7 @@ local function r_users(show_special, filter_negative)
</li>]], {
username_url = urlencode(user.name),
username = user.name:gsub("@", ""),
- balance = format_amount(user.balance, "span")
+ balance = show_balances and format_amount(user.balance, "span") or (config.disabled_balance_replacement or "")
}))
end
end
@@ -1110,11 +1119,11 @@ if path == "/" then
elseif query.create_user then
return r_create_user()
elseif query.spus then
- return r_users(true, nil)
+ return r_users(true, nil, true)
elseif query.users and query.export then
return r_export_balances()
else
- return r_users(false, query.negative and (query.maximum or 0))
+ return r_users(false, query.negative and (query.maximum or 0), query.users or query.negative)
end
else
local username = extract_username()
diff --git a/readme.md b/readme.md
index 8af4f9a..020f2fe 100644
--- a/readme.md
+++ b/readme.md
@@ -20,6 +20,8 @@ useful for development or proxyless deployments.
- `balance_warning`: balance in cents to show warning at
- `balance_min`: minimum balance to be held by all users, in cents
- `unit`: unit used in the UI, e.g. €, $, EUR
+ - `disable_balances`: disables showing user balances on `/`, they are still shown for SPUs, and on `/?users[&negative]` etc.
+ - `disabled_balance_replacement`: only effective when `disable_balances` is set, text printed instead of balance, by default none at all; e.g. `<i>(hidden)</i>`
## Migration from Strichliste
diff --git a/style.css b/style.css
index fbe4903..19382d4 100644
--- a/style.css
+++ b/style.css
@@ -143,6 +143,10 @@ ul.userlist>li a, .firstletterlist>ul>li a {
text-decoration: none;
}
+ul.userlist i {
+ color: grey;
+}
+
.firstletterlist>h3 {
margin: 5px;
margin-right: 2em;
@@ -300,6 +304,8 @@ ul.userforms > li {
padding: 0.5rem;
}
+
+
.backgroundbox {
width: fit-content;
background-color: var(--b0);