Skip to content

Commit f28ca5d

Browse files
committed
Merge branch 'release/3.3.1'
2 parents 8897097 + 9723759 commit f28ca5d

20 files changed

+245
-102
lines changed

CHANGELOG.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1+
# v3.3.1
2+
## 02/25/2021
3+
4+
1. [](#improved)
5+
* Upgraded to TNTSearch version `2.6.0`
6+
* Added German (de) language [#103](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/103)
7+
1. [](#bugfix)
8+
* Fixed `query` truncation when containing a hash (`#`) and preventing proper search results [#110](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/110)
9+
* Fixed `q` query parameter not working [#111](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/111)
10+
* Fix default stemmer and description [#105](https://github.com/trilbymedia/grav-plugin-tntsearch/pull/105)
11+
* Fixed PHP 8 compatibility issues
12+
113
# v3.3.0
214
## 12/02/2020
315

4-
1. [](#new)
5-
* Upgraded to TNTSearch version 2.5
16+
1. [](#improved)
17+
* Upgraded to TNTSearch version `2.5.0`
618
* Pass phpstan level 7 tests
719
1. [](#bugfix)
820
* Fixed FlexPages events for add+delete

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,12 @@ The configuration options are as follows:
105105
* `fuzzy` - matches if the words are 'close' but not necessarily exact matches
106106
* `phrases` - automatically handle phrases support
107107
* `stemmer` - can be one of these types:
108-
* `default` - no stemmer
108+
* `default` - Porter stemmer for English language
109+
* `no` - no stemmer
109110
* `arabic` - Arabic language
110111
* `german` - German language
111112
* `italian` - Italian language
112-
* `porter` - Porter language
113+
* `porter` - Porter stemmer for English language
113114
* `russian` - Russian language
114115
* `ukrainian` - Ukrainian language
115116
* `display_route` - display the route in the search results
@@ -236,11 +237,11 @@ For example, say we have a homepage that is built from a few modular sub-pages w
236237
```twig
237238
{% for module in page.collection() %}
238239
<p>
239-
{{ module.content }}
240+
{{ module.content|raw }}
240241
</p>
241242
{% endfor %}
242243
243-
{{ page.content }}
244+
{{ page.content|raw }}
244245
```
245246

246247
As you can see this simply ensures the module pages as defined in the page's collection are displayed, then the actual page content is displayed.

app/search.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const throttling = throttle(async ({ input, results, historyValue = false } = {}
5959
}
6060

6161
const params = {
62-
q: value,
62+
q: encodeURIComponent(value),
6363
l: data.limit,
6464
sl: data.snippet,
6565
search_type: data.search_type,

assets/tntsearch.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

blueprints.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: TNT Search
22
type: plugin
33
slug: tntsearch
4-
version: 3.3.0
4+
version: 3.3.1
55
testing: false
66
description: Powerful indexed-based full text search engine powered by TNTSearch
77
icon: binoculars
@@ -173,13 +173,14 @@ form:
173173
size: small
174174
classes: fancy
175175
label: Stemmer
176-
help: An automated process which produces a base string in an attempt to represent related words
176+
help: An automated process which produces a base string in an attempt to represent related words. If your content is not in the language listed, for best search results it is recommended to disable the stemmer.
177177
options:
178-
default: Default
178+
default: Default (English)
179+
no: Disabled
179180
arabic: Arabic
181+
porter: English
180182
german: German
181183
italian: Italian
182-
porter: Porter
183184
russian: Russian
184185
ukrainian: Ukrainian
185186

classes/GravConnector.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
use Grav\Common\Yaml;
77
use Grav\Common\Page\Page;
88
use Grav\Plugin\TNTSearchPlugin;
9+
use PDO;
910

10-
class GravConnector extends \PDO
11+
class GravConnector extends PDO
1112
{
1213
public function __construct()
1314
{
14-
1515
}
1616

1717
/**
@@ -23,11 +23,13 @@ public function getAttribute($attribute): bool
2323
return false;
2424
}
2525

26-
/**
27-
* @param string $query
26+
/***
27+
* @param string $statement
28+
* @param int|null $fetch_style
29+
* @param mixed ...$extra
2830
* @return GravResultObject
2931
*/
30-
public function query($query)
32+
public function query(string $statement, ?int $fetch_style = null, ...$extra): GravResultObject
3133
{
3234
$counter = 0;
3335
$results = [];

classes/GravTNTSearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public static function getCleanContent($page)
208208
}
209209

210210
$content = strip_tags($content);
211-
$content = preg_replace('/[ \t]+/', ' ', preg_replace('/\s*$^\s*/m', "\n", $content));
211+
$content = preg_replace(['/[ \t]+/', '/\s*$^\s*/m'], [' ', "\n"], $content) ?? $content;
212212

213213
// Restore active page in Grav.
214214
unset($grav['page']);

cli/TNTSearchIndexerCommand.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,9 @@
1212
*/
1313
class TNTSearchIndexerCommand extends ConsoleCommand
1414
{
15-
/**
16-
* @var array
17-
*/
15+
/** @var array */
1816
protected $options = [];
19-
/**
20-
* @var array
21-
*/
17+
/** @var array */
2218
protected $colors = [
2319
'DEBUG' => 'green',
2420
'INFO' => 'cyan',
@@ -33,7 +29,7 @@ class TNTSearchIndexerCommand extends ConsoleCommand
3329
/**
3430
* @return void
3531
*/
36-
protected function configure()
32+
protected function configure(): void
3733
{
3834
$this
3935
->setName('index')
@@ -54,10 +50,11 @@ protected function configure()
5450
}
5551

5652
/**
57-
* @return void
53+
* @return int
5854
*/
59-
protected function serve()
55+
protected function serve(): int
6056
{
57+
/** @var string|null $langCode */
6158
$langCode = $this->input->getOption('language');
6259

6360
error_reporting(1);
@@ -82,6 +79,8 @@ protected function serve()
8279
$this->output->writeln('');
8380
$this->output->writeln('Indexed in ' . $end . 's');
8481
}
82+
83+
return 0;
8584
}
8685

8786
/**

cli/TNTSearchQueryCommand.php

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@
1313
*/
1414
class TNTSearchQueryCommand extends ConsoleCommand
1515
{
16-
/**
17-
* @var array
18-
*/
16+
/** @var array */
1917
protected $options = [];
20-
21-
/**
22-
* @var array
23-
*/
18+
/** @var array */
2419
protected $colors = [
2520
'DEBUG' => 'green',
2621
'INFO' => 'cyan',
@@ -56,24 +51,24 @@ protected function configure()
5651
}
5752

5853
/**
59-
* @return void
54+
* @return int
6055
*/
61-
protected function serve()
56+
protected function serve(): int
6257
{
63-
$this->setLanguage($this->input->getOption('language'));
64-
$this->initializePages();
58+
/** @var string|null $langCode */
59+
$langCode = $this->input->getOption('language');
60+
/** @var string $query */
61+
$query = $this->input->getArgument('query');
6562

66-
$this->doQuery();
67-
$this->output->writeln('');
68-
}
63+
$this->setLanguage($langCode);
64+
$this->initializePages();
6965

70-
/**
71-
* @return void
72-
*/
73-
private function doQuery()
74-
{
7566
$gtnt = TNTSearchPlugin::getSearchObjectType(['json' => true]);
76-
print_r($gtnt->search($this->input->getArgument('query')));
67+
print_r($gtnt->search($query));
68+
69+
$this->output->newLine();
70+
71+
return 0;
7772
}
7873
}
7974

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"require": {
1717
"php": ">=7.1.3",
1818
"ext-json": "*",
19+
"ext-pdo": "*",
1920
"teamtnt/tntsearch": "^2.0"
2021
},
2122
"autoload": {

0 commit comments

Comments
 (0)