diff --git a/.dockerignore b/.dockerignore index f4d03376c..044460b20 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,9 @@ */*/*/*~ */*/*/*/*~ +# +local/ + # Git .git .gitignore @@ -36,6 +39,11 @@ robot_report.html test_basic/ setup.cfg +# node_modules node_modules/ +*/node_modules/ +*/*/node_modules/ +*/*/*/node_modules/ +*/*/*/*/node_modules/ .tx/ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 069dfd35b..1c82be41b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ setup.cfg */*.pyc *~ -node_modules/ +/node_modules .tx/ diff --git a/.travis.yml b/.travis.yml index e37b65864..1667cd37c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: python sudo: false cache: - - pip - - npm - directories: - $HOME/.cache/pip @@ -10,17 +8,15 @@ addons: firefox: "latest" install: - - ./manage.sh install_geckodriver ~/drivers - - export PATH=~/drivers:$PATH - - ./manage.sh npm_packages - - ./manage.sh update_dev_packages - - pip install codecov + - make install + - make gecko.driver + - make node.env + - local/py3/bin/pip install codecov script: - - ./manage.sh styles - - ./manage.sh grunt_build - - ./manage.sh tests + - make themes + - make test after_success: - - ./manage.sh py_test_coverage + - make test.coverage - codecov stages: @@ -44,7 +40,7 @@ jobs: install: true script: - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin - - ./manage.sh docker_build push + - local/py3/bin/activate; ./manage.sh docker_build push after_success: true notifications: diff --git a/Dockerfile b/Dockerfile index 9885fb794..700a21ffc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,7 @@ EXPOSE 8080 VOLUME /etc/searx VOLUME /var/log/uwsgi +ARG GIT_URL=unknown ARG VERSION_GITCOMMIT=unknown ARG SEARX_GIT_VERSION=unknown @@ -66,7 +67,7 @@ RUN su searx -c "/usr/bin/python3 -m compileall -q searx"; \ # Keep this argument at the end since it change each time ARG LABEL_DATE= -LABEL maintainer="searx " \ +LABEL maintainer="searx <${GIT_URL}>" \ description="A privacy-respecting, hackable metasearch engine." \ version="${SEARX_GIT_VERSION}" \ org.label-schema.schema-version="1.0" \ diff --git a/Makefile b/Makefile index 5a47129e4..a093d8b18 100644 --- a/Makefile +++ b/Makefile @@ -28,23 +28,27 @@ 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 ' buildenv - re-build environment files (aka brand)' + @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 '' @$(MAKE) -s -f utils/makefile.python python-help PHONY += install -install: pyenvinstall +install: buildenv pyenvinstall PHONY += uninstall uninstall: pyenvuninstall PHONY += clean -clean: pyclean +clean: pyclean node.clean test.clean $(call cmd,common_clean) PHONY += run -run: pyenvinstall +run: buildenv pyenvinstall $(Q) ( \ sed -i -e "s/debug : False/debug : True/g" ./searx/settings.yml ; \ sleep 2 ; \ @@ -58,11 +62,11 @@ run: pyenvinstall # ---- PHONY += docs -docs: pyenvinstall sphinx-doc +docs: buildenv pyenvinstall sphinx-doc $(call cmd,sphinx,html,docs,docs) PHONY += docs-live -docs-live: pyenvinstall sphinx-live +docs-live: buildenv pyenvinstall sphinx-live $(call cmd,sphinx_autobuild,html,docs,docs) $(GH_PAGES):: @@ -71,35 +75,146 @@ $(GH_PAGES):: # update project files # -------------------- -PHONY += project engines-languages +PHONY += project engines.languages useragents.update buildenv -project: searx/data/engines_languages.json +project: buildenv useragents.update engines.languages -searx/data/engines_languages.json: 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 + +buildenv: + $(Q)echo "build searx/brand.py" + $(Q)echo "GIT_URL = '$(GIT_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 + $(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 +# ---------- + +node.env: buildenv + $(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 +# ------------ + +PHONY += themes.bootstrap themes themes.oscar themes.simple themes.legacy themes.courgette themes.pixart +themes: buildenv themes.bootstrap themes.oscar themes.simple themes.legacy themes.courgette themes.pixart + +quiet_cmd_lessc = LESSC $3 + cmd_lessc = PATH="$$(npm bin):$$PATH" \ + lessc --clean-css="--s1 --advanced --compatibility=ie9" "searx/static/$2" "searx/static/$3" + +quiet_cmd_grunt = GRUNT $2 + cmd_grunt = PATH="$$(npm bin):$$PATH" \ + grunt --gruntfile "$2" + +themes.oscar: + $(Q)echo '[!] build oscar theme' + $(call cmd,grunt,searx/static/themes/oscar/gruntfile.js) + +themes.simple: + $(Q)echo '[!] build simple theme' + $(call cmd,grunt,searx/static/themes/simple/gruntfile.js) + +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) + +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) + +themes.pixart: + $(Q)echo '[!] build pixart theme' + $(call cmd,lessc,themes/pix-art/less/style.less,themes/pix-art/css/style.css) + +themes.bootstrap: + $(call cmd,lessc,less/bootstrap/bootstrap.less,css/bootstrap.min.css) + + +# docker +# ------ + +PHONY += docker +docker: buildenv + $(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: buildenv 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 + @echo "TEST tests/unit" + $(Q)$(PY_ENV_ACT); python -m nose2 -s tests/unit -test.robot: pyenvinstall - $(PY_ENV_ACT); ./manage.sh install_geckodriver - $(PY_ENV_ACT); ./manage.sh robot_tests +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) diff --git a/docs/conf.py b/docs/conf.py index ebcd102b2..03e977aba 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -4,9 +4,9 @@ import sys, os from searx.version import VERSION_STRING from pallets_sphinx_themes import ProjectLink -GIT_URL = os.environ.get("GIT_URL", "https://github.com/asciimoo/searx") -SEARX_URL = os.environ.get("SEARX_URL", "https://searx.me") -DOCS_URL = os.environ.get("DOCS_URL", "https://asciimoo.github.io/searx/") +from searx.brand import GIT_URL +from searx.brand import SEARX_URL +from searx.brand import DOCS_URL # Project -------------------------------------------------------------- diff --git a/docs/dev/quickstart.rst b/docs/dev/quickstart.rst index e40772b3b..a786eda63 100644 --- a/docs/dev/quickstart.rst +++ b/docs/dev/quickstart.rst @@ -87,8 +87,8 @@ After satisfying the requirements styles can be build using ``manage.sh`` ./manage.sh styles -How to build the source of the oscar theme -========================================== +How to build the source of the themes +===================================== .. _grunt: https://gruntjs.com/ @@ -98,13 +98,13 @@ NodeJS, so first Node has to be installed. .. code:: sh sudo -H apt-get install nodejs - sudo -H npm install -g grunt-cli + make node.env After installing grunt, the files can be built using the following command: .. code:: sh - ./manage.sh grunt_build + make themes Tips for debugging/development diff --git a/manage.sh b/manage.sh index 496a522ba..4831fc1fa 100755 --- a/manage.sh +++ b/manage.sh @@ -10,6 +10,7 @@ PYTHONPATH="$BASE_DIR" SEARX_DIR="$BASE_DIR/searx" ACTION="$1" +. "${BASE_DIR}/utils/brand.env" # # Python @@ -70,45 +71,6 @@ locales() { pybabel compile -d "$SEARX_DIR/translations" } -update_useragents() { - echo '[!] Updating user agent versions' - python utils/fetch_firefox_version.py -} - -pep8_check() { - echo '[!] Running pep8 check' - # ignored rules: - # E402 module level import not at top of file - # W503 line break before binary operator - pep8 --exclude=searx/static --max-line-length=120 --ignore "E402,W503" "$SEARX_DIR" "$BASE_DIR/tests" -} - -unit_tests() { - echo '[!] Running unit tests' - python -m nose2 -s "$BASE_DIR/tests/unit" -} - -py_test_coverage() { - echo '[!] Running python test coverage' - PYTHONPATH="`pwd`" python -m nose2 -C --log-capture --with-coverage --coverage "$SEARX_DIR" -s "$BASE_DIR/tests/unit" \ - && coverage report \ - && coverage html -} - -robot_tests() { - echo '[!] Running robot tests' - PYTHONPATH="`pwd`" python "$SEARX_DIR/testing.py" robot -} - -tests() { - set -e - pep8_check - unit_tests - install_geckodriver - robot_tests - set +e -} - # # Web @@ -135,36 +97,6 @@ npm_packages() { npm install } -build_style() { - npm_path_setup - - lessc --clean-css="--s1 --advanced --compatibility=ie9" "$BASE_DIR/searx/static/$1" "$BASE_DIR/searx/static/$2" -} - -styles() { - npm_path_setup - - echo '[!] Building legacy style' - build_style themes/legacy/less/style.less themes/legacy/css/style.css - build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css - echo '[!] Building courgette style' - build_style themes/courgette/less/style.less themes/courgette/css/style.css - build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css - echo '[!] Building pix-art style' - build_style themes/pix-art/less/style.less themes/pix-art/css/style.css - echo '[!] Building bootstrap style' - build_style less/bootstrap/bootstrap.less css/bootstrap.min.css -} - -grunt_build() { - npm_path_setup - - echo '[!] Grunt build : oscar theme' - grunt --gruntfile "$SEARX_DIR/static/themes/oscar/gruntfile.js" - echo '[!] Grunt build : simple theme' - grunt --gruntfile "$SEARX_DIR/static/themes/simple/gruntfile.js" -} - docker_build() { # Check if it is a git repository if [ ! -d .git ]; then @@ -211,18 +143,18 @@ docker_build() { fi # define the docker image name - # /!\ HACK to get the user name /!\ - GITHUB_USER=$(git remote get-url origin | sed 's/.*github\.com\/\([^\/]*\).*/\1/') + GITHUB_USER=$(echo "${GIT_URL}" | sed 's/.*github\.com\/\([^\/]*\).*/\1/') SEARX_IMAGE_NAME="${GITHUB_USER:-searx}/searx" # build Docker image echo "Building image ${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION}" sudo docker build \ + --build-arg GIT_URL="${GIT_URL}" \ --build-arg SEARX_GIT_VERSION="${SEARX_GIT_VERSION}" \ --build-arg VERSION_GITCOMMIT="${VERSION_GITCOMMIT}" \ --build-arg LABEL_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") \ --build-arg LABEL_VCS_REF=$(git rev-parse HEAD) \ - --build-arg LABEL_VCS_URL=$(git remote get-url origin) \ + --build-arg LABEL_VCS_URL="${GIT_URL}" \ --build-arg TIMESTAMP_SETTINGS=$(git log -1 --format="%cd" --date=unix -- searx/settings.yml) \ --build-arg TIMESTAMP_UWSGI=$(git log -1 --format="%cd" --date=unix -- dockerfiles/uwsgi.ini) \ -t ${SEARX_IMAGE_NAME}:latest -t ${SEARX_IMAGE_NAME}:${SEARX_GIT_VERSION} . @@ -251,22 +183,17 @@ Commands update_dev_packages - Check & update development and production dependency changes install_geckodriver - Download & install geckodriver if not already installed (required for robot_tests) npm_packages - Download & install npm dependencies - update_useragents - Update useragents.json with the most recent versions of Firefox Build ----- locales - Compile locales - styles - Build less files - grunt_build - Build files for themes - docker_build - Build Docker image - Tests - ----- - unit_tests - Run unit tests - pep8_check - Pep8 validation - robot_tests - Run selenium tests - tests - Run all python tests (pep8, unit, robot_tests) - py_test_coverage - Unit test coverage +Environment: + GIT_URL: ${GIT_URL} + ISSUE_URL: ${ISSUE_URL} + SEARX_URL: ${SEARX_URL} + DOCS_URL: ${DOCS_URL} + PUBLIC_INSTANCES: ${PUBLIC_INSTANCES} " } diff --git a/searx/brand.py b/searx/brand.py new file mode 100644 index 000000000..d563447f6 --- /dev/null +++ b/searx/brand.py @@ -0,0 +1,5 @@ +GIT_URL = 'https://github.com/asciimoo/searx' +ISSUE_URL = 'https://github.com/asciimoo/searx/issues' +SEARX_URL = 'https://searx.me' +DOCS_URL = 'https://asciimoo.github.io/searx' +PUBLIC_INSTANCES = 'https://searx.space' diff --git a/searx/data/useragents.json b/searx/data/useragents.json index abb81000c..5ba8c5be8 100644 --- a/searx/data/useragents.json +++ b/searx/data/useragents.json @@ -1,11 +1,8 @@ { "versions": [ - "70.0.1", - "70.0", - "69.0.3", - "69.0.2", - "69.0.1", - "69.0" + "74.0", + "73.0.1", + "73.0" ], "os": [ "Windows NT 10; WOW64", diff --git a/searx/static/themes/oscar/.gitignore b/searx/static/themes/oscar/.gitignore index c2658d7d1..07e6e472c 100644 --- a/searx/static/themes/oscar/.gitignore +++ b/searx/static/themes/oscar/.gitignore @@ -1 +1 @@ -node_modules/ +/node_modules diff --git a/searx/static/themes/oscar/gruntfile.js b/searx/static/themes/oscar/gruntfile.js index def035dba..606b6bcfb 100644 --- a/searx/static/themes/oscar/gruntfile.js +++ b/searx/static/themes/oscar/gruntfile.js @@ -13,7 +13,7 @@ module.exports = function(grunt) { }, uglify: { options: { - banner: '/*! oscar/searx.min.js | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n' + banner: '/*! oscar/searx.min.js | <%= grunt.template.today("dd-mm-yyyy") %> | <%= process.env.GIT_URL %> */\n' }, dist: { files: { @@ -38,7 +38,6 @@ module.exports = function(grunt) { development: { options: { paths: ["less/pointhi", "less/logicodev", "less/logicodev-dark"] - //banner: '/*! less/oscar/oscar.css | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n' }, files: {"css/pointhi.css": "less/pointhi/oscar.less", "css/logicodev.css": "less/logicodev-dark/oscar.less", @@ -47,7 +46,6 @@ module.exports = function(grunt) { production: { options: { paths: ["less/pointhi", "less/logicodev", "less/logicodev-dark"], - //banner: '/*! less/oscar/oscar.css | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n', cleancss: true }, files: {"css/pointhi.min.css": "less/pointhi/oscar.less", diff --git a/searx/static/themes/simple/.gitignore b/searx/static/themes/simple/.gitignore new file mode 100644 index 000000000..07e6e472c --- /dev/null +++ b/searx/static/themes/simple/.gitignore @@ -0,0 +1 @@ +/node_modules diff --git a/searx/static/themes/simple/gruntfile.js b/searx/static/themes/simple/gruntfile.js index c372ec730..c8f2ed3c6 100644 --- a/searx/static/themes/simple/gruntfile.js +++ b/searx/static/themes/simple/gruntfile.js @@ -36,7 +36,7 @@ module.exports = function(grunt) { }, uglify: { options: { - banner: '/*! simple/searx.min.js | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n', + banner: '/*! simple/searx.min.js | <%= grunt.template.today("dd-mm-yyyy") %> | <%= process.env.GIT_URL %> */\n', output: { comments: 'some' }, @@ -57,7 +57,7 @@ module.exports = function(grunt) { development: { options: { paths: ["less"], - banner: '/*! searx | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n' + banner: '/*! searx | <%= grunt.template.today("dd-mm-yyyy") %> | <%= process.env.GIT_URL %> */\n' }, files: { "css/searx.css": "less/style.less", @@ -73,7 +73,7 @@ module.exports = function(grunt) { compatibility: '*' }) ], - banner: '/*! searx | <%= grunt.template.today("dd-mm-yyyy") %> | https://github.com/asciimoo/searx */\n' + banner: '/*! searx | <%= grunt.template.today("dd-mm-yyyy") %> | <%= process.env.GIT_URL %> */\n' }, files: { "css/searx.min.css": "less/style.less", diff --git a/searx/templates/__common__/about.html b/searx/templates/__common__/about.html index ff86ddd28..5c91c3394 100644 --- a/searx/templates/__common__/about.html +++ b/searx/templates/__common__/about.html @@ -1,63 +1,97 @@ -

