From edfd069d162c69936926dc149dbea26c4f1f9b88 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 29 Dec 2021 10:16:30 +0100 Subject: [mod] manage: add themes.live command (rebuild on modification) To have a live build while editing the HTML client of a theme. The first argument of the command is the theme name: ./manage themes.live simple Signed-off-by: Markus Heiser --- manage | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) (limited to 'manage') diff --git a/manage b/manage index 8eb347f4f..08245a9b4 100755 --- a/manage +++ b/manage @@ -511,12 +511,15 @@ gecko.driver() { dump_return $? } -node.env() { +nodejs.ensure() { if ! nvm.min_node "${NODE_MINIMUM_VERSION}"; then info_msg "install Node.js by NVM" nvm.nodejs fi +} +node.env() { + nodejs.ensure ( set -e build_msg INSTALL "searx/static/themes/oscar/package.json" @@ -698,6 +701,30 @@ themes.all() { dump_return $? } +themes.live() { + local LIVE_THEME="${LIVE_THEME:-${1}}" + case "${LIVE_THEME}" in + simple|oscar) + theme="searx/static/themes/${LIVE_THEME}" + ;; + '') + die_caller 42 "missing theme argument" + ;; + *) + die_caller 42 "unknown theme '${LIVE_THEME}' // [simple|oscar]'" + ;; + 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.oscar() { build_msg GRUNT "theme: oscar" npm --prefix searx/static/themes/oscar run build @@ -715,10 +742,7 @@ themes.simple() { themes.simple.test() { build_msg TEST "theme: simple" - if ! nvm.min_node "${NODE_MINIMUM_VERSION}"; then - info_msg "install Node.js by NVM" - nvm.nodejs - fi + nodejs.ensure npm --prefix searx/static/themes/simple install npm --prefix searx/static/themes/simple run test dump_return $? -- cgit v1.2.3 From 1706b130a4eaa8bf493758ef69eca4e7e83a2fbf Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 29 Dec 2021 10:18:02 +0100 Subject: [fix] remove leftover from 59f4c792 Signed-off-by: Markus Heiser --- manage | 1 - 1 file changed, 1 deletion(-) (limited to 'manage') diff --git a/manage b/manage index 08245a9b4..4dfc69782 100755 --- a/manage +++ b/manage @@ -732,7 +732,6 @@ themes.oscar() { } themes.simple() { - local static="searx/static/themes/simple" ( set -e build_msg GRUNT "theme: simple" npm --prefix searx/static/themes/simple run build -- cgit v1.2.3 From c7f274041445f12a50204d1920065b58d5a21613 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 29 Dec 2021 21:28:25 +0100 Subject: [mod] live build of a theme: LIVE_THEME=simple make run Environment variable to get live builds while modifying CSS & JS of a theme:: LIVE_THEME=simple make run Signed-off-by: Markus Heiser --- manage | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'manage') diff --git a/manage b/manage index 4dfc69782..fa33a2e28 100755 --- a/manage +++ b/manage @@ -117,6 +117,17 @@ fi # needed by sphinx-docs export DOCS_BUILD +webapp.run() { + SEARXNG_DEBUG=1 pyenv.cmd python -m searx.webapp & + sleep 3 + if [ "${LIVE_THEME}" ]; then + themes.live "${LIVE_THEME}" & + fi + xdg-open http://127.0.0.1:8888/ + wait -n + kill 0 +} + buildenv() { # settings file from repository's working tree are used by default -- cgit v1.2.3