toys.html 1.5 KB

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