Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaita <maxence@pontapreta.net>2016-10-29 13:54:42 +0300
committerdaita <maxence@pontapreta.net>2016-10-29 13:54:42 +0300
commite1c5e25667c83124f92d95e5ab7124a5f9384824 (patch)
treec0e35e6fbda317c62c0695af87fe3a1c0b1012b3
parent4e6f2788bb870b5812ace29adc7d5efdb47477b7 (diff)
#46 - displaying suggestions
-rw-r--r--appinfo/routes.php5
-rw-r--r--css/navigate.css22
-rw-r--r--js/navigate.js67
-rw-r--r--lib/Controller/SearchController.php19
-rw-r--r--lib/Service/SolrService.php4
5 files changed, 85 insertions, 32 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 751f8c3..f03f0ee 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -54,6 +54,11 @@ return [
'name' => 'search#searchRequest',
'url' => 'ajax/search.php',
'verb' => 'POST'
+ ],
+ [
+ 'name' => 'search#getSuggestions',
+ 'url' => 'ajax/suggest.php',
+ 'verb' => 'POST'
]
]
];
diff --git a/css/navigate.css b/css/navigate.css
index 7b4334d..f6fed0f 100644
--- a/css/navigate.css
+++ b/css/navigate.css
@@ -1,5 +1,10 @@
@CHARSET "ISO-8859-1";
+.searchbox input[type="search"]:valid, .searchbox input[type="search"]:focus
+ {
+ width: 300px;
+}
+
#nextantList {
width: 100%;
}
@@ -75,4 +80,21 @@ SPAN.nextant_line3 {
SPAN.nextant_hl {
color: #000;
font-weight: bold;
+}
+
+#nextantSugg_list {
+ z-index: 200;
+ margin-top: 18px;
+ padding: 3px;
+ border: solid 1px #0000004D;
+ background: #fffc;
+ width: 360px;
+}
+
+DIV.nextantSugg_item {
+ border-top: dashed 1px #0003;
+}
+
+DIV.nextantSugg_firstitem {
+ border-top: 0px;
} \ No newline at end of file
diff --git a/js/navigate.js b/js/navigate.js
index 12b663d..e419cbb 100644
--- a/js/navigate.js
+++ b/js/navigate.js
@@ -69,9 +69,50 @@ $(document)
current_dir : nextant.get('dir')
}
+ nextant.suggestRequest(data);
nextant.searchRequest(data);
},
+ suggestRequest : function(data) {
+ $.post(
+ OC.filePath('nextant', 'ajax',
+ 'suggest.php'), data,
+ nextant.suggestResult);
+ },
+
+ suggestResult : function(response) {
+
+ if (response == null)
+ return;
+
+ if (!$('#nextantSugg_list').length)
+ $('#body-user').append(
+ '<div id="nextantSugg_list"></div>');
+
+ var offset = $('#searchbox').offset();
+ var height = $('#searchbox').height();
+ var top = offset.top + height + "px";
+ var left = offset.left + "px";
+
+ $('#nextantSugg_list').css({
+ 'position' : 'absolute',
+ 'left' : left,
+ 'top' : top
+ });
+
+ $('#nextantSugg_list').empty();
+ for (var i = 0; i < response.length; i++) {
+ var first = '';
+ if (i == 0)
+ first = 'nextantSugg_firstitem';
+ $('#nextantSugg_list').append(
+ '<div class="nextantSugg_item ' + first
+ + '">' + response[i].suggestion
+ + '</div>');
+
+ }
+ },
+
searchRequest : function(data) {
$.post(
OC
@@ -84,12 +125,11 @@ $(document)
if (response == null)
return;
- if (!$('#nextantList').length) {
- // $('#searchresults').prepend(
+ if (!$('#nextantList').length)
$('#fileList')
.append(
'<tr><td colspan="3" style="margin: 0px; padding: 0px;"><div id="nextantList"></div></td></tr>');
- }
+
$('#nextantList').empty();
response
@@ -144,13 +184,7 @@ $(document)
$tmpl += ' data-permissions="" data-has-preview="false" data-path="%PATH%" data-share-permissions="">';
$tmpl += '<td class="filename ui-draggable">';
$tmpl += '<a class="action action-favorite " data-original-title="" title="">';
- // $tmpl += '<span class="icon
- // icon-star"></span><span
- // class="hidden-visually">Favorite</span>';
$tmpl += '</a>';
- // $tmpl += '<input id="select-files-%ID%"
- // class="selectCheckBox checkbox"
- // type="checkbox">';
$tmpl += '<label for="select-files-%ID%"><div class="thumbnail" style="background-image:url(%ICON%); background-size: 32px;">';
$tmpl += '<div class="nextant_details" %DELETED%%SHARED%></div>';
$tmpl += '</div>';
@@ -162,21 +196,6 @@ $(document)
$tmpl += '<span class="nextant_line nextant_line2">%HIGHLIGHT1%</span>';
$tmpl += '<span class="nextant_line nextant_line3">%HIGHLIGHT2%</span>';
$tmpl += '</div></a>';
-
- // $tmpl += '<span class="fileactions"><a
- // class="action action-share permanent" href="#"
- // data-action="Share" data-original-title=""
- // title="">';
- // $tmpl += '<span class="icon
- // icon-share"></span><span
- // class="hidden-visually"></span></a>';
- // $tmpl += '<a class="action action-menu permanent"
- // href="#" data-action="menu"
- // data-original-title="" title=""><span class="icon
- // icon-more"></span>';
- // $tmpl += '<span
- // class="hidden-visually">Actions</span></a></span></a>';
-
$tmpl += '</td>';
$tmpl += '<td class="filesize" style="color:rgb(-17,-17,-17)">%SIZEREAD%</td>';
$tmpl += '<td class="date"><span class="modified" title="" style="color:rgb(155,155,155)" data-original-title=""></span></td></tr>';
diff --git a/lib/Controller/SearchController.php b/lib/Controller/SearchController.php
index 07b9ed5..4f093dc 100644
--- a/lib/Controller/SearchController.php
+++ b/lib/Controller/SearchController.php
@@ -75,8 +75,6 @@ class SearchController extends Controller
if ($query !== null) {
- $this->displaySuggestions($query);
-
// $groups
$groups = array_map(function ($value) {
return (string) $value;
@@ -151,12 +149,19 @@ class SearchController extends Controller
return $results;
}
- private function displaySuggestions($query)
+ /**
+ * @NoAdminRequired
+ * @NoCSRFRequired
+ */
+ public function getSuggestions($query)
{
- $suggest = $this->solrService->suggest($query, $error);
- if ($suggest == false)
- return;
+ if (! $this->solrService)
+ return false;
- $this->miscService->log('Suggestions: ' . var_export($suggest, true));
+ if ($query == null || $query === '')
+ return false;
+
+ $suggest = $this->solrService->suggest($query, $error);
+ return $suggest;
}
}
diff --git a/lib/Service/SolrService.php b/lib/Service/SolrService.php
index 29a7cfa..453a9a7 100644
--- a/lib/Service/SolrService.php
+++ b/lib/Service/SolrService.php
@@ -445,7 +445,9 @@ class SolrService
$t ++;
if ($t == $suggTotal) {
foreach ($termResult as $result)
- $suggestions[] = $queryBase . $result;
+ $suggestions[] = array(
+ 'suggestion' => $queryBase . $result
+ );
}
}