diff --git a/app/models/config.py b/app/models/config.py index ee3c4ac..1c866d7 100644 --- a/app/models/config.py +++ b/app/models/config.py @@ -57,6 +57,7 @@ class Config: self.dark = False self.nojs = False self.near = '' + self.get_only = False for key, value in kwargs.items(): setattr(self, key, value) diff --git a/app/routes.py b/app/routes.py index ba2394c..6b48473 100644 --- a/app/routes.py +++ b/app/routes.py @@ -42,7 +42,8 @@ def index(): bg=bg, ua=g.user_request.modified_user_agent, languages=Config.LANGUAGES, - current_lang=g.user_config.lang) + current_lang=g.user_config.lang, + request_type='get' if g.user_config.get_only else 'post') @app.route('/opensearch.xml', methods=['GET']) @@ -51,7 +52,9 @@ def opensearch(): if opensearch_url.endswith('/'): opensearch_url = opensearch_url[:-1] - template = render_template('opensearch.xml', main_url=opensearch_url) + template = render_template('opensearch.xml', + main_url=opensearch_url, + request_type='get' if g.user_config.get_only else 'post') response = make_response(template) response.headers['Content-Type'] = 'application/xml' return response diff --git a/app/static/js/controller.js b/app/static/js/controller.js index acf16af..e950eb5 100644 --- a/app/static/js/controller.js +++ b/app/static/js/controller.js @@ -13,9 +13,16 @@ const setupSearchLayout = () => { searchBtn.click(); } }); -} +}; + +const fillConfigValues = () => { + // Establish all config value elements + const near = document.getElementById("config-near"); + const noJS = document.getElementById("config-nojs"); + const dark = document.getElementById("config-dark"); + const url = document.getElementById("config-url"); + const getOnly = document.getElementById("config-get-only"); -const fillConfigValues = (near, nojs, dark, url) => { // Request existing config info let xhrGET = new XMLHttpRequest(); xhrGET.open("GET", "/config"); @@ -29,15 +36,16 @@ const fillConfigValues = (near, nojs, dark, url) => { let configSettings = JSON.parse(xhrGET.responseText); near.value = configSettings["near"] ? configSettings["near"] : ""; - nojs.checked = !!configSettings["nojs"]; + noJS.checked = !!configSettings["nojs"]; dark.checked = !!configSettings["dark"]; + getOnly.checked = !!configSettings["get_only"]; // Addresses the issue of incorrect URL being used behind reverse proxy url.value = configSettings["url"] ? configSettings["url"] : ""; }; xhrGET.send(); -} +}; const setupConfigLayout = () => { // Setup whoogle config @@ -54,13 +62,8 @@ const setupConfigLayout = () => { content.classList.toggle("open"); }); - const near = document.getElementById("config-near"); - const noJS = document.getElementById("config-nojs"); - const dark = document.getElementById("config-dark"); - const url = document.getElementById("config-url"); - - fillConfigValues(near, noJS, dark, url); -} + fillConfigValues(); +}; document.addEventListener("DOMContentLoaded", function() { setTimeout(function() { diff --git a/app/templates/index.html b/app/templates/index.html index 89c38d3..222fa17 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -26,7 +26,7 @@
-
+
@@ -66,6 +66,10 @@
+
+ + +
diff --git a/app/templates/opensearch.xml b/app/templates/opensearch.xml index 82254b2..bf44b00 100644 --- a/app/templates/opensearch.xml +++ b/app/templates/opensearch.xml @@ -4,7 +4,7 @@ Whoogle: A lightweight, deployable Google search proxy for desktop/mobile that removes Javascript, AMP links, and ads UTF-8 /static/img/favicon/favicon-32x32.png - +