lib_sxng_themes.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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.:
  11. build : build simple theme
  12. test : test simple theme
  13. EOF
  14. }
  15. themes.all() {
  16. ( set -e
  17. pygments.less
  18. node.env
  19. themes.simple
  20. )
  21. dump_return $?
  22. }
  23. themes.live() {
  24. local LIVE_THEME="${LIVE_THEME:-${1}}"
  25. case "${LIVE_THEME}" in
  26. simple)
  27. theme="searx/static/themes/${LIVE_THEME}"
  28. ;;
  29. '')
  30. die_caller 42 "missing theme argument"
  31. ;;
  32. *)
  33. die_caller 42 "unknown theme '${LIVE_THEME}' // [simple]'"
  34. ;;
  35. esac
  36. build_msg GRUNT "theme: $1 (live build)"
  37. nodejs.ensure
  38. cd "${theme}"
  39. {
  40. npm install
  41. npm run watch
  42. } 2>&1 \
  43. | prefix_stdout "${_Blue}THEME ${1} ${_creset} " \
  44. | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |'
  45. }
  46. themes.simple() {
  47. ( set -e
  48. build_msg GRUNT "theme: simple"
  49. npm --prefix searx/static/themes/simple run build
  50. )
  51. dump_return $?
  52. }
  53. themes.simple.test() {
  54. build_msg TEST "theme: simple"
  55. nodejs.ensure
  56. npm --prefix searx/static/themes/simple install
  57. npm --prefix searx/static/themes/simple run test
  58. dump_return $?
  59. }