Author: Adam <git@apiote.xyz>
show item
templates/item.html | 33 +++++++++++++++++++++++++++++++++ templates/item.txt | 4 +++- toymaker.sh | 5 +++--
diff --git a/templates/item.html b/templates/item.html new file mode 100644 index 0000000000000000000000000000000000000000..cd6a50b234ac703ee3237bac63a537e975b8b2b0 --- /dev/null +++ b/templates/item.html @@ -0,0 +1,33 @@ +#!/bin/sh + +template() { + toy=$(echo "$1" | head -n1 | cut -d ';' -f1) + item=$(echo "$1" | head -n1 | cut -d ';' -f2) + status=$(echo "$1" | head -n1 | cut -d ';' -f3) + content1=$(echo "$1" | head -n1 | cut -d ';' -f4-) + content2=$(echo "$1" | tail -n+2) + cat <<EOF +<!DOCTYPE html> +<html> + <head> + <title>item</title> + </head> + <body> +EOF + printf '\t\t<h1>%s/%s</h1>\n' "$toy" "$item" + if [ "$status" = '0' ] + then + printf '\t\t<h2>OK</h2>\n' + elif [ "$status" = 'r' ] + then + printf '\t\t<h2>Running</h2>\n' + else + printf '\t\t<h2>Error</h2>\n' + fi + + printf '\t\t<code><pre>\n%s\n%s\n\t\t</pre></code>\n' "$content1" "$content2" + cat <<EOF + </body> +</html> +EOF +} diff --git a/templates/item.txt b/templates/item.txt index 7f9f4504afbbf23cd62be307d269ece42bed94d8..4a307a01c258d4d79e9379cd4e82ffaa6cd9b37a 100644 --- a/templates/item.txt +++ b/templates/item.txt @@ -1,5 +1,7 @@ #!/bin/sh template() { - printf '%s' "$1" + content1=$(echo "$1" | head -n1 | cut -d ';' -f4-) + content2=$(echo "$1" | tail -n+2) + printf '%s\n%s' "$content1" "$content2" } diff --git a/toymaker.sh b/toymaker.sh index ff7ce96ab59f214f903a7df21c0ce143e0da626e..e09267d33cff6de521d66757ac13a1ca7b30b5c8 100755 --- a/toymaker.sh +++ b/toymaker.sh @@ -219,11 +219,12 @@ respond404 "$path" return 1 fi r=$(show_item "$toy" "$item") - status=$(echo "$r" | cut -d ';' -f 1) + # artifacts=$(item_artifacts "$toy" "$item") + status=$(echo "$r" | head -n1 | cut -d ';' -f1) if [ "$status" = 'n' ] then respond404 "$path" - elif page=$(templateMessage "$r" 'item' "$accept") + elif page=$(templateMessage "$toy;$item;$r" 'item' "$accept") # add artifacts to message then if [ "$status" = 'r' ] then