Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7766167d authored by Johnny Kalajdzic's avatar Johnny Kalajdzic Committed by Romain Hunault
Browse files

Finish mysql implementation

parent 6391c693
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -14,11 +14,12 @@ See the `documentation <https://asciimoo.github.io/searx>`__ and the `wiki <http
|OpenCollective searx backers|
|OpenCollective searx sponsors|

Setup MySql (No deady)
~~~~~~~~~~~~~~~~~~~~~~
Setup MySql
~~~~~~~~~~~

**Install MySql**
 ``$ sudo apt-get install mysql-server``
 ``$ sudo apt-get install mysql-server
 $ pip install mymysql``

**Start MySql**
 ``$ sudo service mysql start
@@ -37,7 +38,7 @@ Setup MySql (No deady)
**Here are some commands to init the database**
 ``mysql> use searx;``

 ``mysql> create table SEARCH_HISTORY(QUERY varchar(512), CATEGORIES varchar(256), PAGENO int(11), PAGING tinyint(1), SAFE_SEARCH int(11), LANGUAGE varchar(8), TIME_RANGE varchar(16), ENGINES varchar(1024), RESULTS mediumtext, RESULTS_NUMBER int(11), ANSWERS varchar(2048), CORRECTIONS varchar(256), INFOBOXES varchar(8192), SUGGESTIONS varchar(512), UNRESPONSIVE_ENGINES varchar(1024));``
 ``mysql> create table SEARCH_HISTORY(QUERY varchar(512), CATEGORIY varchar(256), PAGENO int(11), PAGING tinyint(1), SAFE_SEARCH int(11), LANGUAGE varchar(8), TIME_RANGE varchar(16), ENGINES varchar(4096), RESULTS mediumtext), RESULTS_NUMBER int(11), ANSWERS varchar(2048), CORRECTIONS varchar(256), INFOBOXES varchar(8192), SUGGESTIONS varchar(1024), UNRESPONSIVE_ENGINES varchar(1024));``

 ``mysql> quit``

+1 −0
Original line number Diff line number Diff line
pymysql
certifi==2017.11.5
flask==0.12.2
flask-babel==0.11.2
+1 −1
Original line number Diff line number Diff line
@@ -224,7 +224,7 @@ def https_url_rewrite(result):
    return result


def on_result(request, search, result):
def on_result(request, searchData, result):
    if result['parsed_url'].scheme == 'http':
        https_url_rewrite(result)
    return True
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ def get_doi_resolver(args, preference_doi_resolver):
    return doi_resolver


def on_result(request, search, result):
def on_result(request, searchData, result):
    doi = extract_doi(result['parsed_url'])
    if doi and len(doi) < 50:
        for suffix in ('/', '.pdf', '/full', '/meta', '/abstract'):
+8 −8
Original line number Diff line number Diff line
@@ -28,19 +28,19 @@ p = re.compile(b'.*user[ -]agent.*', re.IGNORECASE)
# attach callback to the post search hook
#  request: flask request object
#  ctx: the whole local context of the pre search hook
def post_search(request, search):
    if search.search_query.pageno > 1:
def post_search(request, searchData):
    if searchData.pageno > 1:
        return True
    if search.search_query.query == b'ip':
    if searchData.query == b'ip':
        x_forwarded_for = request.headers.getlist("X-Forwarded-For")
        if x_forwarded_for:
            ip = x_forwarded_for[0]
        else:
            ip = request.remote_addr
        search.result_container.answers.clear()
        search.result_container.answers.add(ip)
    elif p.match(search.search_query.query):
        searchData.answers.clear()
        searchData.answers.add(ip)
    elif p.match(searchData.query):
        ua = request.user_agent
        search.result_container.answers.clear()
        search.result_container.answers.add(ua)
        searchData.answers.clear()
        searchData.answers.add(ua)
    return True
Loading