About searx

+

About searx

-

Searx is a metasearch engine, aggregating the results of other search engines while not storing information about its users. -

-

Why use searx?

- -

If you do care about privacy, want to be a conscious user, or otherwise believe - in digital freedom, make searx your default search engine or run it on your own server

+

+ Searx is a metasearch engine, + aggregating the results of other search engines + while not storing information about its users. +

-

Technical details - How does it work?

+

More about searx ...

-

Searx is a metasearch engine, -inspired by the seeks project.
-It provides basic privacy by mixing your queries with searches on other platforms without storing search data. Queries are made using a POST request on every browser (except chrome*). Therefore they show up in neither our logs, nor your url history. In case of Chrome* users there is an exception, searx uses the search bar to perform GET requests.
-Searx can be added to your browser's search bar; moreover, it can be set as the default search engine. -

- -

How can I make it my own?

- -

Searx appreciates your concern regarding logs, so take the code and run it yourself!
Add your Searx to this list to help other people reclaim their privacy and make the Internet freer! -
The more decentralized the Internet is, the more freedom we have!

- - -

More about searx

- - +
-
+

Why use searx?

-

FAQ

+ -

How to add to firefox?

-

Install searx as a search engine on any version of Firefox! (javascript required)

+

+ If you do care about privacy, want to be a conscious user, or otherwise + believe in digital freedom, make searx your default search engine or run it + on your own server +

