From 04c687403e21f883f9614e6a24df9ec450cfc111 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 25 Mar 2020 11:49:33 +0100 Subject: [fix] brands: add variables from build env to jinja templating We have some variables in the build environment which are also needed in the templating process. Theses variables are relavant if one creates a fork with its own branding. We treat these variables under the term 'brands'. Signed-off-by: Markus Heiser --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5a47129e4..3b2d499e8 100644 --- a/Makefile +++ b/Makefile @@ -71,15 +71,22 @@ $(GH_PAGES):: # update project files # -------------------- -PHONY += project engines-languages +PHONY += project engines-languages searx.brand -project: searx/data/engines_languages.json +project: searx/data/engines_languages.json searx.brand -searx/data/engines_languages.json: pyenvinstall +engines-languages: pyenvinstall $(PY_ENV_ACT); python utils/fetch_languages.py mv engines_languages.json searx/data/engines_languages.json mv languages.py searx/languages.py +searx.brand: + $(Q)echo "build searx/brand.py" + $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py + $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py + $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py + $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py + # test # ---- -- cgit v1.2.3 From 757ebb5d9fdc24757f199e52575f32f6faf091b3 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 25 Mar 2020 14:09:47 +0100 Subject: [fix] brands: add variables from build env to grunt process We have some variables in the build environment which are also needed in the grunt process when building themes. Theses variables are relavant if one creates a fork with its own branding. We treat these variables under the term 'brands'. Signed-off-by: Markus Heiser --- Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3b2d499e8..4914a309e 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ help: @echo ' gh-pages - build docs & deploy on gh-pages branch' @echo ' clean - drop builds and environments' @echo ' project - re-build generic files of the searx project' + @echo ' themes - re-build build the source of the themes' @echo '' @$(MAKE) -s -f utils/makefile.include make-help @echo '' @@ -87,6 +88,20 @@ searx.brand: $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py +# build themes +# ------------ + +PHONY += themes themes.oscar themes.simple +themes: themes.oscar themes.simple + +themes.oscar: + $(Q)echo '[!] Grunt build : oscar theme' + $(Q)grunt --gruntfile "searx/static/themes/oscar/gruntfile.js" + +themes.simple: + $(Q)echo '[!] Grunt build : simple theme' + $(Q)grunt --gruntfile "searx/static/themes/simple/gruntfile.js" + # test # ---- -- cgit v1.2.3 From 3dbade0aed048e6001f2ed0f261c7d26f04768ba Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 25 Mar 2020 14:50:39 +0100 Subject: [fix] brands: add GIT_URL variable to the docker build Signed-off-by: Markus Heiser --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4914a309e..f81b4e1de 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,7 @@ help: @echo ' clean - drop builds and environments' @echo ' project - re-build generic files of the searx project' @echo ' themes - re-build build the source of the themes' + @echo ' docker - build Docker image' @echo '' @$(MAKE) -s -f utils/makefile.include make-help @echo '' @@ -102,6 +103,14 @@ themes.simple: $(Q)echo '[!] Grunt build : simple theme' $(Q)grunt --gruntfile "searx/static/themes/simple/gruntfile.js" +# docker +# ------ + +PHONY += docker +docker: + $(Q)./manage.sh docker_build + + # test # ---- -- cgit v1.2.3 From d471ec86dd72cfae80bdaf72b1ed266b1a8cada7 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 25 Mar 2020 16:38:52 +0100 Subject: Makefile: add target node.env - download & install npm dependencies Signed-off-by: Markus Heiser --- Makefile | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index f81b4e1de..5796ae668 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ help: @echo ' project - re-build generic files of the searx project' @echo ' themes - re-build build the source of the themes' @echo ' docker - build Docker image' + @echo ' node.env - download & install npm dependencies locally' @echo '' @$(MAKE) -s -f utils/makefile.include make-help @echo '' @@ -42,7 +43,7 @@ PHONY += uninstall uninstall: pyenvuninstall PHONY += clean -clean: pyclean +clean: pyclean node.clean $(call cmd,common_clean) PHONY += run @@ -89,6 +90,22 @@ searx.brand: $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py +# node / npm +# ---------- + +node.env: + $(Q)./manage.sh npm_packages + +node.clean: + $(Q)echo "CLEAN locally installed npm dependencies" + $(Q)rm -rf \ + ./node_modules \ + ./package-lock.json \ + ./searx/static/themes/oscar/package-lock.json \ + ./searx/static/themes/oscar/node_modules \ + ./searx/static/themes/simple/package-lock.json \ + ./searx/static/themes/simple/node_modules + # build themes # ------------ @@ -97,11 +114,11 @@ themes: themes.oscar themes.simple themes.oscar: $(Q)echo '[!] Grunt build : oscar theme' - $(Q)grunt --gruntfile "searx/static/themes/oscar/gruntfile.js" + $(Q)PATH="$$(npm bin):$$PATH" grunt --gruntfile "searx/static/themes/oscar/gruntfile.js" themes.simple: $(Q)echo '[!] Grunt build : simple theme' - $(Q)grunt --gruntfile "searx/static/themes/simple/gruntfile.js" + $(Q)PATH="$$(npm bin):$$PATH" grunt --gruntfile "searx/static/themes/simple/gruntfile.js" # docker # ------ -- cgit v1.2.3 From 33814719333c2c5b7b13ab47f9c8d4f8a0cecb16 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 25 Mar 2020 17:48:34 +0100 Subject: brands: add ISSUE_URL Signed-off-by: Markus Heiser --- Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5796ae668..bdaa6c774 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ # -*- coding: utf-8; mode: makefile-gmake -*- export GIT_URL=https://github.com/asciimoo/searx +export ISSUE_URL=$(GIT_URL)/issues export SEARX_URL=https://searx.me export DOCS_URL=https://asciimoo.github.io/searx @@ -86,6 +87,7 @@ engines-languages: pyenvinstall searx.brand: $(Q)echo "build searx/brand.py" $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py + $(Q)echo "ISSUE_URL = '$(ISSUE_URL)'" >> searx/brand.py $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py -- cgit v1.2.3 From 3486613a1960f472b9cf8c85ade72c5aec9473eb Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 26 Mar 2020 10:58:25 +0100 Subject: brands: hardcode ISSUE_URL and some links on the about-page A *brand* of searx is a fork which might have its own design and some special functions which might bee reasonable in a special context. In this sense, the fork might have its own documentation but not its own issue tracker. The *upstream* of a brand is always https://github.com/asciimoo from where the brand-fork pulls the master branch regularly. A fork which has its own issue tracker is a spin-off and out of the scope of the searx project itself. The conclusion is: - hard code ISSUE_URL (in the Makefile) - always refer to DOCS_URL - links in the about page refer to the *upstream* (searx project) except DOCS_URL - "fork me on github" ribbons refer to the *upstream* Signed-off-by: Markus Heiser --- Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index bdaa6c774..2bea06c9d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,6 @@ # -*- coding: utf-8; mode: makefile-gmake -*- export GIT_URL=https://github.com/asciimoo/searx -export ISSUE_URL=$(GIT_URL)/issues export SEARX_URL=https://searx.me export DOCS_URL=https://asciimoo.github.io/searx @@ -87,7 +86,7 @@ engines-languages: pyenvinstall searx.brand: $(Q)echo "build searx/brand.py" $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py - $(Q)echo "ISSUE_URL = '$(ISSUE_URL)'" >> searx/brand.py + $(Q)echo "ISSUE_URL = 'https://github.com/asciimoo/searx/issues'" >> searx/brand.py $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py -- cgit v1.2.3 From 00251d7c66e60dc9859bf6368ab68d545660b90e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 26 Mar 2020 13:32:08 +0100 Subject: Makefile: add target 'useragents.update' to fetch versions of Firefox Update searx/data/useragents.json with the most recent versions of Firefox. BTW: add 'useragents.update' to 'project' target and clean up the Makefile and remove it from the manage.sh script. Signed-off-by: Markus Heiser closes: https://github.com/asciimoo/searx/issues/1882 --- Makefile | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2bea06c9d..89e83dc59 100644 --- a/Makefile +++ b/Makefile @@ -74,14 +74,21 @@ $(GH_PAGES):: # update project files # -------------------- -PHONY += project engines-languages searx.brand +PHONY += project engines.languages searx.brand useragents.update -project: searx/data/engines_languages.json searx.brand +project: useragents.update engines.languages searx.brand -engines-languages: pyenvinstall - $(PY_ENV_ACT); python utils/fetch_languages.py - mv engines_languages.json searx/data/engines_languages.json - mv languages.py searx/languages.py +engines.languages: pyenvinstall + $(Q)echo "fetch languages .." + $(Q)$(PY_ENV_ACT); python utils/fetch_languages.py + $(Q)echo "update searx/data/engines_languages.json" + $(Q)mv engines_languages.json searx/data/engines_languages.json + $(Q)echo "update searx/languages.py" + $(Q)mv languages.py searx/languages.py + +useragents.update: pyenvinstall + $(Q)echo "Update searx/data/useragents.json with the most recent versions of Firefox." + $(Q)$(PY_ENV_ACT); python utils/fetch_firefox_version.py searx.brand: $(Q)echo "build searx/brand.py" -- cgit v1.2.3 From e7fbefa8bdecca04824b3ef744786d8bb45c35fe Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 26 Mar 2020 18:00:07 +0100 Subject: build: move build styles from manage.sh to Makefile To build all styles use: make styles To build individual styles use one of: make style.legacy make style.courgette make style.pixart make style.bootstrap Signed-off-by: Markus Heiser --- Makefile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 89e83dc59..8b760093b 100644 --- a/Makefile +++ b/Makefile @@ -128,6 +128,31 @@ themes.simple: $(Q)echo '[!] Grunt build : simple theme' $(Q)PATH="$$(npm bin):$$PATH" grunt --gruntfile "searx/static/themes/simple/gruntfile.js" +# build styles +# ------------ + +PHONY += styles style.legacy style.courgette style.pixart style.bootstrap +styles: style.legacy style.courgette style.pixart style.bootstrap + +quiet_cmd_lessc = STYLE $3 + cmd_lessc = PATH="$$(npm bin):$$PATH" \ + lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3" + +style.legacy: + $(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css) + $(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css) + +style.courgette: + $(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css) + $(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css) + +style.pixart: + $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css) + +style.bootstrap: + $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css) + + # docker # ------ -- cgit v1.2.3 From 1075f58a722fad7801a7b8397cd7e6de31d99da2 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Thu, 26 Mar 2020 18:41:45 +0100 Subject: test: move tests from manage.sh to Makefile Signed-off-by: Markus Heiser --- Makefile | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 8b760093b..fe65acade 100644 --- a/Makefile +++ b/Makefile @@ -43,7 +43,7 @@ PHONY += uninstall uninstall: pyenvuninstall PHONY += clean -clean: pyclean node.clean +clean: pyclean node.clean test.clean $(call cmd,common_clean) PHONY += run @@ -160,27 +160,52 @@ PHONY += docker docker: $(Q)./manage.sh docker_build +# gecko +# ----- + +PHONY += gecko.driver +gecko.driver: + $(PY_ENV_ACT); ./manage.sh install_geckodriver # test # ---- -PHONY += test test.pylint test.pep8 test.unit test.robot +PHONY += test test.pylint test.pep8 test.unit test.coverage test.robot -test: test.pylint test.pep8 test.unit test.robot +test: test.pylint test.pep8 test.unit gecko.driver test.robot # TODO: balance linting with pylint test.pylint: pyenvinstall - $(call cmd,pylint,searx/preferences.py) - $(call cmd,pylint,searx/testing.py) + $(call cmd,pylint,\ + searx/preferences.py \ + searx/testing.py \ + ) + +# ignored rules: +# E402 module level import not at top of file +# W503 line break before binary operator test.pep8: pyenvinstall - $(PY_ENV_ACT); ./manage.sh pep8_check + @echo "TEST pep8" + $(Q)$(PY_ENV_ACT); pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" searx tests test.unit: pyenvinstall - $(PY_ENV_ACT); ./manage.sh unit_tests - -test.robot: pyenvinstall - $(PY_ENV_ACT); ./manage.sh install_geckodriver - $(PY_ENV_ACT); ./manage.sh robot_tests + @echo "TEST tests/unit" + $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit + +test.coverage: pyenvinstall + @echo "TEST unit test coverage" + $(Q)$(PY_ENV_ACT); \ + python -m nose2 -C --log-capture --with-coverage --coverage searx -s tests/unit \ + && coverage report \ + && coverage html \ + +test.robot: pyenvinstall gecko.driver + @echo "TEST robot" + $(Q)$(PY_ENV_ACT); PYTHONPATH=. python searx/testing.py robot + +test.clean: + @echo "CLEAN intermediate test stuff" + $(Q)rm -rf geckodriver.log .coverage coverage/ .PHONY: $(PHONY) -- cgit v1.2.3 From 8a16903a1ca980fc3c670e304067c9e68eb59a25 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 29 Mar 2020 11:29:57 +0200 Subject: make themes: rename 'style' targtes to 'themes' targets style.legacy could be renamed themes.legacy : it actually builds the files for the legacy theme, then themes.legacy can be a dependency of themes. Same for the other styles.* Debatable: about style.bootstrap, same convention : theme.bootstrap (even it is more a toolbox for the oscar theme). So there is no need to add the missing make styles in the help target. thanks @dalf: - https://github.com/asciimoo/searx/pull/1900#discussion_r399160355 Signed-off-by: Markus Heiser --- Makefile | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index fe65acade..5b890374e 100644 --- a/Makefile +++ b/Makefile @@ -117,39 +117,40 @@ node.clean: # build themes # ------------ -PHONY += themes themes.oscar themes.simple -themes: themes.oscar themes.simple +PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart +themes: themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart -themes.oscar: - $(Q)echo '[!] Grunt build : oscar theme' - $(Q)PATH="$$(npm bin):$$PATH" grunt --gruntfile "searx/static/themes/oscar/gruntfile.js" - -themes.simple: - $(Q)echo '[!] Grunt build : simple theme' - $(Q)PATH="$$(npm bin):$$PATH" grunt --gruntfile "searx/static/themes/simple/gruntfile.js" +quiet_cmd_lessc = LESSC $3 + cmd_lessc = PATH="$$(npm bin):$$PATH" \ + lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3" -# build styles -# ------------ +quiet_cmd_grunt = GRUNT $2 + cmd_grunt = PATH="$$(npm bin):$$PATH" \ + grunt --gruntfile "$2" -PHONY += styles style.legacy style.courgette style.pixart style.bootstrap -styles: style.legacy style.courgette style.pixart style.bootstrap +themes.oscar: + $(Q)echo '[!] build oscar theme' + $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js) -quiet_cmd_lessc = STYLE $3 - cmd_lessc = PATH="$$(npm bin):$$PATH" \ - lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3" +themes.simple: + $(Q)echo '[!] build simple theme' + $(call cmd,grunt,searx/static/themes/simple/gruntfile.js) -style.legacy: +themes.legacy: + $(Q)echo '[!] build legacy theme' $(call cmd,lessc,themes/legacy/less/style-rtl.less,themes/legacy/css/style-rtl.css) $(call cmd,lessc,themes/legacy/less/style.less,themes/legacy/css/style.css) -style.courgette: +themes.courgette: + $(Q)echo '[!] build courgette theme' $(call cmd,lessc,themes/courgette/less/style.less,themes/courgette/css/style.css) $(call cmd,lessc,themes/courgette/less/style-rtl.less,themes/courgette/css/style-rtl.css) -style.pixart: +themes.pixart: + $(Q)echo '[!] build pixart theme' $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css) -style.bootstrap: +themes.bootstrap: $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css) -- cgit v1.2.3 From 442b27ac1b1f54669fbb9785d780327f62814431 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 29 Mar 2020 11:41:59 +0200 Subject: bash: use build environment from Makefile To Makefile target brand, add creation of bash environment in:: utils/brand.env In bash scripts (manage.sh) source env by:: . utils/brand.env manage.sh help: show GIT_URL and more environment Signed-off-by: Markus Heiser --- Makefile | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 5b890374e..d09e92828 100644 --- a/Makefile +++ b/Makefile @@ -97,6 +97,13 @@ searx.brand: $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py + $(Q)echo "build utils/brand.env" + $(Q)echo "export GIT_URL='$(GIT_URL)'" > utils/brand.env + $(Q)echo "export ISSUE_URL='https://github.com/asciimoo/searx/issues'" >> utils/brand.env + $(Q)echo "export SEARX_URL='$(SEARX_URL)'" >> utils/brand.env + $(Q)echo "export DOCS_URL='$(DOCS_URL)'" >> utils/brand.env + $(Q)echo "export PUBLIC_INSTANCES='https://searx.space'" >> utils/brand.env + # node / npm # ---------- -- cgit v1.2.3