diff --git a/config.php.example b/config.php.example index 8c1002a..e252a5e 100644 --- a/config.php.example +++ b/config.php.example @@ -8,6 +8,9 @@ "google_language_site" => "", "google_language_results" => "", + // You can set a language for results in wikipedia + "wikipedia_language" => "en", + // You can use any Invidious instance here "invidious_instance_for_video_results" => "https://invidious.namazso.eu", diff --git a/docker/README.md b/docker/README.md index adc3b97..b7bc5d6 100644 --- a/docker/README.md +++ b/docker/README.md @@ -8,6 +8,7 @@ - [Environment variables that can be set in the Docker container](#environment-variables-that-can-be-set-in-the-docker-container) - [OpenSearch](#opensearch) - [Search Config](#search-config) + - [Wikipedia](#wikipedia) - [Applications](#applications) - [Curl](#curl) - [Docker version issues](#docker-version-issues) @@ -23,12 +24,14 @@ Dockerized Librex is a way to provide users with yet another way to self-host th To run librex in a docker container, you can simply use the command: ```sh -docker run -d --name librex \ - -e TZ="America/New_York" \ - -e CONFIG_GOOGLE_DOMAIN="com" \ - -e CONFIG_GOOGLE_LANGUAGE="en" \ - -p 8080:8080 \ - librex/librex:latest +docker run -d \ + --name librex \ + -e TZ="America/New_York" \ + -e CONFIG_GOOGLE_DOMAIN="com" \ + -e CONFIG_GOOGLE_LANGUAGE="en" \ + -e CONFIG_WIKIPEDIA_LANGUAGE="en" \ + -p 8080:8080 \ + librex/librex:latest ```
@@ -51,6 +54,7 @@ services: - TZ="America/New_York" - CONFIG_GOOGLE_DOMAIN="com" - CONFIG_GOOGLE_LANGUAGE="en" + - CONFIG_WIKIPEDIA_LANGUAGE="en" volumes: - ./nginx_logs:/var/log/nginx - ./php_logs:/var/log/php7 @@ -90,6 +94,14 @@ This docker image was developed with high configurability in mind, so here is th
+### Wikipedia + +| Variables | Default | Examples | Description | +|:----------|:-------------|:---------|:------| +| CONFIG_WIKIPEDIA_LANGUAGE | "en" | "pt", "es", "hu" | Adds language support for Wikipedia results | + +
+ ### Applications | Variables | Default | Examples | Description | diff --git a/docker/attributes.sh b/docker/attributes.sh index 012c7c2..5a86ccc 100755 --- a/docker/attributes.sh +++ b/docker/attributes.sh @@ -19,13 +19,17 @@ export OPEN_SEARCH_HOST=${OPEN_SEARCH_HOST:-"127.0.0.1"} # Replace the 'config.php' script, which contains the most common search engine configurations, with these environment setups # These environment setups can be found in 'config.php', and the default configurations can be useful for most use cases -export CONFIG_GOOGLE_DOMAIN=${CONFIG_GOOGLE_DOMAIN:-".com"} +export CONFIG_GOOGLE_DOMAIN=${CONFIG_GOOGLE_DOMAIN:-"com"} export CONFIG_GOOGLE_LANGUAGE=${CONFIG_GOOGLE_LANGUAGE:-"en"} export CONFIG_INVIDIOUS_INSTANCE=${CONFIG_INVIDIOUS_INSTANCE:-"invidious.namazso.eu"} export CONFIG_HIDDEN_SERVICE_SEARCH=${CONFIG_HIDDEN_SERVICE_SEARCH:-false} export CONFIG_DISABLE_BITTORRENT_SEARCH=${CONFIG_DISABLE_BITTORRENT_SEARCH:-false} export CONFIG_BITTORRENT_TRACKERS=${CONFIG_BITTORRENT_TRACKERS:-"&tr=http://nyaa.tracker.wf:7777/announce&tr=udp://open.stealth.si:80/announce&tr=udp://tracker.opentrackr.org:1337/announce&tr=udp://exodus.desync.com:6969/announce&tr=udp://tracker.torrent.eu.org:451/announce"} +# The settings that will be used to handle Wikipedia results displayed on the libreX search page +# the settings below can be edited via environment variables. +export CONFIG_WIKIPEDIA_LANGUAGE=${CONFIG_WIKIPEDIA_LANGUAGE:-${CONFIG_GOOGLE_LANGUAGE}} + # Supported apps integration configuration. These empty spaces can be set up using free hosts as pointers # A particular example is using the "https://yewtu.be" or a self-hosted host to integrate the invidious app to librex export APP_INVIDIOUS=${APP_INVIDIOUS:-""} diff --git a/docker/php/config.php b/docker/php/config.php index ded967d..f90b765 100644 --- a/docker/php/config.php +++ b/docker/php/config.php @@ -4,6 +4,8 @@ "google_language" => "${CONFIG_GOOGLE_LANGUAGE}", "invidious_instance_for_video_results" => "${CONFIG_INVIDIOUS_INSTANCE}", + "wikipedia_language" => "${CONFIG_WIKIPEDIA_LANGUAGE}", + "disable_bittorent_search" => ${CONFIG_DISABLE_BITTORRENT_SEARCH}, "bittorent_trackers" => "${CONFIG_BITTORRENT_TRACKERS}", "disable_hidden_service_search" => ${CONFIG_HIDDEN_SERVICE_SEARCH}, diff --git a/engines/google/text.php b/engines/google/text.php index 27b7eec..05cdcf9 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -55,7 +55,8 @@ $url = "https://check.torproject.org/torbulkexitlist"; break; case 7: - $url = "https://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded"; + $wikipedia_language = $config->wikipedia_language; + $url = "https://$wikipedia_language.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded"; break; } diff --git a/engines/special/wikipedia.php b/engines/special/wikipedia.php index d24dd21..ec15e69 100644 --- a/engines/special/wikipedia.php +++ b/engines/special/wikipedia.php @@ -1,6 +1,8 @@ wikipedia_language; - $source = check_for_privacy_frontend("https://en.wikipedia.org/wiki/$query"); + $source = check_for_privacy_frontend("https://$wikipedia_language.wikipedia.org/wiki/$query"); $response = array( "special_response" => array( "response" => htmlspecialchars($description),