summaryrefslogtreecommitdiff
path: root/utils/lib_sxng_themes.sh
blob: 8d41b6480120c348708d68ed34fefc17e8fda4ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env bash
# SPDX-License-Identifier: AGPL-3.0-or-later

declare _Blue
declare _creset

themes.help(){
    cat <<EOF
themes.:
  all       : build all themes
  live      : to get live builds of CSS & JS use 'LIVE_THEME=simple make run'
  simple.:
    build   : build simple theme
    test    : test simple theme
EOF
}

themes.all() {
    (   set -e
        pygments.less
        node.env
        themes.simple
    )
    dump_return $?
}

themes.live() {
    local LIVE_THEME="${LIVE_THEME:-${1}}"
    case "${LIVE_THEME}" in
        simple)
            theme="searx/static/themes/${LIVE_THEME}"
            ;;
        '')
            die_caller 42 "missing theme argument"
            ;;
        *)
            die_caller 42 "unknown theme '${LIVE_THEME}' // [simple]'"
            ;;
    esac
    build_msg GRUNT "theme: $1 (live build)"
    nodejs.ensure
    cd "${theme}"
    {
        npm install
        npm run watch
    } 2>&1 \
        | prefix_stdout "${_Blue}THEME ${1} ${_creset}  " \
        | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |'
}

themes.simple() {
    (   set -e
        build_msg GRUNT "theme: simple"
        npm --prefix searx/static/themes/simple run build
    )
    dump_return $?
}

themes.simple.test() {
    build_msg TEST "theme: simple"
    nodejs.ensure
    npm --prefix searx/static/themes/simple install
    npm --prefix searx/static/themes/simple run test
    dump_return $?
}