Introduction
Introduction Statistics Contact Development Disclaimer Help
tallow voting by selecting items in ranking - gph-poll - a dynamic poll for geo…
git clone git://src.adamsgaard.dk/gph-poll
Log
Files
Refs
LICENSE
---
commit afc543e950f5de12d04241690ddcc9e555ce744e
parent f376c25d72b12a1a4db4f0343bd00af1915a5504
Author: Anders Damsgaard <[email protected]>
Date: Tue, 30 Mar 2021 13:54:08 +0200
allow voting by selecting items in ranking
Diffstat:
M index.dcgi | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
---
diff --git a/index.dcgi b/index.dcgi
t@@ -9,12 +9,14 @@ polldb="poll.db"
polldescription="description.txt"
polldir="poll"
-# TODO: Lock access for database trimming.
-if [ -n "${search}" ]; then
+if [ -n "${search}" -o "${arguments}" ]; then
tmpdb="$(mktemp)"
- tail -n 99 "${polldb}" > "${tmpdb}"
- printf "%s\n" "${search}" | expand -t 4 >> "${tmpdb}"
- mv "${tmpdb}" "${polldb}"
+ if [ -r "$polldb" ]; then
+ tail -n 99 "${polldb}" > "${tmpdb}"
+ fi
+ printf "%s%s\n" "${search}" "${arguments}" \
+ | expand -t 4 >> "${tmpdb}"
+ cat "${tmpdb}" > "${polldb}"
fi
printf '\n'
t@@ -23,11 +25,17 @@ if [ -r "$polldescription" ]; then
cat "$polldescription"
fi
-printf '[7|Your choice: _______|/%s|server|port]\n\n' "$polldir"
-printf 'Ranking:\n\n'
+if [ -r "$polldb" ]; then
+ printf '\nRanking:\n\n'
+ sort "${polldb}" \
+ | uniq -c \
+ | sort -nr \
+ | while read -r count option; do
+ printf '[1|(%s) %s|/%s?%s|server|port]\n' \
+ "$count" "$option" "$polldir" "$option"
+ done
+fi
-sort "${polldb}" \
- | uniq -c \
- | sort -nr
+printf '\n[7|Add new choice: _______|/%s|server|port]\n' "$polldir"
-printf '\n[1|<< back|/|server|port]\r\n'
+printf '\n[1|<< back|/|server|port]\n'
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.