diff --git a/nyaa/routes.py b/nyaa/routes.py index 2941e5b..3e87a2a 100644 --- a/nyaa/routes.py +++ b/nyaa/routes.py @@ -207,6 +207,9 @@ def search(term='', user=None, sort='id', order='desc', category='0_0', quality_ s = s[(page-1)*per:page*per] #query = query.paginate_faste(page, per_page=app.config['RESULTS_PER_PAGE'], step=5) + s = s.highlight_options(tags_schema='styled') + s = s.highlight("display_name") + #return query from pprint import pprint print(json.dumps(s.to_dict())) diff --git a/nyaa/static/css/main.css b/nyaa/static/css/main.css index ee01f9b..f7234ec 100644 --- a/nyaa/static/css/main.css +++ b/nyaa/static/css/main.css @@ -92,4 +92,14 @@ table.torrent-list thead th.sorting_desc:after { margin-left: 20px; margin-bottom: 10px; } -} \ No newline at end of file +} + +/* elasticsearch term highlight */ +.hlt1 { + font-style: normal; + display: inline-block; + padding: 0 3px; + border-radius: 3px; + border: 1px solid rgba(100, 56, 0, 0.8); + background: rgba(200,127,0,0.3); +} diff --git a/nyaa/templates/search_results.html b/nyaa/templates/search_results.html index 4bce368..7657bb1 100644 --- a/nyaa/templates/search_results.html +++ b/nyaa/templates/search_results.html @@ -54,7 +54,7 @@ - {{ torrent.display_name | escape }} + {{ torrent.meta.highlight.display_name[0] | safe }} {% if torrent.has_torrent %}{% endif %}