lib_sxng_themes.sh 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 : build all themes
  9. live : to get live builds of CSS & JS use 'LIVE_THEME=simple make run'
  10. simple.: build simple theme
  11. test : test simple theme
  12. pygments: build pygment's LESS files for simple theme
  13. EOF
  14. }
  15. themes.all() {
  16. ( set -e
  17. themes.simple
  18. )
  19. dump_return $?
  20. }
  21. themes.live() {
  22. local LIVE_THEME="${LIVE_THEME:-${1}}"
  23. case "${LIVE_THEME}" in
  24. simple)
  25. theme="searx/static/themes/${LIVE_THEME}"
  26. ;;
  27. '')
  28. die_caller 42 "missing theme argument"
  29. ;;
  30. *)
  31. die_caller 42 "unknown theme '${LIVE_THEME}' // [simple]'"
  32. ;;
  33. esac
  34. build_msg GRUNT "theme: $1 (live build)"
  35. nodejs.ensure
  36. cd "${theme}"
  37. {
  38. npm install
  39. npm run watch
  40. } 2>&1 \
  41. | prefix_stdout "${_Blue}THEME ${1} ${_creset} " \
  42. | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |'
  43. }
  44. themes.simple() {
  45. ( set -e
  46. node.env
  47. themes.simple.pygments
  48. )
  49. build_msg GRUNT "theme: simple"
  50. npm --prefix searx/static/themes/simple run build
  51. dump_return $?
  52. }
  53. themes.simple.pygments() {
  54. build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
  55. pyenv.cmd python searxng_extra/update/update_pygments.py \
  56. | prefix_stdout "${_Blue}PYGMENTS ${_creset} "
  57. if [ "${PIPESTATUS[0]}" -ne "0" ]; then
  58. build_msg PYGMENTS "building LESS files for pygments failed"
  59. return 1
  60. fi
  61. return 0
  62. }
  63. themes.simple.test() {
  64. build_msg TEST "theme: simple"
  65. node.env
  66. npm --prefix searx/static/themes/simple install
  67. npm --prefix searx/static/themes/simple run test
  68. dump_return $?
  69. }