diff --git a/pillar/api/search/routes.py b/pillar/api/search/routes.py index 5b62a1f8..83d2994f 100644 --- a/pillar/api/search/routes.py +++ b/pillar/api/search/routes.py @@ -47,7 +47,12 @@ def search_nodes(): def search_user(): searchword = _valid_search() terms = _term_filters() + # data is the raw elasticseach output. + # we need to filter fields in case of user objects. data = queries.do_user_search(searchword, terms) + + # filter sensitive stuff + return jsonify(data) diff --git a/src/scripts/algolia_search.js b/src/scripts/elasticsearch.js similarity index 100% rename from src/scripts/algolia_search.js rename to src/scripts/elasticsearch.js diff --git a/src/scripts/tutti/4_search.js b/src/scripts/tutti/4_search.js index ba075040..d5280c51 100644 --- a/src/scripts/tutti/4_search.js +++ b/src/scripts/tutti/4_search.js @@ -108,8 +108,7 @@ var elasticSearcher = (function() { var elasticSearch = (function($, url) { - console.log(url); - return function findMatches(q, cb, async){ + return function findMatches(q, cb, async){ if (!cb) { return; } $.fn.getSearch(q, cb, async, url); }; @@ -133,7 +132,7 @@ var elasticSearch = (function($, url) { newhits = hits.map(function(hit){ return hit._source; }); - cb(newhits.slice(0)); + //cb(newhits.slice(0)); async(newhits.slice(0)); }); }; @@ -151,7 +150,8 @@ $(document).ready(function() { source: elasticSearch($), async: true, displayKey: 'name', - limit: 10, + limit: 9, // Above 10 it stops working from + // some magic reason minLength: 0, templates: { suggestion: function(hit) { @@ -193,7 +193,7 @@ $(document).ready(function() { $('.search-site-result.advanced, .search-icon').on('click', function(e){ e.stopPropagation(); e.preventDefault(); - window.location.href = '/search#q='+ $("#cloud-search").val() + '&page=1'; + window.location.href = '/search?q='+ $("#cloud-search").val() + '&page=1'; }); @@ -224,7 +224,7 @@ $(document).ready(function() { searchInput.bind('typeahead:render', function(event, suggestions, async, dataset) { if( suggestions != undefined && $('.tt-all-results').length <= 0){ $('.tt-dataset').append( - '' + + '' + '
' + '
' + '
' + diff --git a/src/styles/_project-sharing.sass b/src/styles/_project-sharing.sass index aef546dc..40a2e7be 100644 --- a/src/styles/_project-sharing.sass +++ b/src/styles/_project-sharing.sass @@ -111,7 +111,7 @@ ul.sharing-users-list color: $color-text-dark-secondary padding-bottom: 10px -.algolia-autocomplete +.search-autocomplete position: relative width: 100% &:before @@ -124,16 +124,16 @@ ul.sharing-users-list z-index: 1 color: $color-text-dark-secondary -.algolia-autocomplete .aa-input +.search-autocomplete .aa-input padding-left: 35px width: 100% -.algolia-autocomplete .aa-hint +.search-autocomplete .aa-hint width: 100% color: $color-text-dark-hint -.algolia-autocomplete .aa-dropdown-menu +.search-autocomplete .aa-dropdown-menu width: 100% background-color: white border: 1px solid $color-text-dark-hint @@ -142,16 +142,16 @@ ul.sharing-users-list border-bottom-right-radius: 3px box-shadow: 0 15px 30px rgba(black, .1) -.algolia-autocomplete .aa-dropdown-menu .aa-suggestion +.search-autocomplete .aa-dropdown-menu .aa-suggestion cursor: pointer padding: 5px 4px -.algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor, -.algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor em +.search-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor, +.search-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor em background-color: $color-primary color: white -.algolia-autocomplete .aa-dropdown-menu .aa-suggestion em +.search-autocomplete .aa-dropdown-menu .aa-suggestion em font-style: normal color: $color-primary diff --git a/src/templates/layout.pug b/src/templates/layout.pug index 6e067634..b398faa8 100644 --- a/src/templates/layout.pug +++ b/src/templates/layout.pug @@ -31,12 +31,9 @@ html(lang="en") script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery-3.1.0.min.js')}}") script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.typeahead-0.11.1.min.js')}}") - script(src="{{ url_for('static_pillar', filename='assets/js/vendor/algoliasearch-3.19.0.min.js')}}") script(src="{{ url_for('static_pillar', filename='assets/js/vendor/js.cookie-2.0.3.min.js')}}") script. - var algolia = algoliasearch("{{config['ALGOLIA_USER']}}", "{{config['ALGOLIA_PUBLIC_KEY']}}"); - var algoliaIndex = algolia.initIndex("{{config['ALGOLIA_INDEX_NODES']}}"); !function(e){"use strict";e.loadCSS=function(t,n,o){var r,i=e.document,l=i.createElement("link");if(n)r=n;else{var d=(i.body||i.getElementsByTagName("head")[0]).childNodes;r=d[d.length-1]}var a=i.styleSheets;l.rel="stylesheet",l.href=t,l.media="only x",r.parentNode.insertBefore(l,n?r:r.nextSibling);var f=function(e){for(var t=l.href,n=a.length;n--;)if(a[n].href===t)return e();setTimeout(function(){f(e)})};return l.onloadcssdefined=f,f(function(){l.media=o||"all"}),l},"undefined"!=typeof module&&(module.exports=e.loadCSS)}(this); diff --git a/src/templates/nodes/search.pug b/src/templates/nodes/search.pug index 7bad1347..c92b6fef 100644 --- a/src/templates/nodes/search.pug +++ b/src/templates/nodes/search.pug @@ -180,9 +180,8 @@ script(). FACET_CONFIG.push({ name: 'project._id', title: 'Project', disjunctive: false, hidden: true, value: '{{project._id}}' }) {% endif %} -script(src="{{ url_for('static_pillar', filename='assets/js/vendor/algoliasearch.helper.min.js') }}") script(src="{{ url_for('static_pillar', filename='assets/js/vendor/hogan.common-3.0.0.js') }}") -script(src="{{ url_for('static_pillar', filename='assets/js/algolia_search.min.js') }}") +script(src="{{ url_for('static_pillar', filename='assets/js/elasticsearch.min.js') }}") script(type="text/javascript"). diff --git a/src/templates/organizations/index.pug b/src/templates/organizations/index.pug index 6138a51c..511aa935 100644 --- a/src/templates/organizations/index.pug +++ b/src/templates/organizations/index.pug @@ -74,7 +74,6 @@ meta(name="twitter:image", content="{{ url_for('static', filename='assets/img/ba | {% block footer_scripts %} script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.typeahead-0.11.1.min.js')}}") -script(src="{{ url_for('static_pillar', filename='assets/js/vendor/algoliasearch-3.19.0.min.js')}}") script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.autocomplete-0.22.0.min.js') }}", async=true) script. diff --git a/src/templates/users/index.pug b/src/templates/users/index.pug index 6c5eef8f..93115efa 100644 --- a/src/templates/users/index.pug +++ b/src/templates/users/index.pug @@ -94,10 +94,8 @@ script(type="text/template", id="stats-template") | {% block footer_scripts %} -script(src="{{ url_for('static_pillar', filename='assets/js/vendor/algoliasearch-3.19.0.min.js')}}") -script(src="{{ url_for('static_pillar', filename='assets/js/vendor/algoliasearch.helper.min.js') }}") script(src="{{ url_for('static_pillar', filename='assets/js/vendor/hogan.common-3.0.0.js') }}") -script(src="{{ url_for('static_pillar', filename='assets/js/algolia_search.min.js') }}") +script(src="{{ url_for('static_pillar', filename='assets/js/elasticsearch.min.js') }}") script(src="{{ url_for('static_pillar', filename='assets/js/vendor/jquery.select2.min.js') }}") script(type="text/javascript").