toymaker.git

commit 6596b588f3cb63a6aa15a43f6c44d33345df6d1c

Author: Adam <git@apiote.xyz>

list toys with latest status

 get.sh | 7 ++++++-
 templates/toys.html | 34 ++++++++++++++++++++++++++++++++++


diff --git a/get.sh b/get.sh
index e3c706c7afe08059a96e6e4dc269468a67389c7b..b0ddcd58276d91c45af499f1d92ef01ff7e44176 100644
--- a/get.sh
+++ b/get.sh
@@ -1,7 +1,12 @@
 #!/bin/sh
 
 list_toys() {
-	find toys/ -mindepth 1 -maxdepth 1 -type d
+	toys=$(find toys/ -mindepth 1 -maxdepth 1 -type d | sed 's|toys/||')
+	echo "$toys" | while read -r toy
+	do
+		status=$(show_item "$toy" 'latest' | head -n1 | cut -d ';' -f1)
+		printf '%s;%s\n' "$status" "$toy"
+	done
 }
 
 list_items() {




diff --git a/templates/toys.html b/templates/toys.html
new file mode 100644
index 0000000000000000000000000000000000000000..9b362f3c2241233021b5d50e38f65ae2c088d6ea
--- /dev/null
+++ b/templates/toys.html
@@ -0,0 +1,34 @@
+#!/bin/sh
+
+template() {
+	cat <<EOF
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>toys</title>
+	</head>
+	<body>
+EOF
+	for toy in $1
+	do
+		status=$(echo "$toy" | cut -d ';' -f1)
+		name=$(echo "$toy" | cut -d ';' -f2)
+		if [ "$status" = '0' ]
+		then
+			printf '\t\tOK '
+		elif [ "$status" = 'n' ]
+		then
+			printf '\t\tNY '
+		elif [ "$status" = 'r' ]
+		then
+			printf '\t\tRU '
+		else
+			printf '\t\tER '
+		fi
+		printf '<a href="/toys/%s">%s</a><br/>\n' "$name" "$name"
+	done
+	cat <<EOF
+	</body>
+</html>
+EOF
+}