diff options
author | Adam Tauber <asciimoo@gmail.com> | 2014-06-24 16:30:04 +0200 |
---|---|---|
committer | Adam Tauber <asciimoo@gmail.com> | 2014-06-24 16:30:04 +0200 |
commit | 96c8b20a045f62205a3b9a03113086f0fcfbc579 (patch) | |
tree | b544d925aaf847b71c998d7f7a610abe73aeb686 /searx/webapp.py | |
parent | b44643222f85764399a4eac72541783eb8c2868f (diff) | |
download | searxng-96c8b20a045f62205a3b9a03113086f0fcfbc579.tar.gz searxng-96c8b20a045f62205a3b9a03113086f0fcfbc579.zip |
[enh] https rewrite basics
Diffstat (limited to 'searx/webapp.py')
-rw-r--r-- | searx/webapp.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 158dc35a7..000543e06 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -41,13 +41,16 @@ from searx.engines import ( from searx.utils import ( UnicodeWriter, highlight_content, html_to_text, get_themes ) +from searx.https_rewrite import https_rules from searx.languages import language_codes from searx.search import Search from searx.autocomplete import backends as autocomplete_backends -static_path, templates_path, themes = get_themes(settings['themes_path'] if \ - settings.get('themes_path', None) else searx_dir) +static_path, templates_path, themes =\ + get_themes(settings['themes_path'] + if settings.get('themes_path') + else searx_dir) default_theme = settings['default_theme'] if \ settings.get('default_theme', None) else 'default' @@ -192,8 +195,20 @@ def index(): search.lang) for result in search.results: + if not search.paging and engines[result['engine']].paging: search.paging = True + + if settings['server']['https_rewrite']\ + and result['parsed_url'].scheme == 'http': + + for http_regex, https_url in https_rules: + if http_regex.match(result['url']): + result['url'] = http_regex.sub(https_url, result['url']) + # TODO result['parsed_url'].scheme + break + + # HTTPS rewrite if search.request_data.get('format', 'html') == 'html': if 'content' in result: result['content'] = highlight_content(result['content'], @@ -206,6 +221,7 @@ def index(): # removing html content and whitespace duplications result['title'] = ' '.join(html_to_text(result['title']) .strip().split()) + if len(result['url']) > 74: url_parts = result['url'][:35], result['url'][-35:] result['pretty_url'] = u'{0}[...]{1}'.format(*url_parts) |