toy.html 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #!/bin/sh
  2. template() {
  3. toy=$(echo "$1" | cut -d ';' -f 1)
  4. content=$(echo "$1" | cut -d ';' -f 2)
  5. cat <<EOF
  6. <!DOCTYPE html>
  7. <html>
  8. <head>
  9. <meta charset="UTF-8">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. EOF
  12. printf '\t\t<title>toymaker::%s</title>\n' "$toy"
  13. cat <<EOF
  14. <style>
  15. * {
  16. box-sizing: border-box;
  17. }
  18. a {
  19. color: #00afff;
  20. }
  21. a:hover {
  22. background-color: #db9d3b;
  23. color: #000000;
  24. }
  25. </style>
  26. </head>
  27. <body style="background-color: #292929; color: #fafafa;">
  28. <header style="font-size: 1.25rem; padding-top: .3125rem; padding-bottom: .3125rem;">
  29. <a href="/toys/" style="font-family: monospace; text-decoration: none;">toymaker</a>
  30. </header>
  31. <main style="margin-left: 1rem; margin-top: 2rem;">
  32. EOF
  33. printf '\t\t\t<h1>%s</h1>\n' "$toy"
  34. if [ "$(echo "$content" | tr -d ' ' | sed 's/n,//')" = '' ]
  35. then
  36. printf '\t\t\t<span style="font-size: 2rem;>Have not run yet</span>\n'
  37. else
  38. printf '\t\t\t<ul>\n'
  39. for item in $content
  40. do
  41. status=$(echo "$item" | cut -d ',' -f1)
  42. name=$(echo "$item" | cut -d ',' -f2)
  43. printf '\t\t\t\t<li>\n'
  44. if [ "$status" = '0' ]
  45. then
  46. printf '\t\t\t\t\t<span style="color: #5af78e; font-size: .75rem; margin-right: .5rem;">OK</span>\n'
  47. elif [ "$status" = 'r' ]
  48. then
  49. printf '\t\t\t\t\t<span style="font-size: .75rem; margin-right: .5rem;">R_</span>\n'
  50. else
  51. printf '\t\t\t\t\t<span style="color: #ff5c57; font-size: .75rem; margin-right: .5rem;">ER</span>\n'
  52. fi
  53. printf '\t\t\t\t\t<a href="/toys/%s/%s"><span style="font-size: 1.5rem;">%s</span></a>\n' "$toy" "$name" "$name"
  54. printf '\t\t\t\t</li>\n'
  55. done
  56. printf '\t\t\t</ul>\n'
  57. fi
  58. cat <<EOF
  59. </main>
  60. </body>
  61. </html>
  62. EOF
  63. }