-

Developer FAQ

+

Technical details - How does it work?

-

New engines?

- -

Don't forget to restart searx after config edit!

+

+ Searx is a metasearch engine, + inspired by the seeks project. -

Installation/WSGI support?

-

See the installation and setup wiki page

+ It provides basic privacy by mixing your queries with searches on other + platforms without storing search data. Queries are made using a POST request + on every browser (except chrome*). Therefore they show up in neither our + logs, nor your url history. In case of Chrome* users there is an exception, + searx uses the search bar to perform GET requests. -

How to debug engines?

-

Stats page contains some useful data about the engines used.

+ Searx can be added to your browser's search bar; moreover, it can be set as + the default search engine. +

+ +

How to set as the default search engine?

+ +
Firefox
+ +
+ Install + searx as a search engine on any version of Firefox! (javascript required) +
+ +

Where to find anonymous usage statistics of this instance ?

+ +

+ Stats page contains some useful data about the engines used. +

+ +

How can I make it my own?

+ +

+ Searx appreciates your concern regarding logs, so take the + code from the orgin searx project and + run it yourself! +

+

+ Add your searx instance to this list + of public searx instances to help other people reclaim their privacy and + make the Internet freer! The more decentralized the Internet is, the more + freedom we have! +

+ +

Where are the docs & code of this instance?

