lib_sxng_themes.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/usr/bin/env bash
  2. # SPDX-License-Identifier: AGPL-3.0-or-later
  3. declare _Blue
  4. declare _creset
  5. themes.help(){
  6. cat <<EOF
  7. themes.:
  8. all : test & build all themes
  9. test : test all themes
  10. fix : fix JS & CSS (LESS)
  11. live : to get live builds of CSS & JS use: LIVE_THEME=simple make run
  12. simple.: test & build simple theme ..
  13. pygments: build pygment's LESS files for simple theme
  14. test : test simple theme
  15. fix : fix JS & CSS (LESS) of the simple theme
  16. EOF
  17. }
  18. themes.all() {
  19. ( set -e
  20. node.env
  21. themes.simple
  22. )
  23. dump_return $?
  24. }
  25. themes.fix() {
  26. ( set -e
  27. node.env
  28. themes.simple.fix
  29. )
  30. dump_return $?
  31. }
  32. themes.test() {
  33. ( set -e
  34. node.env
  35. themes.simple.test
  36. )
  37. dump_return $?
  38. }
  39. themes.live() {
  40. local LIVE_THEME="${LIVE_THEME:-${1}}"
  41. case "${LIVE_THEME}" in
  42. simple)
  43. theme="searx/static/themes/${LIVE_THEME}"
  44. ;;
  45. '')
  46. die 42 "missing theme argument"
  47. ;;
  48. *)
  49. die 42 "unknown theme '${LIVE_THEME}' // [simple]'"
  50. ;;
  51. esac
  52. build_msg SIMPLE "theme: $1 (live build)"
  53. node.env
  54. themes.simple.pygments
  55. cd "${theme}"
  56. {
  57. npm run watch
  58. } # 2>&1 \
  59. # | prefix_stdout "${_Blue}THEME ${1} ${_creset} " \
  60. # | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |'
  61. }
  62. themes.simple() {
  63. ( set -e
  64. themes.simple.pygments
  65. build_msg SIMPLE "theme: run build"
  66. # "run build" includes tests from eslint and stylelint
  67. npm --prefix searx/static/themes/simple run build
  68. )
  69. dump_return $?
  70. }
  71. themes.simple.pygments() {
  72. build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
  73. pyenv.cmd python searxng_extra/update/update_pygments.py \
  74. | prefix_stdout "${_Blue}PYGMENTS ${_creset} "
  75. if [ "${PIPESTATUS[0]}" -ne "0" ]; then
  76. build_msg PYGMENTS "building LESS files for pygments failed"
  77. return 1
  78. fi
  79. return 0
  80. }
  81. themes.simple.fix() {
  82. build_msg SIMPLE "theme: fix"
  83. npm --prefix searx/static/themes/simple run fix
  84. dump_return $?
  85. }
  86. themes.simple.test() {
  87. build_msg SIMPLE "theme: run test"
  88. npm --prefix searx/static/themes/simple run test
  89. dump_return $?
  90. }