Author: Adam <git@apiote.xyz>
[WIP] artifacts
get.sh | 12 ++++++++++++ templates/item.html | 25 ++++++++++++++++++++----- templates/item.txt | 2 +- toymaker.sh | 4 ++--
diff --git a/get.sh b/get.sh index ce13dbffe7ed70dc5993759d05a452aec869c318..1cc8543c50ea23dd3dbcd54dabad1506fe08bd05 100644 --- a/get.sh +++ b/get.sh @@ -51,6 +51,18 @@ cat "toys/$toy/$item.log" fi } +item_artifacts() { + toy=$1 + item=$2 + artifacts="" + for artifactName in "toys/$toy/$item/"* + do + artifactName=$(printf '%s' "$artifactName" | sed "s|toys/$toy/$item/||") + artifacts=$(printf '%s %s' "$artifacts" "$artifactName") + done + printf '%s' "$artifacts" | sed 's/^ //' +} + get_artifact() { toy=$1 item=$2 diff --git a/templates/item.html b/templates/item.html index cd6a50b234ac703ee3237bac63a537e975b8b2b0..510d5dfd457aef3eb7ec69461ac9e935c8a7965f 100644 --- a/templates/item.html +++ b/templates/item.html @@ -1,16 +1,21 @@ #!/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-) + artifacts=$(echo "$1" | head -n1 | cut -d ';' -f1) + toy=$(echo "$1" | head -n1 | cut -d ';' -f2) + item=$(echo "$1" | head -n1 | cut -d ';' -f3) + status=$(echo "$1" | head -n1 | cut -d ';' -f4) + content1=$(echo "$1" | head -n1 | cut -d ';' -f5-) content2=$(echo "$1" | tail -n+2) cat <<EOF <!DOCTYPE html> <html> <head> - <title>item</title> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1.0"> +EOF + printf '\t\t<title>toymaker::%s/%s</title>\n' "$toy" "$item" + cat <<EOF </head> <body> EOF @@ -23,6 +28,16 @@ then printf '\t\t<h2>Running</h2>\n' else printf '\t\t<h2>Error</h2>\n' + fi + + if [ -n "$artifacts" ] + then + printf '\t\t<details>\n\t\t\t<summary>artifacts</summary>\n\t\t\t<ul>\n' + for artifact in $artifacts + do + printf '\t\t\t<li><a href="/toys/%s/%s/%s">%s</a></li>\n' "$toy" "$item" "$artifact" "$artifact" + done + printf '\t\t</details>' fi printf '\t\t<code><pre>\n%s\n%s\n\t\t</pre></code>\n' "$content1" "$content2" diff --git a/templates/item.txt b/templates/item.txt index 4a307a01c258d4d79e9379cd4e82ffaa6cd9b37a..777f474ad75cb962a9a9d820570ef206d0263fdf 100644 --- a/templates/item.txt +++ b/templates/item.txt @@ -1,7 +1,7 @@ #!/bin/sh template() { - content1=$(echo "$1" | head -n1 | cut -d ';' -f4-) + content1=$(echo "$1" | head -n1 | cut -d ';' -f5-) content2=$(echo "$1" | tail -n+2) printf '%s\n%s' "$content1" "$content2" } diff --git a/toymaker.sh b/toymaker.sh index 84c1a27ef5b710a3d6ce187459e5468834a7f5e0..b44ca7db18161ca44756337397ab5f7cce8b8451 100755 --- a/toymaker.sh +++ b/toymaker.sh @@ -219,13 +219,13 @@ respond404 "$path" return 1 fi r=$(show_item "$toy" "$item") - # artifacts=$(item_artifacts "$toy" "$item") + artifacts=$(item_artifacts "$toy" "$item") status=$(echo "$r" | head -n1 | cut -d ';' -f1) if [ "$status" = 'n' ] then respond404 "item $toy/$item" return 1 - elif page=$(templateMessage "$toy;$item;$r" 'item' "$accept") # todo add artifacts to message + elif page=$(templateMessage "$artifacts;$toy;$item;$r" 'item' "$accept") then body=$(echo "$page" | tail -n+2) contentType=$(echo "$page" | head -n1)