diff --git a/.travis.yml b/.travis.yml index 65f8ef235..0a174ff66 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ cache: - npm - directories: - $HOME/.cache/pip +addons: + firefox: "latest" language: python python: - "2.7" @@ -12,6 +14,9 @@ before_install: - "sh -e /etc/init.d/xvfb start" - npm install less grunt-cli - ( cd searx/static/themes/oscar;npm install; cd - ) + - mkdir -p ~/drivers; export PATH=~/drivers:$PATH; + - GECKODRIVER_URL="https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz"; + - FILE=`mktemp`; wget "$GECKODRIVER_URL" -qO $FILE && tar xz -C ~/drivers -f $FILE geckodriver; rm $FILE; chmod 777 ~/drivers/geckodriver; install: - ./manage.sh update_dev_packages - pip install coveralls diff --git a/AUTHORS.rst b/AUTHORS.rst index 505b28eeb..0c224088f 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -58,3 +58,5 @@ generally made searx better: - marc @a01200356 - Harry Wood @harry-wood - Thomas Renard @threnard +- Pydo ``_ +- Athemis ``_ diff --git a/manage.sh b/manage.sh index 75ba32024..11f2df04d 100755 --- a/manage.sh +++ b/manage.sh @@ -53,8 +53,8 @@ build_style() { styles() { echo '[!] Building styles' - build_style themes/default/less/style.less themes/default/css/style.css - build_style themes/default/less/style-rtl.less themes/default/css/style-rtl.css + build_style themes/legacy/less/style.less themes/legacy/css/style.css + build_style themes/legacy/less/style-rtl.less themes/legacy/css/style-rtl.css build_style themes/courgette/less/style.less themes/courgette/css/style.css build_style themes/courgette/less/style-rtl.less themes/courgette/css/style-rtl.css build_style less/bootstrap/bootstrap.less css/bootstrap.min.css diff --git a/requirements-dev.txt b/requirements-dev.txt index 580ef63e5..543521895 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,8 +3,8 @@ mock==2.0.0 nose2[coverage-plugin] pep8==1.7.0 plone.testing==5.0.0 -robotframework-selenium2library==1.7.4 +robotframework-selenium2library==1.8.0 robotsuite==1.7.0 -transifex-client==0.11 +transifex-client==0.12.2 unittest2==1.1.0 -zope.testrunner==4.4.10 +zope.testrunner==4.5.1 diff --git a/requirements.txt b/requirements.txt index 029c0cffa..c4cbe4e04 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -certifi==2016.2.28 +certifi==2016.9.26 flask==0.11.1 flask-babel==0.11.1 lxml==3.6.0 diff --git a/searx/engines/__init__.py b/searx/engines/__init__.py index 782b622b0..14376c31f 100644 --- a/searx/engines/__init__.py +++ b/searx/engines/__init__.py @@ -57,11 +57,17 @@ def load_module(filename): def load_engine(engine_data): - engine_name = engine_data['engine'] + + if '_' in engine_data['name']: + logger.error('Engine name conains underscore: "{}"'.format(engine_data['name'])) + sys.exit(1) + + engine_module = engine_data['engine'] + try: - engine = load_module(engine_name + '.py') + engine = load_module(engine_module + '.py') except: - logger.exception('Cannot load engine "{}"'.format(engine_name)) + logger.exception('Cannot load engine "{}"'.format(engine_module)) return None for param_name in engine_data: diff --git a/searx/engines/digbt.py b/searx/engines/digbt.py index c35327e8c..b55d7747a 100644 --- a/searx/engines/digbt.py +++ b/searx/engines/digbt.py @@ -40,7 +40,7 @@ def response(resp): results = list() for result in search_res: url = urljoin(URL, result.xpath('.//a[@title]/@href')[0]) - title = result.xpath('.//a[@title]/text()')[0] + title = extract_text(result.xpath('.//a[@title]')) content = extract_text(result.xpath('.//div[@class="files"]')) files_data = extract_text(result.xpath('.//div[@class="tail"]')).split() filesize = get_torrent_size(files_data[FILESIZE], files_data[FILESIZE_MULTIPLIER]) diff --git a/searx/engines/kickass.py b/searx/engines/kickass.py index 4c5d24008..9cd8284da 100644 --- a/searx/engines/kickass.py +++ b/searx/engines/kickass.py @@ -16,13 +16,14 @@ from urllib import quote from lxml import html from operator import itemgetter from searx.engines.xpath import extract_text +from searx.utils import get_torrent_size, convert_str_to_int # engine dependent config categories = ['videos', 'music', 'files'] paging = True # search-url -url = 'https://kickass.to/' +url = 'https://kickass.cd/' search_url = url + 'search/{search_term}/{pageno}/' # specific xpath variables @@ -57,41 +58,16 @@ def response(resp): href = urljoin(url, link.attrib['href']) title = extract_text(link) content = escape(extract_text(result.xpath(content_xpath))) - seed = result.xpath('.//td[contains(@class, "green")]/text()')[0] - leech = result.xpath('.//td[contains(@class, "red")]/text()')[0] - filesize = result.xpath('.//td[contains(@class, "nobr")]/text()')[0] - filesize_multiplier = result.xpath('.//td[contains(@class, "nobr")]//span/text()')[0] - files = result.xpath('.//td[contains(@class, "center")][2]/text()')[0] + seed = extract_text(result.xpath('.//td[contains(@class, "green")]')) + leech = extract_text(result.xpath('.//td[contains(@class, "red")]')) + filesize_info = extract_text(result.xpath('.//td[contains(@class, "nobr")]')) + files = extract_text(result.xpath('.//td[contains(@class, "center")][2]')) - # convert seed to int if possible - if seed.isdigit(): - seed = int(seed) - else: - seed = 0 + seed = convert_str_to_int(seed) + leech = convert_str_to_int(leech) - # convert leech to int if possible - if leech.isdigit(): - leech = int(leech) - else: - leech = 0 - - # convert filesize to byte if possible - try: - filesize = float(filesize) - - # convert filesize to byte - if filesize_multiplier == 'TB': - filesize = int(filesize * 1024 * 1024 * 1024 * 1024) - elif filesize_multiplier == 'GB': - filesize = int(filesize * 1024 * 1024 * 1024) - elif filesize_multiplier == 'MB': - filesize = int(filesize * 1024 * 1024) - elif filesize_multiplier == 'KB': - filesize = int(filesize * 1024) - except: - filesize = None - - # convert files to int if possible + filesize, filesize_multiplier = filesize_info.split() + filesize = get_torrent_size(filesize, filesize_multiplier) if files.isdigit(): files = int(files) else: diff --git a/searx/engines/pdbe.py b/searx/engines/pdbe.py new file mode 100644 index 000000000..f784e106f --- /dev/null +++ b/searx/engines/pdbe.py @@ -0,0 +1,109 @@ +""" + PDBe (Protein Data Bank in Europe) + + @website https://www.ebi.ac.uk/pdbe + @provide-api yes (https://www.ebi.ac.uk/pdbe/api/doc/search.html), + unlimited + @using-api yes + @results python dictionary (from json) + @stable yes + @parse url, title, content, img_src +""" + +from json import loads +from flask_babel import gettext + +categories = ['science'] + +hide_obsolete = False + +# status codes of unpublished entries +pdb_unpublished_codes = ['HPUB', 'HOLD', 'PROC', 'WAIT', 'AUTH', 'AUCO', 'REPL', 'POLC', 'REFI', 'TRSF', 'WDRN'] +# url for api query +pdbe_solr_url = 'https://www.ebi.ac.uk/pdbe/search/pdb/select?' +# base url for results +pdbe_entry_url = 'https://www.ebi.ac.uk/pdbe/entry/pdb/{pdb_id}' +# link to preview image of structure +pdbe_preview_url = 'https://www.ebi.ac.uk/pdbe/static/entry/{pdb_id}_deposited_chain_front_image-200x200.png' + + +def request(query, params): + + params['url'] = pdbe_solr_url + params['method'] = 'POST' + params['data'] = { + 'q': query, + 'wt': "json" # request response in parsable format + } + return params + + +def construct_body(result): + # set title + title = result['title'] + + # construct content body + content = """{title}
{authors} {journal} {volume} {page} ({year})""" + + # replace placeholders with actual content + try: + if result['journal']: + content = content.format( + title=result['citation_title'], + authors=result['entry_author_list'][0], journal=result['journal'], volume=result['journal_volume'], + page=result['journal_page'], year=result['citation_year']) + else: + content = content.format( + title=result['citation_title'], + authors=result['entry_author_list'][0], journal='', volume='', page='', year=result['release_year']) + img_src = pdbe_preview_url.format(pdb_id=result['pdb_id']) + except (KeyError): + content = None + img_src = None + + # construct url for preview image + try: + img_src = pdbe_preview_url.format(pdb_id=result['pdb_id']) + except (KeyError): + img_src = None + + return [title, content, img_src] + + +def response(resp): + + results = [] + json = loads(resp.text)['response']['docs'] + + # parse results + for result in json: + # catch obsolete entries and mark them accordingly + if result['status'] in pdb_unpublished_codes: + continue + if hide_obsolete: + continue + if result['status'] == 'OBS': + # expand title to add some sort of warning message + title = gettext('{title} (OBSOLETE)').format(title=result['title']) + superseded_url = pdbe_entry_url.format(pdb_id=result['superseded_by']) + + # since we can't construct a proper body from the response, we'll make up our own + msg_superseded = gettext("This entry has been superseded by") + content = '{msg_superseded} \{pdb_id}'.format( + msg_superseded=msg_superseded, + url=superseded_url, + pdb_id=result['superseded_by'], ) + + # obsoleted entries don't have preview images + img_src = None + else: + title, content, img_src = construct_body(result) + + results.append({ + 'url': pdbe_entry_url.format(pdb_id=result['pdb_id']), + 'title': title, + 'content': content, + 'img_src': img_src + }) + + return results diff --git a/searx/engines/seedpeer.py b/searx/engines/seedpeer.py new file mode 100644 index 000000000..854ebba03 --- /dev/null +++ b/searx/engines/seedpeer.py @@ -0,0 +1,78 @@ +# Seedpeer (Videos, Music, Files) +# +# @website http://seedpeer.eu +# @provide-api no (nothing found) +# +# @using-api no +# @results HTML (using search portal) +# @stable yes (HTML can change) +# @parse url, title, content, seed, leech, magnetlink + +from urlparse import urljoin +from cgi import escape +from urllib import quote +from lxml import html +from operator import itemgetter +from searx.engines.xpath import extract_text + + +url = 'http://www.seedpeer.eu/' +search_url = url + 'search/{search_term}/7/{page_no}.html' +# specific xpath variables +torrent_xpath = '//*[@id="body"]/center/center/table[2]/tr/td/a' +alternative_torrent_xpath = '//*[@id="body"]/center/center/table[1]/tr/td/a' +title_xpath = '//*[@id="body"]/center/center/table[2]/tr/td/a/text()' +alternative_title_xpath = '//*[@id="body"]/center/center/table/tr/td/a' +seeds_xpath = '//*[@id="body"]/center/center/table[2]/tr/td[4]/font/text()' +alternative_seeds_xpath = '//*[@id="body"]/center/center/table/tr/td[4]/font/text()' +peers_xpath = '//*[@id="body"]/center/center/table[2]/tr/td[5]/font/text()' +alternative_peers_xpath = '//*[@id="body"]/center/center/table/tr/td[5]/font/text()' +age_xpath = '//*[@id="body"]/center/center/table[2]/tr/td[2]/text()' +alternative_age_xpath = '//*[@id="body"]/center/center/table/tr/td[2]/text()' +size_xpath = '//*[@id="body"]/center/center/table[2]/tr/td[3]/text()' +alternative_size_xpath = '//*[@id="body"]/center/center/table/tr/td[3]/text()' + + +# do search-request +def request(query, params): + params['url'] = search_url.format(search_term=quote(query), + page_no=params['pageno'] - 1) + return params + + +# get response from search-request +def response(resp): + results = [] + dom = html.fromstring(resp.text) + torrent_links = dom.xpath(torrent_xpath) + if len(torrent_links) > 0: + seeds = dom.xpath(seeds_xpath) + peers = dom.xpath(peers_xpath) + titles = dom.xpath(title_xpath) + sizes = dom.xpath(size_xpath) + ages = dom.xpath(age_xpath) + else: # under ~5 results uses a different xpath + torrent_links = dom.xpath(alternative_torrent_xpath) + seeds = dom.xpath(alternative_seeds_xpath) + peers = dom.xpath(alternative_peers_xpath) + titles = dom.xpath(alternative_title_xpath) + sizes = dom.xpath(alternative_size_xpath) + ages = dom.xpath(alternative_age_xpath) + # return empty array if nothing is found + if not torrent_links: + return [] + + # parse results + for index, result in enumerate(torrent_links): + link = result.attrib.get('href') + href = urljoin(url, link) + results.append({'url': href, + 'title': titles[index].text_content(), + 'content': '{}, {}'.format(sizes[index], ages[index]), + 'seed': seeds[index], + 'leech': peers[index], + + 'template': 'torrent.html'}) + + # return results sorted by seeder + return sorted(results, key=itemgetter('seed'), reverse=True) diff --git a/searx/settings.yml b/searx/settings.yml index 308a0bd45..ba7ae428b 100644 --- a/searx/settings.yml +++ b/searx/settings.yml @@ -18,6 +18,12 @@ ui: default_theme : oscar # ui theme default_locale : "" # Default interface locale - leave blank to detect from browser information or use codes from the 'locales' config section +# searx supports result proxification using an external service: https://github.com/asciimoo/morty +# uncomment below section if you have running morty proxy +#result_proxy: +# url : http://127.0.0.1:3000/ +# key : your_morty_proxy_key + outgoing: # communication with search engines request_timeout : 2.0 # seconds useragent_suffix : "" # suffix of searx_useragent, could contain informations like an email address to the administrator @@ -301,6 +307,12 @@ engines: timeout : 6.0 disabled : True + - name: kickass + engine : kickass + shortcut : kc + timeout : 4.0 + disabled : True + - name : microsoft academic engine : json_engine paging : True @@ -339,6 +351,13 @@ engines: disabled : True shortcut : or + - name : pdbe + engine : pdbe + shortcut : pdb +# Hide obsolete PDB entries. +# Default is not to hide obsolete structures +# hide_obsolete : False + - name : photon engine : photon shortcut : ph @@ -377,7 +396,7 @@ engines: timeout : 10.0 disabled : True - - name : scanr_structures + - name : scanr structures shortcut: scs engine : scanr_structures disabled : True @@ -495,6 +514,12 @@ engines: timeout: 6.0 categories : science + - name : seedpeer + engine : seedpeer + shortcut: speu + categories: files, music, videos + disabled: True + - name : dictzone engine : dictzone shortcut : dc diff --git a/searx/settings_robot.yml b/searx/settings_robot.yml index 7c7c4eec2..43dc9b00a 100644 --- a/searx/settings_robot.yml +++ b/searx/settings_robot.yml @@ -15,7 +15,7 @@ server: ui: themes_path : "" - default_theme : default + default_theme : legacy default_locale : "" outgoing: @@ -23,12 +23,12 @@ outgoing: useragent_suffix : "" engines: - - name : general_dummy + - name : general dummy engine : dummy categories : general shortcut : gd - - name : dummy_dummy + - name : dummy dummy engine : dummy categories : dummy shortcut : dd diff --git a/searx/static/themes/default/css/style-rtl.css b/searx/static/themes/legacy/css/style-rtl.css similarity index 100% rename from searx/static/themes/default/css/style-rtl.css rename to searx/static/themes/legacy/css/style-rtl.css diff --git a/searx/static/themes/default/css/style.css b/searx/static/themes/legacy/css/style.css similarity index 100% rename from searx/static/themes/default/css/style.css rename to searx/static/themes/legacy/css/style.css diff --git a/searx/static/themes/default/img/favicon.png b/searx/static/themes/legacy/img/favicon.png similarity index 100% rename from searx/static/themes/default/img/favicon.png rename to searx/static/themes/legacy/img/favicon.png diff --git a/searx/static/themes/default/img/github_ribbon.png b/searx/static/themes/legacy/img/github_ribbon.png similarity index 100% rename from searx/static/themes/default/img/github_ribbon.png rename to searx/static/themes/legacy/img/github_ribbon.png diff --git a/searx/static/themes/default/img/icons/icon_500px.ico b/searx/static/themes/legacy/img/icons/icon_500px.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_500px.ico rename to searx/static/themes/legacy/img/icons/icon_500px.ico diff --git a/searx/static/themes/default/img/icons/icon_bing.ico b/searx/static/themes/legacy/img/icons/icon_bing.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_bing.ico rename to searx/static/themes/legacy/img/icons/icon_bing.ico diff --git a/searx/static/themes/default/img/icons/icon_dailymotion.ico b/searx/static/themes/legacy/img/icons/icon_dailymotion.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_dailymotion.ico rename to searx/static/themes/legacy/img/icons/icon_dailymotion.ico diff --git a/searx/static/themes/default/img/icons/icon_deezer.ico b/searx/static/themes/legacy/img/icons/icon_deezer.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_deezer.ico rename to searx/static/themes/legacy/img/icons/icon_deezer.ico diff --git a/searx/static/themes/default/img/icons/icon_deviantart.ico b/searx/static/themes/legacy/img/icons/icon_deviantart.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_deviantart.ico rename to searx/static/themes/legacy/img/icons/icon_deviantart.ico diff --git a/searx/static/themes/default/img/icons/icon_digg.ico b/searx/static/themes/legacy/img/icons/icon_digg.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_digg.ico rename to searx/static/themes/legacy/img/icons/icon_digg.ico diff --git a/searx/static/themes/default/img/icons/icon_duckduckgo.ico b/searx/static/themes/legacy/img/icons/icon_duckduckgo.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_duckduckgo.ico rename to searx/static/themes/legacy/img/icons/icon_duckduckgo.ico diff --git a/searx/static/themes/default/img/icons/icon_flickr.ico b/searx/static/themes/legacy/img/icons/icon_flickr.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_flickr.ico rename to searx/static/themes/legacy/img/icons/icon_flickr.ico diff --git a/searx/static/themes/default/img/icons/icon_github.ico b/searx/static/themes/legacy/img/icons/icon_github.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_github.ico rename to searx/static/themes/legacy/img/icons/icon_github.ico diff --git a/searx/static/themes/default/img/icons/icon_google play apps.ico b/searx/static/themes/legacy/img/icons/icon_google play apps.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_google play apps.ico rename to searx/static/themes/legacy/img/icons/icon_google play apps.ico diff --git a/searx/static/themes/default/img/icons/icon_google play movies.ico b/searx/static/themes/legacy/img/icons/icon_google play movies.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_google play movies.ico rename to searx/static/themes/legacy/img/icons/icon_google play movies.ico diff --git a/searx/static/themes/default/img/icons/icon_google play music.ico b/searx/static/themes/legacy/img/icons/icon_google play music.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_google play music.ico rename to searx/static/themes/legacy/img/icons/icon_google play music.ico diff --git a/searx/static/themes/default/img/icons/icon_google.ico b/searx/static/themes/legacy/img/icons/icon_google.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_google.ico rename to searx/static/themes/legacy/img/icons/icon_google.ico diff --git a/searx/static/themes/default/img/icons/icon_kickass.ico b/searx/static/themes/legacy/img/icons/icon_kickass.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_kickass.ico rename to searx/static/themes/legacy/img/icons/icon_kickass.ico diff --git a/searx/static/themes/default/img/icons/icon_openstreetmap.ico b/searx/static/themes/legacy/img/icons/icon_openstreetmap.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_openstreetmap.ico rename to searx/static/themes/legacy/img/icons/icon_openstreetmap.ico diff --git a/searx/static/themes/default/img/icons/icon_searchcode code.ico b/searx/static/themes/legacy/img/icons/icon_searchcode code.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_searchcode code.ico rename to searx/static/themes/legacy/img/icons/icon_searchcode code.ico diff --git a/searx/static/themes/default/img/icons/icon_searchcode doc.ico b/searx/static/themes/legacy/img/icons/icon_searchcode doc.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_searchcode doc.ico rename to searx/static/themes/legacy/img/icons/icon_searchcode doc.ico diff --git a/searx/static/themes/default/img/icons/icon_searchcode.ico b/searx/static/themes/legacy/img/icons/icon_searchcode.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_searchcode.ico rename to searx/static/themes/legacy/img/icons/icon_searchcode.ico diff --git a/searx/static/themes/default/img/icons/icon_soundcloud.ico b/searx/static/themes/legacy/img/icons/icon_soundcloud.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_soundcloud.ico rename to searx/static/themes/legacy/img/icons/icon_soundcloud.ico diff --git a/searx/static/themes/default/img/icons/icon_stackoverflow.ico b/searx/static/themes/legacy/img/icons/icon_stackoverflow.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_stackoverflow.ico rename to searx/static/themes/legacy/img/icons/icon_stackoverflow.ico diff --git a/searx/static/themes/default/img/icons/icon_startpage.ico b/searx/static/themes/legacy/img/icons/icon_startpage.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_startpage.ico rename to searx/static/themes/legacy/img/icons/icon_startpage.ico diff --git a/searx/static/themes/default/img/icons/icon_subtitleseeker.ico b/searx/static/themes/legacy/img/icons/icon_subtitleseeker.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_subtitleseeker.ico rename to searx/static/themes/legacy/img/icons/icon_subtitleseeker.ico diff --git a/searx/static/themes/default/img/icons/icon_twitter.ico b/searx/static/themes/legacy/img/icons/icon_twitter.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_twitter.ico rename to searx/static/themes/legacy/img/icons/icon_twitter.ico diff --git a/searx/static/themes/default/img/icons/icon_vimeo.ico b/searx/static/themes/legacy/img/icons/icon_vimeo.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_vimeo.ico rename to searx/static/themes/legacy/img/icons/icon_vimeo.ico diff --git a/searx/static/themes/default/img/icons/icon_wikipedia.ico b/searx/static/themes/legacy/img/icons/icon_wikipedia.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_wikipedia.ico rename to searx/static/themes/legacy/img/icons/icon_wikipedia.ico diff --git a/searx/static/themes/default/img/icons/icon_yahoo.ico b/searx/static/themes/legacy/img/icons/icon_yahoo.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_yahoo.ico rename to searx/static/themes/legacy/img/icons/icon_yahoo.ico diff --git a/searx/static/themes/default/img/icons/icon_youtube.ico b/searx/static/themes/legacy/img/icons/icon_youtube.ico similarity index 100% rename from searx/static/themes/default/img/icons/icon_youtube.ico rename to searx/static/themes/legacy/img/icons/icon_youtube.ico diff --git a/searx/static/themes/default/img/preference-icon.png b/searx/static/themes/legacy/img/preference-icon.png similarity index 100% rename from searx/static/themes/default/img/preference-icon.png rename to searx/static/themes/legacy/img/preference-icon.png diff --git a/searx/static/themes/default/img/search-icon.png b/searx/static/themes/legacy/img/search-icon.png similarity index 100% rename from searx/static/themes/default/img/search-icon.png rename to searx/static/themes/legacy/img/search-icon.png diff --git a/searx/static/themes/default/img/searx.png b/searx/static/themes/legacy/img/searx.png similarity index 100% rename from searx/static/themes/default/img/searx.png rename to searx/static/themes/legacy/img/searx.png diff --git a/searx/static/themes/default/img/searx_logo.svg b/searx/static/themes/legacy/img/searx_logo.svg similarity index 100% rename from searx/static/themes/default/img/searx_logo.svg rename to searx/static/themes/legacy/img/searx_logo.svg diff --git a/searx/static/themes/default/js/searx.js b/searx/static/themes/legacy/js/searx.js similarity index 100% rename from searx/static/themes/default/js/searx.js rename to searx/static/themes/legacy/js/searx.js diff --git a/searx/static/themes/default/less/autocompleter.less b/searx/static/themes/legacy/less/autocompleter.less similarity index 100% rename from searx/static/themes/default/less/autocompleter.less rename to searx/static/themes/legacy/less/autocompleter.less diff --git a/searx/static/themes/default/less/code.less b/searx/static/themes/legacy/less/code.less similarity index 100% rename from searx/static/themes/default/less/code.less rename to searx/static/themes/legacy/less/code.less diff --git a/searx/static/themes/default/less/definitions.less b/searx/static/themes/legacy/less/definitions.less similarity index 100% rename from searx/static/themes/default/less/definitions.less rename to searx/static/themes/legacy/less/definitions.less diff --git a/searx/static/themes/default/less/mixins.less b/searx/static/themes/legacy/less/mixins.less similarity index 100% rename from searx/static/themes/default/less/mixins.less rename to searx/static/themes/legacy/less/mixins.less diff --git a/searx/static/themes/default/less/search.less b/searx/static/themes/legacy/less/search.less similarity index 100% rename from searx/static/themes/default/less/search.less rename to searx/static/themes/legacy/less/search.less diff --git a/searx/static/themes/default/less/style-rtl.less b/searx/static/themes/legacy/less/style-rtl.less similarity index 100% rename from searx/static/themes/default/less/style-rtl.less rename to searx/static/themes/legacy/less/style-rtl.less diff --git a/searx/static/themes/default/less/style.less b/searx/static/themes/legacy/less/style.less similarity index 100% rename from searx/static/themes/default/less/style.less rename to searx/static/themes/legacy/less/style.less diff --git a/searx/templates/courgette/base.html b/searx/templates/courgette/base.html index b2c70a3b7..8e272585c 100644 --- a/searx/templates/courgette/base.html +++ b/searx/templates/courgette/base.html @@ -22,7 +22,7 @@ {% endblock %} {% block meta %}{% endblock %} {% block head %} - + {% endblock %} + + +
Home > Torrent search > Narcos season 2 | page 1
+ + + + + \ No newline at end of file diff --git a/tests/unit/engines/test_digbt.py b/tests/unit/engines/test_digbt.py index 867188ed9..31a1b03a4 100644 --- a/tests/unit/engines/test_digbt.py +++ b/tests/unit/engines/test_digbt.py @@ -28,7 +28,9 @@ class TestDigBTEngine(SearxTestCase): - + @@ -97,7 +97,7 @@ class TestKickassEngine(SearxTestCase): self.assertEqual(type(results), list) self.assertEqual(len(results), 1) self.assertEqual(results[0]['title'], 'This should be the title') - self.assertEqual(results[0]['url'], 'https://kickass.to/url.html') + self.assertEqual(results[0]['url'], 'https://kickass.cd/url.html') self.assertEqual(results[0]['content'], 'Posted by riri in Other > Unsorted') self.assertEqual(results[0]['seed'], 10) self.assertEqual(results[0]['leech'], 1) @@ -191,7 +191,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -235,7 +235,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -279,7 +279,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -323,7 +323,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -367,7 +367,7 @@ class TestKickassEngine(SearxTestCase): - + @@ -380,17 +380,17 @@ class TestKickassEngine(SearxTestCase): self.assertEqual(type(results), list) self.assertEqual(len(results), 5) self.assertEqual(results[0]['title'], 'This should be the title') - self.assertEqual(results[0]['url'], 'https://kickass.to/url.html') + self.assertEqual(results[0]['url'], 'https://kickass.cd/url.html') self.assertEqual(results[0]['content'], 'Posted by riri in Other > Unsorted') self.assertEqual(results[0]['seed'], 10) self.assertEqual(results[0]['leech'], 1) self.assertEqual(results[0]['files'], 4) self.assertEqual(results[0]['magnetlink'], 'magnet:?xt=urn:btih:MAGNETURL&dn=test') self.assertEqual(results[0]['torrentfile'], 'http://torcache.net/torrent/53917.torrent?title=test') - self.assertEqual(results[0]['filesize'], 1024) - self.assertEqual(results[1]['filesize'], 1048576) - self.assertEqual(results[2]['filesize'], 1073741824) - self.assertEqual(results[3]['filesize'], 1099511627776) + self.assertEqual(results[0]['filesize'], 1000) + self.assertEqual(results[1]['filesize'], 1000000) + self.assertEqual(results[2]['filesize'], 1000000000) + self.assertEqual(results[3]['filesize'], 1000000000000) self.assertEqual(results[4]['seed'], 0) self.assertEqual(results[4]['leech'], 0) self.assertEqual(results[4]['files'], None) diff --git a/tests/unit/engines/test_pdbe.py b/tests/unit/engines/test_pdbe.py new file mode 100644 index 000000000..7aa8e2655 --- /dev/null +++ b/tests/unit/engines/test_pdbe.py @@ -0,0 +1,109 @@ +import mock +from collections import defaultdict +from searx.engines import pdbe +from searx.testing import SearxTestCase + + +class TestPdbeEngine(SearxTestCase): + def test_request(self): + query = 'test_query' + dicto = defaultdict(dict) + params = pdbe.request(query, dicto) + self.assertTrue('url' in params) + self.assertTrue('ebi.ac.uk' in params['url']) + self.assertTrue('data' in params) + self.assertTrue('q' in params['data']) + self.assertTrue(query in params['data']['q']) + self.assertTrue('wt' in params['data']) + self.assertTrue('json' in params['data']['wt']) + self.assertTrue('method' in params) + self.assertTrue(params['method'] == 'POST') + + def test_response(self): + self.assertRaises(AttributeError, pdbe.response, None) + self.assertRaises(AttributeError, pdbe.response, []) + self.assertRaises(AttributeError, pdbe.response, '') + self.assertRaises(AttributeError, pdbe.response, '[]') + + json = """ +{ + "response": { + "docs": [ + { + "citation_title": "X-ray crystal structure of ferric Aplysia limacina myoglobin in different liganded states.", + "citation_year": 1993, + "entry_author_list": [ + "Conti E, Moser C, Rizzi M, Mattevi A, Lionetti C, Coda A, Ascenzi P, Brunori M, Bolognesi M" + ], + "journal": "J. Mol. Biol.", + "journal_page": "498-508", + "journal_volume": "233", + "pdb_id": "2fal", + "status": "REL", + "title": "X-RAY CRYSTAL STRUCTURE OF FERRIC APLYSIA LIMACINA MYOGLOBIN IN DIFFERENT LIGANDED STATES" + } + ], + "numFound": 1, + "start": 0 + }, + "responseHeader": { + "QTime": 0, + "params": { + "q": "2fal", + "wt": "json" + }, + "status": 0 + } +} +""" + + response = mock.Mock(text=json) + results = pdbe.response(response) + self.assertEqual(type(results), list) + self.assertEqual(len(results), 1) + self.assertEqual(results[0]['title'], + 'X-RAY CRYSTAL STRUCTURE OF FERRIC APLYSIA LIMACINA MYOGLOBIN IN DIFFERENT LIGANDED STATES') + self.assertEqual(results[0]['url'], pdbe.pdbe_entry_url.format(pdb_id='2fal')) + self.assertEqual(results[0]['img_src'], pdbe.pdbe_preview_url.format(pdb_id='2fal')) + self.assertTrue('Conti E' in results[0]['content']) + self.assertTrue('X-ray crystal structure of ferric Aplysia limacina myoglobin in different liganded states.' in + results[0]['content']) + self.assertTrue('1993' in results[0]['content']) + + # Testing proper handling of PDB entries marked as obsolete + json = """ +{ + "response": { + "docs": [ + { + "citation_title": "Obsolete entry test", + "citation_year": 2016, + "entry_author_list": ["Doe J"], + "journal": "J. Obs.", + "journal_page": "1-2", + "journal_volume": "1", + "pdb_id": "xxxx", + "status": "OBS", + "title": "OBSOLETE ENTRY TEST", + "superseded_by": "yyyy" + } + ], + "numFound": 1, + "start": 0 + }, + "responseHeader": { + "QTime": 0, + "params": { + "q": "xxxx", + "wt": "json" + }, + "status": 0 + } +} +""" + response = mock.Mock(text=json) + results = pdbe.response(response) + self.assertEqual(type(results), list) + self.assertEqual(len(results), 1) + self.assertEqual(results[0]['title'], 'OBSOLETE ENTRY TEST (OBSOLETE)') + self.assertTrue(results[0]['content'].startswith('This entry has been superseded by')) diff --git a/tests/unit/engines/test_seedpeer.py b/tests/unit/engines/test_seedpeer.py new file mode 100644 index 000000000..37b2de8e4 --- /dev/null +++ b/tests/unit/engines/test_seedpeer.py @@ -0,0 +1,51 @@ +import mock +from collections import defaultdict +from searx.engines import seedpeer +from searx.testing import SearxTestCase +from datetime import datetime + + +class TestSeedPeerEngine(SearxTestCase): + + html = '' + with open('./tests/unit/engines/seedpeer_fixture.html') as fixture: + html += fixture.read() + + def test_request(self): + query = 'test_query' + dicto = defaultdict(dict) + dicto['pageno'] = 1 + params = seedpeer.request(query, dicto) + self.assertIn('url', params) + self.assertIn(query, params['url']) + self.assertIn('seedpeer.eu', params['url']) + + def test_response_raises_attr_error_on_empty_response(self): + self.assertRaises(AttributeError, seedpeer.response, None) + self.assertRaises(AttributeError, seedpeer.response, []) + self.assertRaises(AttributeError, seedpeer.response, '') + self.assertRaises(AttributeError, seedpeer.response, '[]') + + def test_response_returns_empty_list(self): + response = mock.Mock(text='') + self.assertEqual(seedpeer.response(response), []) + + def test_response_returns_all_results(self): + response = mock.Mock(text=self.html) + results = seedpeer.response(response) + self.assertTrue(isinstance(results, list)) + self.assertEqual(len(results), 2) + + def test_response_returns_correct_results(self): + response = mock.Mock(text=self.html) + results = seedpeer.response(response) + self.assertEqual( + results[0]['title'], 'Narcos - Season 2 - 720p WEBRiP - x265 HEVC - ShAaNiG ' + ) + self.assertEqual( + results[0]['url'], + 'http://www.seedpeer.eu/details/11685972/Narcos---Season-2---720p-WEBRiP---x265-HEVC---ShAaNiG.html' + ) + self.assertEqual(results[0]['content'], '2.48 GB, 1 day') + self.assertEqual(results[0]['seed'], '861') + self.assertEqual(results[0]['leech'], '332') diff --git a/tests/unit/test_webapp.py b/tests/unit/test_webapp.py index 1762d66b6..912bebc4d 100644 --- a/tests/unit/test_webapp.py +++ b/tests/unit/test_webapp.py @@ -44,7 +44,7 @@ class ViewsTestCase(SearxTestCase): webapp.Search.search = search_mock def get_current_theme_name_mock(override=None): - return 'default' + return 'legacy' webapp.get_current_theme_name = get_current_theme_name_mock @@ -58,7 +58,7 @@ class ViewsTestCase(SearxTestCase): def test_index_html(self): result = self.app.post('/', data={'q': 'test'}) self.assertIn( - '

youtubeSecond Test

', # noqa + '

youtubeSecond Test

', # noqa result.data ) self.assertIn(
diff --git a/tests/unit/engines/test_kickass.py b/tests/unit/engines/test_kickass.py index 4cfcaa63c..96c17911c 100644 --- a/tests/unit/engines/test_kickass.py +++ b/tests/unit/engines/test_kickass.py @@ -14,7 +14,7 @@ class TestKickassEngine(SearxTestCase): params = kickass.request(query, dicto) self.assertIn('url', params) self.assertIn(query, params['url']) - self.assertIn('kickass.to', params['url']) + self.assertIn('kickass.cd', params['url']) self.assertFalse(params['verify']) def test_response(self): @@ -84,7 +84,7 @@ class TestKickassEngine(SearxTestCase):
449 bytes449 bytes 4 2 years 10 1 KB1 KiB 4 2 years 10 1 MB1 MiB 4 2 years 9 1 GB1 GiB 4 2 years 8 1 TB1 TiB 4 2 years 7 z bytesz bytes r 2 years a