Browse Source

[web-client] integrate the migrated theme in the development workflows

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Markus Heiser 3 months ago
parent
commit
2bf77f5d2d

+ 0 - 1
Makefile

@@ -85,7 +85,6 @@ MANAGE += pyenv pyenv.install pyenv.uninstall
 MANAGE += format.python
 MANAGE += format.python
 MANAGE += test.yamllint test.pylint test.black test.pybabel test.unit test.coverage test.robot test.rst test.clean test.themes test.types.dev test.types.ci
 MANAGE += test.yamllint test.pylint test.black test.pybabel test.unit test.coverage test.robot test.rst test.clean test.themes test.types.dev test.types.ci
 MANAGE += themes.all themes.fix themes.test
 MANAGE += themes.all themes.fix themes.test
-MANAGE += themes.simple themes.simple.pygments themes.simple.fix
 MANAGE += static.build.commit static.build.drop static.build.restore
 MANAGE += static.build.commit static.build.drop static.build.restore
 MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs
 MANAGE += nvm.install nvm.clean nvm.status nvm.nodejs
 
 

+ 2 - 1
client/simple/package.json

@@ -3,7 +3,8 @@
   "version": "1.0.0",
   "version": "1.0.0",
   "type": "module",
   "type": "module",
   "scripts": {
   "scripts": {
-    "build": "vite build",
+    "clean": "rm -Rf node_modules",
+    "build": "node theme_icons.js && vite build",
     "fix": "eslint --fix && stylelint --fix strict 'src/**/*.{css,scss,sass,less,styl,vue,svelte}'",
     "fix": "eslint --fix && stylelint --fix strict 'src/**/*.{css,scss,sass,less,styl,vue,svelte}'",
     "icons.html": "node theme_icons.js"
     "icons.html": "node theme_icons.js"
   },
   },

+ 1 - 1
docs/admin/settings/settings_ui.rst

@@ -44,7 +44,7 @@
 ``center_alignment`` : default ``false``
 ``center_alignment`` : default ``false``
   When enabled, the results are centered instead of being in the left (or RTL)
   When enabled, the results are centered instead of being in the left (or RTL)
   side of the screen.  This setting only affects the *desktop layout*
   side of the screen.  This setting only affects the *desktop layout*
-  (:origin:`min-width: @tablet <searx/static/themes/simple/src/less/definitions.less>`)
+  (:origin:`min-width: @tablet <client/simple/src/less/definitions.less>`)
 
 
 .. cache_url:
 .. cache_url:
 
 

+ 1 - 1
docs/conf.py

@@ -197,7 +197,7 @@ html_sidebars = {
     ],
     ],
 }
 }
 singlehtml_sidebars = {"index": ["project.html", "localtoc.html"]}
 singlehtml_sidebars = {"index": ["project.html", "localtoc.html"]}
-html_logo = "../src/brand/searxng-wordmark.svg"
+html_logo = "../client/simple/src/brand/searxng-wordmark.svg"
 html_title = "SearXNG Documentation ({})".format(VERSION_STRING)
 html_title = "SearXNG Documentation ({})".format(VERSION_STRING)
 html_show_sourcelink = True
 html_show_sourcelink = True
 
 

+ 6 - 3
docs/dev/makefile.rst

@@ -180,10 +180,13 @@ sources of the theme need to be rebuild.  You can do that by running::
 
 
   $ make themes.all
   $ make themes.all
 
 
-Alternatively to ``themes.all`` you can run *live builds* of the theme you are
+..
-modify (:ref:`make themes`)::
+   ToDo: vite server is not implemented yet / will be done in a follow up PR
 
 
-  $ LIVE_THEME=simple make run
+   Alternatively to ``themes.all`` you can run *live builds* of the theme you are
+   modify (:ref:`make themes`)::
+
+    $ LIVE_THEME=simple make run
 
 
 .. _make format.python:
 .. _make format.python:
 
 

+ 12 - 0
manage

@@ -314,6 +314,18 @@ format.python() {
     dump_return $?
     dump_return $?
 }
 }
 
 
+docs.prebuild() {
+    build_msg DOCS "build ${DOCS_BUILD}/includes"
+    (
+        set -e
+        [ "$VERBOSE" = "1" ] && set -x
+        mkdir -p "${DOCS_BUILD}/includes"
+        ./utils/searxng.sh searxng.doc.rst >  "${DOCS_BUILD}/includes/searxng.rst"
+        pyenv.cmd searxng_extra/docs_prebuild
+    )
+    dump_return $?
+}
+
 # shellcheck disable=SC2119
 # shellcheck disable=SC2119
 main() {
 main() {
 
 

+ 0 - 12
utils/lib_sxng_data.sh

@@ -59,15 +59,3 @@ data.locales() {
     )
     )
     dump_return $?
     dump_return $?
 }
 }
