forked from zaclys/searxng
[enh] image proxification
This commit is contained in:
parent
60eb831966
commit
01143f48c5
@ -8,6 +8,7 @@ server:
|
||||
default_theme : oscar # ui theme
|
||||
https_rewrite : True # Force rewrite result urls. See searx/https_rewrite.py
|
||||
useragent_suffix : "" # suffix of searx_useragent, could contain informations like an email address to the administrator
|
||||
image_proxy : False # Proxying image results through searx
|
||||
|
||||
engines:
|
||||
- name : wikipedia
|
||||
|
@ -29,6 +29,7 @@ import os
|
||||
from datetime import datetime, timedelta
|
||||
from requests import get as http_get
|
||||
from itertools import chain
|
||||
from urllib import urlencode
|
||||
from flask import (
|
||||
Flask, request, render_template, url_for, Response, make_response,
|
||||
redirect, send_from_directory
|
||||
@ -204,6 +205,18 @@ def url_for_theme(endpoint, override_theme=None, **values):
|
||||
return url_for(endpoint, **values)
|
||||
|
||||
|
||||
def image_proxify(url):
|
||||
|
||||
if url.startswith('//'):
|
||||
url = 'https:' + url
|
||||
|
||||
if not settings['server'].get('image_proxy') and not request.cookies.get('image_proxy'):
|
||||
return url
|
||||
|
||||
return '{0}?{1}'.format(url_for('image_proxy'),
|
||||
urlencode(dict(url=url)))
|
||||
|
||||
|
||||
def render(template_name, override_theme=None, **kwargs):
|
||||
blocked_engines = request.cookies.get('blocked_engines', '').split(',')
|
||||
|
||||
@ -250,6 +263,8 @@ def render(template_name, override_theme=None, **kwargs):
|
||||
# override url_for function in templates
|
||||
kwargs['url_for'] = url_for_theme
|
||||
|
||||
kwargs['image_proxify'] = image_proxify
|
||||
|
||||
kwargs['get_result_template'] = get_result_template
|
||||
|
||||
kwargs['theme'] = get_current_theme_name(override=override_theme)
|
||||
|
Loading…
Reference in New Issue
Block a user