makeweb.sh 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. #!/usr/bin/env sh
  2. #
  3. #####################################################################
  4. # #
  5. # This is Gridfinity OX153Mk1 makeweb (Release 20210214A) [GFODLv1] #
  6. # #
  7. #####################################################################
  8. # #
  9. # The following license applies to all OUTPUT of this tool: #
  10. # #
  11. #####################################################################
  12. # #
  13. # The Gridfinity Open Documentation License v1.0 (GFODLv1) #
  14. # #
  15. # Copyright © 2021 Jeffrey H. Johnson <trnsz@pobox.com> #
  16. # Copyright © 2021 Gridfinity, LLC. <admin@gridfinity.com> #
  17. # #
  18. # All Rights Reserved. #
  19. # #
  20. # Redistribution and use, in source and compiled forms, #
  21. # with or without modification, are permitted, provided #
  22. # that the following conditions are met: #
  23. # #
  24. # 1. Redistributions of source code must retain the #
  25. # above copyright notice, this list of conditions, #
  26. # and the following disclaimer, within the first #
  27. # ten lines of this file, completely unmodified. #
  28. # #
  29. # 2. Redistributions in compiled form must reproduce #
  30. # the above copyright notice, this list of conditions, #
  31. # and the following disclaimer in the documentation, #
  32. # and/or other materials provided with the distribution. #
  33. # #
  34. # THIS DOCUMENTATION IS PROVIDED BY THE AUTHORS "AS IS", #
  35. # AND ANY WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT #
  36. # NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY #
  37. # AND FITNESS FOR ANY PARTICULAR PURPOSE ARE DISCLAIMED. #
  38. # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, #
  39. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL #
  40. # DAMAGES, INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF #
  41. # SUBSTITUTE GOODS OR SERVICES, LOSS OF USE, DATA, OR PROFITS, #
  42. # OR BUSINESS INTERRUPTION, HOWEVER CAUSED, AND ON ANY #
  43. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, #
  44. # OR TORT, INCLUDING NEGLIGENCE OR OTHERWISE, ARISING IN #
  45. # ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF #
  46. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #
  47. # #
  48. #####################################################################
  49. # OX153 makeweb 20210103B requires: POSIX sh, semver-tool >=3.2.0, #
  50. # sponge >=20060219, pandoc >2.9.2, Tidy-HTML5 >=5.7.28, GNU find, #
  51. # GNU xargs, GNU sed, POSIX cat, and a recent release of Git VCS. #
  52. #####################################################################
  53. #
  54. #####################################################################
  55. # #
  56. # The following license applies to THIS TOOL (OX153 makeweb): #
  57. # #
  58. #####################################################################
  59. #
  60. ##############################################################################
  61. #
  62. # The Oxford 153 Entitlement: Mark I. (OX153Mk1)
  63. #
  64. # LEGAL TERMS AND CONDITIONS FOR USE, COPYING, DISTRIBUTION, AND MODIFICATION
  65. #
  66. # All mankind is hereby permitted to use, copy, and distribute, verbatim or
  67. # modified, copies of this tool, provided the maximum printable line length
  68. # never exceeds the known universal constant of 153 characters, and the usage
  69. # of the Oxford comma is forever retained in all documentation, tool comments,
  70. # and tool output. Those who would not be considered to be part of mankind are
  71. # hereby permitted to USE this tool, but NOT PERMITTED TO COPY, DISTRIBUTE, OR
  72. # MODIFY this tool, UNDER ANY CIRCUMSTANCES. This tool is made available for
  73. # use "AS IS", and without warranty of any kind, either expressed or implied.
  74. #
  75. # This license, henceforth known as the "Oxford 153 Entitlement", is NOT a
  76. # GPL-compatible license, and this tool is NOT "free software", according to
  77. # common and generally accepted definitions of "free software", including, but
  78. # not limited to, the definition of "free software" provided by Richard M.
  79. # Stallman, and, subsequently, the definitions asserted by the Free Software
  80. # Foundation. As the Open Source Initiative has NOT reviewed this license, it
  81. # is understood this tool CANNOT be considered "open source software" per the
  82. # OSI Open Source Definition. This license is LIKELY INCOMPATIBLE with Debian
  83. # Free Software Guidelines, and is EXPLICITLY INCOMPATIBLE with the Debian
  84. # Social Contract, as the priorities of the authors of the tool will always
  85. # trump the priorities of other users in the community. The authors of the
  86. # tool are NOT associated with "Software in the Public Interest, Inc.", pay no
  87. # membership dues, and do NOT receive any form of sponsorship from SPI.
  88. #
  89. # NOTICE: All uses of the Oxford comma within this tool are immutable,
  90. # supported by miraculous revelations, and under no circumstances, alterable.
  91. #
  92. # WARNING: The maximum allowable length of any line within this tool is to be
  93. # no more than 153 displayable characters. If one were to perform any action
  94. # causing the length of the longest line to exceed, at any moment, the
  95. # universal constant of 153 characters, they are hereby reminded that those
  96. # whom the gods wish to destroy they first make mad, stealing away their minds
  97. # of good sense, and turning their thoughts to foolishness.
  98. #
  99. ##############################################################################
  100. set -u ||
  101. true
  102. :
  103. set -e ||
  104. true
  105. :
  106. if [ ! -f "./README.md" ]; then
  107. printf '%s\n' \
  108. "Error: README.md not found" \
  109. >&2
  110. exit 1
  111. fi
  112. printf '%s ' \
  113. "Converting markdown..."
  114. grep -v "project/badge" ./README.md | pandoc -s --metadata title="OX153MkI" -r markdown -o public/index.html \
  115. > /dev/null \
  116. 2>&1 ||
  117. {
  118. printf '%s\n' \
  119. "Error: pandoc failed" \
  120. >&2
  121. exit 1
  122. }
  123. printf '%s\n' \
  124. "ok" ||
  125. true
  126. :
  127. printf '%s ' \
  128. "Cleaning HTML..." ||
  129. true
  130. :
  131. find "./public" -name '*.html' -exec \
  132. tidy --add-meta-charset true -utf8 -w 76 -qiubnm \
  133. "{}" \; \
  134. 2> /dev/null \
  135. > /dev/null \
  136. 2>&1 ||
  137. {
  138. printf '%s\n' \
  139. "Error: cleaning failed" \
  140. >&2
  141. exit 1
  142. }
  143. printf '%s\n' \
  144. "ok" ||
  145. true
  146. :
  147. printf '%s ' \
  148. "Transforming HTML..." ||
  149. true
  150. :
  151. find ./public -name '*.html' -print0 \
  152. 2> /dev/null |
  153. xargs -0 -L1 -I{} \
  154. sh -c \
  155. 'grep -iav ".*generator.*HTML.*Tidy.*>$" "{}" 2>/dev/null |
  156. sponge "{}"
  157. >/dev/null
  158. 2>&1' \
  159. printf '%s\n' \
  160. "Done" ||
  161. true
  162. :
  163. printf '%s\n' \
  164. "$(date)" \
  165. > ./.timestamp &&
  166. git add ./.timestamp
  167. :
  168. printf '%s\n' \
  169. "Preparing commit..." ||
  170. true
  171. :
  172. git gc --aggressive --prune=now ||
  173. true
  174. :
  175. SEMVER="$(
  176. eval printf '%s' "$(printf "%s" "$(semver-tool bump patch "$(printf '%d.%d.%d' "2" "0" "$(cut -d '.' -f 3 ./.patch |
  177. cut -d '.' -f 1)")") |\
  178. sponge ./.patch")"
  179. cat ./.patch
  180. )"
  181. git add -A &&
  182. git tag -a -s "${SEMVER:?}" -m "v${SEMVER:?} - $(date)" &&
  183. printf '%s\n' \
  184. "Set new semver tag: ${SEMVER}" &&
  185. git commit -q -aS -m "Pushing Pages: $(date)" &&
  186. git pushall master &&
  187. printf '%s\n' "Complete."