-
-docs.prebuild() {
-    build_msg DOCS "build ${DOCS_BUILD}/includes"
-    (
-        set -e
-        [ "$VERBOSE" = "1" ] && set -x
-        mkdir -p "${DOCS_BUILD}/includes"
-        ./utils/searxng.sh searxng.doc.rst >  "${DOCS_BUILD}/includes/searxng.rst"
-        pyenv.cmd searxng_extra/docs_prebuild
-    )
-    dump_return $?
-}

+ 3 - 3
utils/lib_sxng_node.sh

@@ -25,8 +25,8 @@ nodejs.ensure() {
 node.env() {
 node.env() {
     nodejs.ensure
     nodejs.ensure
     (   set -e
     (   set -e
-        build_msg INSTALL "[npm] ./searx/static/themes/simple/package.json"
+        build_msg INSTALL "[npm] ./client/simple/package.json"
-        npm --prefix searx/static/themes/simple install
+        npm --prefix client/simple install
     )
     )
     dump_return $?
     dump_return $?
 }
 }
@@ -44,7 +44,7 @@ node.clean() {
     fi
     fi
     build_msg CLEAN "themes -- locally installed npm dependencies"
     build_msg CLEAN "themes -- locally installed npm dependencies"
     (   set -e
     (   set -e
-        npm --prefix searx/static/themes/simple run clean \
+        npm --prefix client/simple run clean \
 	    | prefix_stdout "${_Blue}CLEAN    ${_creset} "
 	    | prefix_stdout "${_Blue}CLEAN    ${_creset} "
 	if [ "${PIPESTATUS[0]}" -ne "0" ]; then
 	if [ "${PIPESTATUS[0]}" -ne "0" ]; then
             return 1
             return 1

+ 2 - 7
utils/lib_sxng_static.sh

@@ -4,12 +4,7 @@
 
 
 STATIC_BUILD_COMMIT="[build] /static"
 STATIC_BUILD_COMMIT="[build] /static"
 STATIC_BUILT_PATHS=(
 STATIC_BUILT_PATHS=(
-    'searx/static/themes/simple/css'
+    'searx/static/themes/simple'
-    'searx/static/themes/simple/js'
-    'searx/static/themes/simple/src/generated/pygments.less'
-    'searx/static/themes/simple/img'
-    'searx/templates/simple/searxng-wordmark.min.svg'
-    'searx/templates/simple/icons.html'
 )
 )
 
 
 static.help(){
 static.help(){
@@ -101,7 +96,7 @@ static.build.commit() {
 
 
     (   set -e
     (   set -e
         # fix & build the themes
         # fix & build the themes
-	themes.fix
+	    themes.fix
         themes.all
         themes.all
 
 
         # add build files
         # add build files

+ 7 - 71
utils/lib_sxng_themes.sh

@@ -1,100 +1,36 @@
 #!/usr/bin/env bash
 #!/usr/bin/env bash
 # SPDX-License-Identifier: AGPL-3.0-or-later
 # SPDX-License-Identifier: AGPL-3.0-or-later
 
 
-declare _Blue
-declare _creset
-
 themes.help(){
 themes.help(){
     cat <<EOF
     cat <<EOF
 themes.:
 themes.:
   all       : test & build all themes
   all       : test & build all themes
   test      : test all themes
   test      : test all themes
   fix       : fix JS & CSS (LESS)
   fix       : fix JS & CSS (LESS)
-  live      : to get live builds of CSS & JS use: LIVE_THEME=simple make run
-  simple.:    test & build simple theme ..
-    pygments: build pygment's LESS files for simple theme
-    test    : test simple theme
-    fix     : fix JS & CSS (LESS) of the simple theme
 EOF
 EOF
 }
 }
 
 
 themes.all() {
 themes.all() {
     (   set -e
     (   set -e
-        node.env
+        build_msg SIMPLE "theme: run build"
-        themes.simple
+        vite.simple.build
     )
     )
     dump_return $?
     dump_return $?
 }
 }
 
 
 themes.fix() {
 themes.fix() {
     (   set -e
     (   set -e
-        node.env
+        build_msg SIMPLE "theme: fix"
-        themes.simple.fix
+        vite.simple.fix
     )
     )
     dump_return $?
     dump_return $?
 }
 }
 
 
 themes.test() {
 themes.test() {
     (   set -e
     (   set -e
-        node.env
+        # we run a build to test (in CI)
-        themes.simple.test
+        build_msg SIMPLE "theme: run build (to test)"
-    )
+        vite.simple.build
-    dump_return $?
-}
-
-themes.live() {
-    local LIVE_THEME="${LIVE_THEME:-${1}}"
-    case "${LIVE_THEME}" in
-        simple)
-            theme="searx/static/themes/${LIVE_THEME}"
-            ;;
-        '')
-            die 42 "missing theme argument"
-            ;;
-        *)
-            die 42 "unknown theme '${LIVE_THEME}' // [simple]'"
-            ;;
-    esac
-    build_msg SIMPLE "theme: $1 (live build)"
-    node.env
-    themes.simple.pygments
-    cd "${theme}"
-    {
-        npm run watch
-    } # 2>&1 \
-      #       | prefix_stdout "${_Blue}THEME ${1} ${_creset}  " \
-      #       | grep -E --ignore-case --color 'error[s]?[:]? |warning[s]?[:]? |'
-}
-
-themes.simple() {
-    (   set -e
-        themes.simple.pygments
-        build_msg SIMPLE "theme: run build"
-        # "run build" includes tests from eslint and stylelint
-        npm --prefix searx/static/themes/simple run build
     )
     )
     dump_return $?
     dump_return $?
 }
 }
-
-themes.simple.pygments() {
-    build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
-    pyenv.cmd python searxng_extra/update/update_pygments.py \
-        | prefix_stdout "${_Blue}PYGMENTS ${_creset} "
-    if [ "${PIPESTATUS[0]}" -ne "0" ]; then
-        build_msg PYGMENTS "building LESS files for pygments failed"
-        return 1
-    fi
-    return 0
-}
-
-themes.simple.fix() {
-    build_msg SIMPLE "theme: fix"
-    npm --prefix searx/static/themes/simple run fix
-    dump_return $?
-}
-
-themes.simple.test() {
-    build_msg SIMPLE "theme: run test"
-    npm --prefix searx/static/themes/simple run test
-    dump_return $?
-}

+ 34 - 15
utils/lib_sxng_vite.sh

@@ -1,6 +1,8 @@
 #!/usr/bin/env bash
 #!/usr/bin/env bash
 # SPDX-License-Identifier: AGPL-3.0-or-later
 # SPDX-License-Identifier: AGPL-3.0-or-later
 
 
+declare _Blue
+declare _creset
 
 
 vite.help(){
 vite.help(){
     cat <<EOF
     cat <<EOF
@@ -12,25 +14,24 @@ EOF
 }
 }
 
 
 VITE_SIMPLE_THEME="${REPO_ROOT}/client/simple"
 VITE_SIMPLE_THEME="${REPO_ROOT}/client/simple"
-VITE_SIMPLE_DIST="${REPO_ROOT}/searx/static/themes/simple"
 
 
-vite.simple.dev() {
+# ToDo: vite server is not implemented yet / will be done in a follow up PR
-
+#
-    (   set -e
+# vite.simple.dev() {
-        build_msg SIMPLE "start server for FE development of: ${VITE_SIMPLE_THEME}"
+#     (   set -e
-        pushd "${VITE_SIMPLE_THEME}"
+#         build_msg SIMPLE "start server for FE development of: ${VITE_SIMPLE_THEME}"
-        npm install
+#         pushd "${VITE_SIMPLE_THEME}"
-        npm exec -- vite
+#         npm install
-        popd &> /dev/null
+#         npm exec -- vite
-    )
+#         popd &> /dev/null
-
+#     )
-}
+# }
 
 
 vite.simple.build() {
 vite.simple.build() {
-
-    # build static files of the simple theme
-
     (   set -e
     (   set -e
+        templates.simple.pygments
+
+        node.env
         build_msg SIMPLE "run build of theme from: ${VITE_SIMPLE_THEME}"
         build_msg SIMPLE "run build of theme from: ${VITE_SIMPLE_THEME}"
 
 
         pushd "${VITE_SIMPLE_THEME}"
         pushd "${VITE_SIMPLE_THEME}"
@@ -38,6 +39,24 @@ vite.simple.build() {
         npm run fix
         npm run fix
         npm run icons.html
         npm run icons.html
         npm run build
         npm run build
+        popd &> /dev/null
+    )
+}
 
 
+vite.simple.fix() {
+    (   set -e
+        node.env
+        npm --prefix client/simple run fix
     )
     )
 }
 }
+
+templates.simple.pygments() {
+    build_msg PYGMENTS "searxng_extra/update/update_pygments.py"
+    pyenv.cmd python searxng_extra/update/update_pygments.py \
+        | prefix_stdout "${_Blue}PYGMENTS ${_creset} "
+    if [ "${PIPESTATUS[0]}" -ne "0" ]; then
+        build_msg PYGMENTS "building LESS files for pygments failed"
+        return 1
+    fi
+    return 0
+}