Skip to content
Snippets Groups Projects
Commit cc790faf authored by Dennis's avatar Dennis
Browse files

adds suggestions to frontend

parent f4c33f97
No related branches found
No related tags found
No related merge requests found
......@@ -167,8 +167,9 @@ class OdshFeedController(FeedController):
class OdshAutocompleteController(ApiController):
def autocomplete(self):
from ckan.common import request
query = {
'spellcheck.q': 'Obs',
'spellcheck.q': request.get('q', ''),
'wt': 'json'}
conn = make_connection(decode_dates=False)
......@@ -180,7 +181,4 @@ class OdshAutocompleteController(ApiController):
(query, e))
suggest = solr_response.raw_response.get('spellcheck')
hits = suggest.get('suggestions')[0].get(query.get('spellcheck.q')).get('numFound')
if hits >= 1:
return base.response.body_file.write(suggest.get('suggestions')[0].get(query.get('spellcheck.q'))
.get('suggestion')[0])
return suggest
.ui-autocomplete .ui-menu-item a,
.ui-autocomplete .ui-menu-item a:active,
.ui-autocomplete .ui-menu-item a:focus,
.ui-autocomplete .ui-menu-item a:hover,
.ui-autocomplete .ui-menu-item a:visited {
display: block;
text-decoration: none;
}
'use strict';
$(function () {
// Activate search suggestions for the search bar in the header and for the
// search bar used in the body.
$('.site-search input, .search').autocomplete({
delay: 500,
html: true,
minLength: 2,
source: function (request, response) {
var url = ckan.SITE_ROOT + '/autocomplete';
$.getJSON(url, {q: request.term})
.done(function (data) {
console.log(data);
response(data['result']);
});
}
});
})
......@@ -6,6 +6,8 @@
<link rel="stylesheet" href="/odsh.css?refresh={{ range(1,10000) | random }}" />
<link rel="stylesheet" href="/odsh_header.css?refresh={{ range(1,10000) | random }}" />
<link rel="stylesheet" href="/bootstrap-multiselect.css" />
<link rel="stylesheet" href="/autocomplete.css" />
{% resource 'odsh/autocomplete.js' %}
{% endblock %}
{% block head_extras %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment