toymaker.git

commit 89e9246f2899ae707a8801d02dd6c390f4256044

Author: Adam <git@apiote.xyz>

show toy with latest status

 get.sh | 7 ++++++-
 templates/toy.html | 39 +++++++++++++++++++++++++++++++++++++++
 toymaker.sh | 5 +++--


diff --git a/get.sh b/get.sh
index b0ddcd58276d91c45af499f1d92ef01ff7e44176..57fcd7293decb1528a55de49a37b27b09f032e0d 100644
--- a/get.sh
+++ b/get.sh
@@ -16,7 +16,12 @@ 	then
 		printf "n;"
 	else
 		printf "0;"
-		find "toys/$toy" . -mindepth 1 -maxdepth 1 -type d
+		items=$(find "toys/$toy" -mindepth 1 -maxdepth 1 -type d | sed "s|toys/$toy/||")
+		echo "$items" | while read -r item
+		do
+			status=$(show_item "$toy" 'latest' | head -n1 | cut -d ';' -f1)
+			printf '%s,%s ' "$status" "$item"
+		done
 	fi
 }
 




diff --git a/templates/toy.html b/templates/toy.html
new file mode 100644
index 0000000000000000000000000000000000000000..82ea88d26598756c607e2571468ae17e527e9c2d
--- /dev/null
+++ b/templates/toy.html
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+template() {
+	toy=$(echo "$1" | cut -d ';' -f 1)
+	content=$(echo "$1" | cut -d ';' -f 2)
+	cat <<EOF
+<!DOCTYPE html>
+<html>
+	<head>
+		<title>$toy</title>
+	</head>
+	<body>
+EOF
+
+	cat <<EOF
+		<h1>$toy</h1>
+EOF
+	if [ "$(echo "$content" | tr -d ' ' | sed 's/n,//')" = '' ]
+	then
+		printf '\t\tHave not run yet\n'
+	else
+		echo "$content" | while read -r item
+		do
+			status=$(echo "$item" | cut -d ',' -f1)
+			name=$(echo "$item" | cut -d ',' -f2)
+			if [ "$status" = '0' ]
+			then
+				printf '\t\tOK '
+			else
+				printf '\t\tERR '
+			fi
+			printf '<a href="/toys/%s/%s">%s</a><br/>\n' "$toy" "$name" "$name"
+		done
+	fi
+	cat <<EOF
+	</body>
+</html>
+EOF
+}




diff --git a/toymaker.sh b/toymaker.sh
index ad646f5371ce9db4eac1b6f5fdafc1ea7de562ef..ff7ce96ab59f214f903a7df21c0ce143e0da626e 100755
--- a/toymaker.sh
+++ b/toymaker.sh
@@ -197,11 +197,12 @@ 					respond406 "$accept"
 				fi
 			else
 				r=$(list_items "$toy")
-				status=$(echo "$r" | cut -d ';' -f 1)
+				status=$(echo "$r" | cut -d ';' -f1)
+				content=$(echo "$r" | cut -d ';' -f2)
 				if [ "$status" = 'n' ]
 				then
 					respond404 "$path"
-				elif page=$(templateMessage "$r" 'items' 'text/html')
+				elif page=$(templateMessage "$toy;$content" 'toy' 'text/html')
 				then
 					respond200 "$page"
 				else