Removed referrer from links, refacored routes
Added <meta name="referrer" content="no-referrer"> to all whoogle templates Refactored search route to use conditionally use either request.args or request.form, depending on rest call (get vs post respectively)main
parent
ab317fa0d0
commit
d01f56ea03
|
@ -23,8 +23,9 @@ Contents
|
|||
- No tracking/linking of your personal IP address
|
||||
- No AMP links
|
||||
- No URL tracking tags (i.e. utm=%s)
|
||||
- No referrer header
|
||||
- POST request search queries (when possible)
|
||||
- View images at full res with one click
|
||||
- View images at full res without site redirect (currently mobile only)
|
||||
- Dark mode
|
||||
- Randomly generated User Agent
|
||||
- Easy to install/deploy
|
||||
|
|
|
@ -20,6 +20,11 @@ def before_request_func():
|
|||
g.user_request = Request(request.headers.get('User-Agent'))
|
||||
|
||||
|
||||
@app.errorhandler(404)
|
||||
def unknown_page(e):
|
||||
return redirect('/')
|
||||
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def index():
|
||||
bg = '#000' if 'dark' in user_config and user_config['dark'] else '#fff'
|
||||
|
@ -32,7 +37,7 @@ def opensearch():
|
|||
if url_root.endswith('/'):
|
||||
url_root = url_root[:-1]
|
||||
|
||||
template = render_template('opensearch.xml', whoogle_url=url_root)
|
||||
template = render_template('opensearch.xml', main_url=url_root)
|
||||
response = make_response(template)
|
||||
response.headers['Content-Type'] = 'application/xml'
|
||||
return response
|
||||
|
@ -40,25 +45,23 @@ def opensearch():
|
|||
|
||||
@app.route('/search', methods=['GET', 'POST'])
|
||||
def search():
|
||||
if request.method == 'GET':
|
||||
q = request.args.get('q')
|
||||
if q is None:
|
||||
request_params = request.args if request.method == 'GET' else request.form
|
||||
q = request_params.get('q')
|
||||
|
||||
if q is None or len(q) == 0:
|
||||
return redirect('/')
|
||||
else:
|
||||
# Attempt to decrypt if this is an internal link
|
||||
try:
|
||||
q = Fernet(app.secret_key).decrypt(q.encode()).decode()
|
||||
except InvalidToken:
|
||||
pass
|
||||
else:
|
||||
q = request.form['q']
|
||||
|
||||
if q is None or len(q) == 0:
|
||||
return render_template('error.html')
|
||||
|
||||
user_agent = request.headers.get('User-Agent')
|
||||
mobile = 'Android' in user_agent or 'iPhone' in user_agent
|
||||
|
||||
content_filter = Filter(mobile, user_config, secret_key=app.secret_key)
|
||||
full_query = gen_query(q, request.args, content_filter.near)
|
||||
full_query = gen_query(q, request_params, content_filter.near)
|
||||
get_body = g.user_request.send(query=full_query)
|
||||
|
||||
results = content_filter.reskin(get_body)
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
<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">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<title>{{ query }} - Whoogle Search</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
<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="manifest" href="/static/img/favicon/manifest.json">
|
||||
<meta name="referrer" content="no-referrer">
|
||||
<meta name="msapplication-TileColor" content="#ffffff">
|
||||
<meta name="msapplication-TileImage" content="/static/img/favicon/ms-icon-144x144.png">
|
||||
<script type="text/javascript" src="/static/js/controller.js"></script>
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
<Description>Whoogle: A lightweight, deployable Google search proxy for desktop/mobile that removes Javascript, AMP links, and ads</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<Image width="32" height="32" type="image/x-icon">/static/img/favicon/favicon-32x32.png</Image>
|
||||
<Url type="text/html" method="post" template="{{ whoogle_url }}/search">
|
||||
<Url type="text/html" method="post" template="{{ main_url }}/search">
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
</Url>
|
||||
<Url type="application/x-suggestions+json" template="{{ whoogle_url }}/search"/>
|
||||
<moz:SearchForm>{{ whoogle_url }}/search</moz:SearchForm>
|
||||
<Url type="application/x-suggestions+json" template="{{ main_url }}/search"/>
|
||||
<moz:SearchForm>{{ main_url }}/search</moz:SearchForm>
|
||||
</OpenSearchDescription>
|
||||
|
||||
|
|
Loading…
Reference in New Issue