From f25da6070e398f17c24b194c8688595050dc473c Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 3 Mar 2020 16:26:02 +0100 Subject: [PATCH] docs: generic documentation get templating Signed-off-by: Markus Heiser --- docs/build-templates/searx.rst | 159 ++++++++++++++++++++++++++++++++ docs/conf.py | 2 + utils/searx.sh | 162 +-------------------------------- 3 files changed, 162 insertions(+), 161 deletions(-) create mode 100644 docs/build-templates/searx.rst diff --git a/docs/build-templates/searx.rst b/docs/build-templates/searx.rst new file mode 100644 index 000000000..9e33928ad --- /dev/null +++ b/docs/build-templates/searx.rst @@ -0,0 +1,159 @@ +.. template evaluated by: ./utils/searx.sh docs +.. hint: all dollar-names are variables, dollar sign itself is quoted by: \\$ + +.. START distro-packages + +.. tabs:: + + .. group-tab:: Ubuntu / debian + + .. code-block:: sh + + $ sudo -H apt-get install -y \\ +${debian} + + .. group-tab:: Arch Linux + + .. code-block:: sh + + $ sudo -H pacman -S --noconfirm \\ +${arch} + + .. group-tab:: Fedora / RHEL + + .. code-block:: sh + + $ sudo -H dnf install -y \\ +${fedora} + +.. END distro-packages + + +.. START create user + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + $ sudo -H useradd --shell /bin/bash --system \\ + --home-dir "$SERVICE_HOME" \\ + --comment "Privacy-respecting metasearch engine" $SERVICE_USER + + $ sudo -H mkdir "$SERVICE_HOME" + $ sudo -H chown -R "$SERVICE_GROUP:$SERVICE_GROUP" "$SERVICE_HOME" + +.. END create user + +.. START clone searx + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + $ sudo -H -u ${SERVICE_USER} -i + (${SERVICE_USER})$ git clone "https://github.com/asciimoo/searx.git" "$SEARX_SRC" + +.. END clone searx + +.. START create virtualenv + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + (${SERVICE_USER})$ python3 -m venv "${SEARX_PYENV}" + (${SERVICE_USER})$ echo ". ${SEARX_PYENV}/bin/activate" >> "$SERVICE_HOME/.profile" + +.. END create virtualenv + +.. START manage.sh update_packages + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + $ sudo -H -u ${SERVICE_USER} -i + + (${SERVICE_USER})$ command -v python && python --version + $SEARX_PYENV/bin/python + Python 3.8.1 + + (${SERVICE_USER})$ cd "$SEARX_SRC" + (${SERVICE_USER})$ ./manage.sh update_packages + +.. END manage.sh update_packages + +.. START searx config + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + $ sudo -H cp "$SEARX_SRC/searx/settings.yml" "${SEARX_SETTINGS_PATH}" + $ sudo -H sed -i -e "s/ultrasecretkey/\\$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH" + $ sudo -H sed -i -e "s/{instance_name}/searx@\\$(uname -n)/g" "$SEARX_SETTINGS_PATH" + +.. END searx config + +.. START check searx installation + +.. tabs:: + + .. group-tab:: bash + + .. code-block:: sh + + # enable debug .. + $ sudo -H sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH" + + # start webapp + $ sudo -H -u ${SERVICE_USER} -i + (${SERVICE_USER})$ cd ${SEARX_SRC} + (${SERVICE_USER})$ export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" + (${SERVICE_USER})$ python searx/webapp.py + + # disable debug + $ sudo -H sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH" + +Open WEB browser and visit http://$SEARX_INTERNAL_URL . If you are inside a +container or in a script, test with curl: + +.. tabs:: + + .. group-tab:: WEB browser + + .. code-block:: sh + + $ xgd-open http://$SEARX_INTERNAL_URL + + .. group-tab:: curl + + .. code-block:: none + + $ curl --location --verbose --head --insecure $SEARX_INTERNAL_URL + + * Trying 127.0.0.1:8888... + * TCP_NODELAY set + * Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0) + > HEAD / HTTP/1.1 + > Host: 127.0.0.1:8888 + > User-Agent: curl/7.68.0 + > Accept: */* + > + * Mark bundle as not supporting multiuse + * HTTP 1.0, assume close after body + < HTTP/1.0 200 OK + HTTP/1.0 200 OK + ... + +.. END check searx installation diff --git a/docs/conf.py b/docs/conf.py index 8f11b1c6c..6a6633341 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -23,6 +23,8 @@ master_doc = "index" source_suffix = '.rst' numfig = True +exclude_patterns = ['build-templates/*.rst'] + from searx import webapp jinja_contexts = { 'webapp': dict(**webapp.__dict__) diff --git a/utils/searx.sh b/utils/searx.sh index de903bc09..38ccfdcab 100755 --- a/utils/searx.sh +++ b/utils/searx.sh @@ -643,170 +643,10 @@ rst-doc() { arch="$(echo "${arch}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" fedora="$(echo "${fedora}" | sed 's/.*/ & \\/' | sed '$ s/.$//')" - cat <> "$SERVICE_HOME/.profile" - -.. END create virtualenv - -.. START manage.sh update_packages - -.. tabs:: - - .. group-tab:: bash - - .. code-block:: sh - - $ sudo -H -u ${SERVICE_USER} -i - - (${SERVICE_USER})$ command -v python && python --version - $SEARX_PYENV/bin/python - Python 3.8.1 - - (${SERVICE_USER})$ cd "$SEARX_SRC" - (${SERVICE_USER})$ ./manage.sh update_packages - -.. END manage.sh update_packages - -.. START searx config - -.. tabs:: - - .. group-tab:: bash - - .. code-block:: sh - - $ sudo -H cp "$SEARX_SRC/searx/settings.yml" "${SEARX_SETTINGS_PATH}" - $ sudo -H sed -i -e "s/ultrasecretkey/\$(openssl rand -hex 16)/g" "$SEARX_SETTINGS_PATH" - $ sudo -H sed -i -e "s/{instance_name}/searx@\$(uname -n)/g" "$SEARX_SETTINGS_PATH" - -.. END searx config - -.. START check searx installation - -.. tabs:: - - .. group-tab:: bash - - .. code-block:: sh - - # enable debug .. - $ sudo -H sed -i -e "s/debug : False/debug : True/g" "$SEARX_SETTINGS_PATH" - - # start webapp - $ sudo -H -u ${SERVICE_USER} -i - (${SERVICE_USER})$ cd ${SEARX_SRC} - (${SERVICE_USER})$ export SEARX_SETTINGS_PATH="${SEARX_SETTINGS_PATH}" - (${SERVICE_USER})$ python searx/webapp.py - - # disable debug - $ sudo -H sed -i -e "s/debug : True/debug : False/g" "$SEARX_SETTINGS_PATH" - -Open WEB browser and visit http://$SEARX_INTERNAL_URL . If you are inside a -container or in a script, test with curl: - -.. tabs:: - - .. group-tab:: WEB browser - - .. code-block:: sh - - $ xgd-open http://$SEARX_INTERNAL_URL - - .. group-tab:: curl - - .. code-block:: none - - $ curl --location --verbose --head --insecure $SEARX_INTERNAL_URL - - * Trying 127.0.0.1:8888... - * TCP_NODELAY set - * Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0) - > HEAD / HTTP/1.1 - > Host: 127.0.0.1:8888 - > User-Agent: curl/7.68.0 - > Accept: */* - > - * Mark bundle as not supporting multiuse - * HTTP 1.0, assume close after body - < HTTP/1.0 200 OK - HTTP/1.0 200 OK - ... - -.. END check searx installation - -EOF + eval "echo \"$(< ${REPO_ROOT}/docs/build-templates/searx.rst)\"" } - # ---------------------------------------------------------------------------- main "$@" # ----------------------------------------------------------------------------