Use relative links instead of absolute (#139)

* Use relative links instead of absolute

This allows for hosting under a subpath. For example if you want to host
whoogle at example.com/whoogle, it should work better with a reverse proxy.

* Use relative link for opensearch.xml
main
bugbounce 2020-10-29 15:09:31 +00:00 committed by GitHub
parent 933ce7e068
commit 1148a7fb8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 43 deletions

View File

@ -107,14 +107,14 @@ class Filter:
element_src = 'https:' + element_src element_src = 'https:' + element_src
elif element_src.startswith(LOGO_URL): elif element_src.startswith(LOGO_URL):
# Re-brand with Whoogle logo # Re-brand with Whoogle logo
element['src'] = '/static/img/logo.png' element['src'] = 'static/img/logo.png'
element['style'] = 'height:40px;width:162px' element['style'] = 'height:40px;width:162px'
return return
elif element_src.startswith(GOOG_IMG): elif element_src.startswith(GOOG_IMG):
element['src'] = BLANK_B64 element['src'] = BLANK_B64
return return
element['src'] = '/element?url=' + self.encrypt_path(element_src, is_element=True) + \ element['src'] = 'element?url=' + self.encrypt_path(element_src, is_element=True) + \
'&type=' + urlparse.quote(mime) '&type=' + urlparse.quote(mime)
# TODO: Non-mobile image results link to website instead of image # TODO: Non-mobile image results link to website instead of image
# if not self.mobile: # if not self.mobile:
@ -145,7 +145,7 @@ class Filter:
def update_link(self, link): def update_link(self, link):
# Replace href with only the intended destination (no "utm" type tags) # Replace href with only the intended destination (no "utm" type tags)
href = link['href'].replace('https://www.google.com', '') href = link['href'].replace('https://www.google.com', '')
if '/advanced_search' in href or 'tbm=shop' in href: if 'advanced_search' in href or 'tbm=shop' in href:
# TODO: The "Shopping" tab requires further filtering (see #136) # TODO: The "Shopping" tab requires further filtering (see #136)
# Temporarily removing all links to that tab for now. # Temporarily removing all links to that tab for now.
link.decompose() link.decompose()
@ -163,7 +163,7 @@ class Filter:
# "li:1" implies the query should be interpreted verbatim, so we wrap it in double quotes # "li:1" implies the query should be interpreted verbatim, so we wrap it in double quotes
if 'li:1' in href: if 'li:1' in href:
query_link = '"' + query_link + '"' query_link = '"' + query_link + '"'
new_search = '/search?q=' + self.encrypt_path(query_link) new_search = 'search?q=' + self.encrypt_path(query_link)
query_params = parse_qs(urlparse.urlparse(href).query) query_params = parse_qs(urlparse.urlparse(href).query)
for param in VALID_PARAMS: for param in VALID_PARAMS:

View File

@ -1,6 +1,6 @@
const handleUserInput = searchBar => { const handleUserInput = searchBar => {
let xhrRequest = new XMLHttpRequest(); let xhrRequest = new XMLHttpRequest();
xhrRequest.open("POST", "/autocomplete"); xhrRequest.open("POST", "autocomplete");
xhrRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhrRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhrRequest.onload = function () { xhrRequest.onload = function () {
if (xhrRequest.readyState === 4 && xhrRequest.status !== 200) { if (xhrRequest.readyState === 4 && xhrRequest.status !== 200) {
@ -123,4 +123,4 @@ const autocomplete = (searchInput, autocompleteResults) => {
document.addEventListener("click", function (e) { document.addEventListener("click", function (e) {
closeAllLists(e.target); closeAllLists(e.target);
}); });
}; };

View File

@ -31,7 +31,7 @@ const setupSearchLayout = () => {
const fillConfigValues = () => { const fillConfigValues = () => {
// Request existing config info // Request existing config info
let xhrGET = new XMLHttpRequest(); let xhrGET = new XMLHttpRequest();
xhrGET.open("GET", "/config"); xhrGET.open("GET", "config");
xhrGET.onload = function() { xhrGET.onload = function() {
if (xhrGET.readyState === 4 && xhrGET.status !== 200) { if (xhrGET.readyState === 4 && xhrGET.status !== 200) {
alert("Error loading Whoogle config"); alert("Error loading Whoogle config");
@ -82,7 +82,7 @@ const loadConfig = event => {
} }
let xhrPUT = new XMLHttpRequest(); let xhrPUT = new XMLHttpRequest();
xhrPUT.open("PUT", "/config?name=" + config + ".conf"); xhrPUT.open("PUT", "config?name=" + config + ".conf");
xhrPUT.onload = function() { xhrPUT.onload = function() {
if (xhrPUT.readyState === 4 && xhrPUT.status !== 200) { if (xhrPUT.readyState === 4 && xhrPUT.status !== 200) {
alert("Error loading Whoogle config"); alert("Error loading Whoogle config");
@ -104,7 +104,7 @@ const saveConfig = event => {
} }
let configForm = document.getElementById("config-form"); let configForm = document.getElementById("config-form");
configForm.action = '/config?name=' + config + ".conf"; configForm.action = 'config?name=' + config + ".conf";
configForm.submit(); configForm.submit();
}; };

View File

@ -1,15 +1,15 @@
<html> <html>
<head> <head>
<link rel="shortcut icon" href="/static/img/favicon.ico" type="image/x-icon"> <link rel="shortcut icon" href="static/img/favicon.ico" type="image/x-icon">
<link rel="icon" href="/static/img/favicon.ico" type="image/x-icon"> <link rel="icon" href="static/img/favicon.ico" type="image/x-icon">
<link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Whoogle Search"> <link rel="search" href="opensearch.xml" type="application/opensearchdescription+xml" title="Whoogle Search">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="referrer" content="no-referrer"> <meta name="referrer" content="no-referrer">
<script type="text/javascript" src="/static/js/autocomplete.js"></script> <script type="text/javascript" src="static/js/autocomplete.js"></script>
<link rel="stylesheet" href="/static/css/{{ 'search-dark' if dark_mode else 'search' }}.css"> <link rel="stylesheet" href="static/css/{{ 'search-dark' if dark_mode else 'search' }}.css">
<link rel="stylesheet" href="/static/css/header.css"> <link rel="stylesheet" href="static/css/header.css">
{% if dark_mode %} {% if dark_mode %}
<link rel="stylesheet" href="/static/css/dark-theme.css"/> <link rel="stylesheet" href="static/css/dark-theme.css"/>
{% endif %} {% endif %}
<title>{{ query }} - Whoogle Search</title> <title>{{ query }} - Whoogle Search</title>
</head> </head>

View File

@ -3,7 +3,7 @@
<div class="bz1lBb"> <div class="bz1lBb">
<form class="Pg70bf" id="search-form" method="POST"> <form class="Pg70bf" id="search-form" method="POST">
<a class="logo-link mobile-logo" <a class="logo-link mobile-logo"
href="/" href=""
style="display:flex; justify-content:center; align-items:center; color:#685e79; font-size:18px; "> style="display:flex; justify-content:center; align-items:center; color:#685e79; font-size:18px; ">
<span style="color: #685e79">Whoogle</span> <span style="color: #685e79">Whoogle</span>
</a> </a>
@ -24,7 +24,7 @@
{% else %} {% else %}
<header> <header>
<div class="logo-div"> <div class="logo-div">
<a class="logo-link" href="/"> <a class="logo-link" href="">
<span style="color: #685e79">Whoogle</span> <span style="color: #685e79">Whoogle</span>
</a> </a>
</div> </div>
@ -56,4 +56,4 @@
document.getElementById("search-form").submit(); document.getElementById("search-form").submit();
} }
}); });
</script> </script>

View File

@ -1,30 +1,30 @@
<html> <html>
<head> <head>
<link rel="apple-touch-icon" sizes="57x57" href="/static/img/favicon/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="57x57" href="static/img/favicon/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/static/img/favicon/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="60x60" href="static/img/favicon/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/static/img/favicon/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="72x72" href="static/img/favicon/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/static/img/favicon/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="76x76" href="static/img/favicon/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/static/img/favicon/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="114x114" href="static/img/favicon/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/static/img/favicon/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="120x120" href="static/img/favicon/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/static/img/favicon/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="144x144" href="static/img/favicon/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/static/img/favicon/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="152x152" href="static/img/favicon/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/static/img/favicon/apple-icon-180x180.png"> <link rel="apple-touch-icon" sizes="180x180" href="static/img/favicon/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/static/img/favicon/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="192x192" href="static/img/favicon/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/static/img/favicon/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="32x32" href="static/img/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/static/img/favicon/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="96x96" href="static/img/favicon/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/static/img/favicon/favicon-16x16.png"> <link rel="icon" type="image/png" sizes="16x16" href="static/img/favicon/favicon-16x16.png">
<link rel="manifest" href="/static/img/favicon/manifest.json"> <link rel="manifest" href="static/img/favicon/manifest.json">
<meta name="referrer" content="no-referrer"> <meta name="referrer" content="no-referrer">
<meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/static/img/favicon/ms-icon-144x144.png"> <meta name="msapplication-TileImage" content="static/img/favicon/ms-icon-144x144.png">
<script type="text/javascript" src="/static/js/autocomplete.js"></script> <script type="text/javascript" src="static/js/autocomplete.js"></script>
<script type="text/javascript" src="/static/js/controller.js"></script> <script type="text/javascript" src="static/js/controller.js"></script>
<link rel="search" href="/opensearch.xml" type="application/opensearchdescription+xml" title="Whoogle Search"> <link rel="search" href="opensearch.xml" type="application/opensearchdescription+xml" title="Whoogle Search">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/static/css/{{ 'search-dark' if config.dark else 'search' }}.css"> <link rel="stylesheet" href="static/css/{{ 'search-dark' if config.dark else 'search' }}.css">
<link rel="stylesheet" href="/static/css/main.css"> <link rel="stylesheet" href="static/css/main.css">
{% if config.dark %} {% if config.dark %}
<link rel="stylesheet" href="/static/css/dark-theme.css"/> <link rel="stylesheet" href="static/css/dark-theme.css"/>
{% endif %} {% endif %}
<title>Whoogle Search</title> <title>Whoogle Search</title>
</head> </head>
@ -36,8 +36,8 @@
{% endif %} {% endif %}
</script> </script>
<div class="search-container"> <div class="search-container">
<img class="logo" src="/static/img/logo.png"> <img class="logo" src="static/img/logo.png">
<form id="search-form" action="/search" method="{{ 'get' if config.get_only else 'post' }}"> <form id="search-form" action="search" method="{{ 'get' if config.get_only else 'post' }}">
<div class="search-fields"> <div class="search-fields">
<div class="autocomplete"> <div class="autocomplete">
<input type="text" name="q" id="search-bar" autofocus="autofocus" autocomplete="off"> <input type="text" name="q" id="search-bar" autofocus="autofocus" autocomplete="off">
@ -49,7 +49,7 @@
<button id="config-collapsible" class="collapsible">Configuration</button> <button id="config-collapsible" class="collapsible">Configuration</button>
<div class="content"> <div class="content">
<div class="config-fields"> <div class="config-fields">
<form id="config-form" action="/config" method="post"> <form id="config-form" action="config" method="post">
<div class="config-div"> <div class="config-div">
<label for="config-ctry">Filter Results by Country: </label> <label for="config-ctry">Filter Results by Country: </label>
<select name="ctry" id="config-ctry"> <select name="ctry" id="config-ctry">