@@ -5,6 +5,8 @@ PYTHONPATH=$BASE_DIR
55SEARX_DIR="$BASE_DIR/searx"
66ACTION=$1
77
8+cd "$BASE_DIR"
9+
810update_packages() {
911 pip install -r "$BASE_DIR/requirements.txt"
1012}
@@ -14,16 +16,17 @@ update_dev_packages() {
1416 pip install -r "$BASE_DIR/requirements-dev.txt"
1517}
1618
17−check_geckodriver() {
19+install_geckodriver() {
1820 echo '[!] Checking geckodriver'
21+ # TODO : check the current geckodriver version
1922 set -e
2023 geckodriver -V 2>1 > /dev/null || NOTFOUND=1
2124 set +e
2225 if [ -z $NOTFOUND ]; then
2326 return
2427 fi
25− GECKODRIVER_VERSION="v0.14.0"
26− PLATFORM=`python -c "import platform; print platform.system().lower(), platform.architecture()[0]"`
28+ GECKODRIVER_VERSION="v0.18.0"
29+ PLATFORM=`python -c "import six; import platform; six.print_(platform.system().lower(), platform.architecture()[0])"`
2730 case $PLATFORM in
2831 "linux 32bit" | "linux2 32bit") ARCH="linux32";;
2932 "linux 64bit" | "linux2 64bit") ARCH="linux64";;
@@ -32,16 +35,25 @@ check_geckodriver() {
3235 "mac 64bit") ARCH="macos";;
3336 esac
3437 GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/$GECKODRIVER_VERSION/geckodriver-$GECKODRIVER_VERSION-$ARCH.tar.gz";
35− if [ -z "$VIRTUAL_ENV" ]; then
36− echo "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n $GECKODRIVER_URL"
37− exit
38+
39+ if [ -z "$1" ]; then
40+ if [ -z "$VIRTUAL_ENV" ]; then
41+ echo "geckodriver can't be installed because VIRTUAL_ENV is not set, you should download it from\n $GECKODRIVER_URL"
42+ exit
43+ else
44+ GECKODRIVER_DIR="$VIRTUAL_ENV/bin"
45+ fi
3846 else
39− echo "Installing $VIRTUAL_ENV from\n $GECKODRIVER_URL"
40− FILE=`mktemp`
41− wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C $VIRTUAL_ENV/bin/ -f $FILE geckodriver
42− rm $FILE
43− chmod 777 $VIRTUAL_ENV/bin/geckodriver
47+ GECKODRIVER_DIR="$1"
48+ mkdir -p "$GECKODRIVER_DIR"
4449 fi
50+
51+ echo "Installing $GECKODRIVER_DIR/geckodriver from\n $GECKODRIVER_URL"
52+
53+ FILE=`mktemp`
54+ wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C "$GECKODRIVER_DIR" -f $FILE geckodriver
55+ rm $FILE
56+ chmod 777 "$GECKODRIVER_DIR/geckodriver"
4557}
4658
4759pep8_check() {
@@ -73,37 +85,49 @@ tests() {
7385 set -e
7486 pep8_check
7587 unit_tests
76− check_geckodriver
88+ install_geckodriver
7789 robot_tests
7890 set +e
7991}
8092
8193build_style() {
82− # lessc -x "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
8394 lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2"
8495}
8596
8697styles() {
8798 echo '[!] Building styles'
88− build_style themes/legacy/less/style.less themes/legacy/css/style.css
89− build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css
90− build_style themes/courgette/less/style.less themes/courgette/css/style.css
91− build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
92− build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
93− build_style themes/oscar/less/pointhi/oscar.less themes/oscar/css/pointhi.min.css
94− build_style themes/oscar/less/logicodev/oscar.less themes/oscar/css/logicodev.min.css
95− build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
96− build_style themes/simple/less/style.less themes/simple/css/searx.min.css
97− build_style themes/simple/less/style-rtl.less themes/simple/css/searx-rtl.min.css
99+ build_style themes/legacy/less/style.less themes/legacy/css/style.css
100+ build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css
101+ build_style themes/courgette/less/style.less themes/courgette/css/style.css
102+ build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css
103+ build_style less/bootstrap/bootstrap.less css/bootstrap.min.css
104+ build_style themes/pix-art/less/style.less themes/pix-art/css/style.css
105+ # built using grunt
106+ #build_style themes/oscar/less/pointhi/oscar.less themes/oscar/css/pointhi.min.css
107+ #build_style themes/oscar/less/logicodev/oscar.less themes/oscar/css/logicodev.min.css
108+ #build_style themes/simple/less/style.less themes/simple/css/searx.min.css
109+ #build_style themes/simple/less/style-rtl.less themes/simple/css/searx-rtl.min.css
110+}
111+
112+npm_packages() {
113+ echo '[!] install NPM packages for oscar theme'
114+ cd $BASE_DIR/searx/static/themes/oscar
115+ npm install
116+
117+ echo '[!] install NPM packages for simple theme'
118+ cd $BASE_DIR/searx/static/themes/simple
119+ npm install
98120}
99121
100122grunt_build() {
101− grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
102− grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
123+ echo '[!] Grunt build : oscar theme'
124+ grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js"
125+ echo '[!] Grunt build : simple theme'
126+ grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js"
103127}
104128
105129locales() {
106− pybabel compile -d "$SEARX_DIR/translations"
130+ pybabel compile -d "$SEARX_DIR/translations"
107131}
108132
109133help() {
@@ -112,6 +136,7 @@ help() {
112136
113137Commands
114138========
139+ npm_packages - Download & install dependencies
115140 grunt_build - Build js files
116141 help - This text
117142 locales - Compile locales
@@ -123,10 +148,10 @@ Commands
123148 unit_tests - Run unit tests
124149 update_dev_packages - Check & update development and production dependency changes
125150 update_packages - Check & update dependency changes
126− check_geckodriver - Check & download geckodriver (required for robot_tests)
151+ install_geckodriver - Download & install geckodriver if not already installed (required for robot_tests)
127152"
128153}
129154
130155[ "$(command -V "$ACTION" | grep ' function$')" = "" ] \
131156 && help "action not found" \
132− || $ACTION
157+ || $ACTION "$2"