2016-08-20 01:48:00 +03:00
|
|
|
from __future__ import absolute_import
|
|
|
|
|
2016-08-15 06:30:21 +03:00
|
|
|
from flask import render_template, request, Blueprint, current_app
|
2016-09-05 00:08:18 +03:00
|
|
|
from flask_login import current_user
|
2016-08-20 01:48:00 +03:00
|
|
|
|
2014-11-13 01:06:56 +02:00
|
|
|
from realms import search as search_engine
|
2014-11-12 01:06:28 +02:00
|
|
|
|
2016-08-20 01:48:00 +03:00
|
|
|
|
2016-08-16 06:06:05 +03:00
|
|
|
blueprint = Blueprint('search', __name__, template_folder='templates')
|
2014-11-10 18:54:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
@blueprint.route('/_search')
|
|
|
|
def search():
|
2016-09-06 07:08:58 +03:00
|
|
|
if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
|
2016-08-15 06:30:21 +03:00
|
|
|
return current_app.login_manager.unauthorized()
|
|
|
|
|
2014-11-13 01:06:56 +02:00
|
|
|
results = search_engine.wiki(request.args.get('q'))
|
2014-11-17 19:25:26 +02:00
|
|
|
return render_template('search/search.html', results=results)
|