+ +

+ See the {{ brand.DOCS_URL }} + and {{ brand.GIT_URL }} +

{% include "__common__/aboutextend.html" ignore missing %} diff --git a/searx/templates/courgette/github_ribbon.html b/searx/templates/courgette/github_ribbon.html index 67c6e678f..bdd9cf180 100644 --- a/searx/templates/courgette/github_ribbon.html +++ b/searx/templates/courgette/github_ribbon.html @@ -1,3 +1,3 @@ Fork me on GitHub - \ No newline at end of file + diff --git a/searx/templates/oscar/base.html b/searx/templates/oscar/base.html index 9465ca58a..5eb4462e4 100644 --- a/searx/templates/oscar/base.html +++ b/searx/templates/oscar/base.html @@ -85,10 +85,10 @@ {% endblock %}

- {{ _('Powered by') }} searx - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}
- {{ _('Source code') }} | - {{ _('Issue tracker') }} | - {{ _('Public instances') }} + {{ _('Powered by') }} searx - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}
+ {{ _('Source code') }} | + {{ _('Issue tracker') }} | + {{ _('Public instances') }}

diff --git a/searx/templates/simple/base.html b/searx/templates/simple/base.html index bba02dbf8..71df123ea 100644 --- a/searx/templates/simple/base.html +++ b/searx/templates/simple/base.html @@ -51,9 +51,9 @@ diff --git a/searx/webapp.py b/searx/webapp.py old mode 100644 new mode 100755 index b3928921e..c910230ab --- a/searx/webapp.py +++ b/searx/webapp.py @@ -57,6 +57,7 @@ from babel.support import Translations import flask_babel from flask_babel import Babel, gettext, format_date, format_decimal from flask.json import jsonify +from searx import brand from searx import settings, searx_dir, searx_debug from searx.exceptions import SearxParameterException from searx.engines import ( @@ -427,6 +428,8 @@ def render(template_name, override_theme=None, **kwargs): kwargs['preferences'] = request.preferences + kwargs['brand'] = brand + kwargs['scripts'] = set() for plugin in request.user_plugins: for script in plugin.js_dependencies: @@ -955,34 +958,51 @@ def clear_cookies(): @app.route('/config') def config(): - return jsonify({'categories': list(categories.keys()), - 'engines': [{'name': name, - 'categories': engine.categories, - 'shortcut': engine.shortcut, - 'enabled': not engine.disabled, - 'paging': engine.paging, - 'language_support': engine.language_support, - 'supported_languages': - list(engine.supported_languages.keys()) - if isinstance(engine.supported_languages, dict) - else engine.supported_languages, - 'safesearch': engine.safesearch, - 'time_range_support': engine.time_range_support, - 'timeout': engine.timeout} - for name, engine in engines.items() if request.preferences.validate_token(engine)], - 'plugins': [{'name': plugin.name, - 'enabled': plugin.default_on} - for plugin in plugins], - 'instance_name': settings['general']['instance_name'], - 'locales': settings['locales'], - 'default_locale': settings['ui']['default_locale'], - 'autocomplete': settings['search']['autocomplete'], - 'safe_search': settings['search']['safe_search'], - 'default_theme': settings['ui']['default_theme'], - 'version': VERSION_STRING, - 'doi_resolvers': [r for r in settings['doi_resolvers']], - 'default_doi_resolver': settings['default_doi_resolver'], - }) + """Return configuration in JSON format.""" + _engines = [] + for name, engine in engines.items(): + if not request.preferences.validate_token(engine): + continue + + supported_languages = engine.supported_languages + if isinstance(engine.supported_languages, dict): + supported_languages = list(engine.supported_languages.keys()) + + _engines.append({ + 'name': name, + 'categories': engine.categories, + 'shortcut': engine.shortcut, + 'enabled': not engine.disabled, + 'paging': engine.paging, + 'language_support': engine.language_support, + 'supported_languages': supported_languages, + 'safesearch': engine.safesearch, + 'time_range_support': engine.time_range_support, + 'timeout': engine.timeout + }) + + _plugins = [] + for _ in plugins: + _plugins.append({'name': _.name, 'enabled': _.default_on}) + + return jsonify({ + 'categories': list(categories.keys()), + 'engines': _engines, + 'plugins': _plugins, + 'instance_name': settings['general']['instance_name'], + 'locales': settings['locales'], + 'default_locale': settings['ui']['default_locale'], + 'autocomplete': settings['search']['autocomplete'], + 'safe_search': settings['search']['safe_search'], + 'default_theme': settings['ui']['default_theme'], + 'version': VERSION_STRING, + 'brand': { + 'GIT_URL': brand.GIT_URL, + 'DOCS_URL': brand.DOCS_URL + }, + 'doi_resolvers': [r for r in settings['doi_resolvers']], + 'default_doi_resolver': settings['default_doi_resolver'], + }) @app.errorhandler(404) diff --git a/setup.py b/setup.py index bd3dd5d1c..97a3270ef 100644 --- a/setup.py +++ b/setup.py @@ -10,6 +10,7 @@ import sys # required to load VERSION_STRING constant sys.path.insert(0, './searx') from version import VERSION_STRING +import brand with open('README.rst') as f: long_description = f.read() @@ -25,6 +26,11 @@ setup( version=VERSION_STRING, description="A privacy-respecting, hackable metasearch engine", long_description=long_description, + url=brand.DOCS_URL, + project_urls={ + "Code": brand.GIT_URL, + "Issue tracker": brand.ISSUE_URL + }, classifiers=[ "Development Status :: 4 - Beta", "Programming Language :: Python", @@ -36,7 +42,6 @@ setup( keywords='metasearch searchengine search web http', author='Adam Tauber', author_email='asciimoo@gmail.com', - url='https://github.com/asciimoo/searx', license='GNU Affero General Public License', packages=find_packages(exclude=["tests*"]), zip_safe=False, diff --git a/utils/brand.env b/utils/brand.env new file mode 100644 index 000000000..7fe1a3911 --- /dev/null +++ b/utils/brand.env @@ -0,0 +1,5 @@ +export GIT_URL='https://github.com/asciimoo/searx' +export ISSUE_URL='https://github.com/asciimoo/searx/issues' +export SEARX_URL='https://searx.me' +export DOCS_URL='https://asciimoo.github.io/searx' +export PUBLIC_INSTANCES='https://searx.space'