Skip to content

Commit

Permalink
Merge branch 'release/2.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Sep 14, 2020
2 parents 51803f6 + 33a26f4 commit 8ed2a50
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 36 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# v2.2.0
## 09/14/2020

1. [](#improved)
* Added config option to choose keys to ignore when searching header
* Added ability to opt-out of page search by setting: `simplesearch: process: false` in page header
* Added `form` and `forms` to default list of ignores in page header searches
1. [](#bugfix)
* Fix issue to ensure matching ignore keys only checked at root level
* Fix issue where searchable header content was growing exponentially

# v2.1.0
## 05/27/2020

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ searchable_types:
content: true
taxonomy: true
header: false
header_keys_ignored: ['title', 'taxonomy','content', 'form', 'forms', 'media_order']
```

By creating the configuration file: `user/config/plugins/simplesearch.yaml` you have effectively created a site-wide configuration for SimpleSearch. However, you may want to have multiple searches.
Expand All @@ -61,6 +62,7 @@ To accomplish multiple search types in a single site, you should use **page-base

```
simplesearch:
process: true
route: @self
filters:
- @self
Expand Down Expand Up @@ -169,6 +171,15 @@ filters:
- '@taxonomy': false
```
## Ignoring a page
A page can be setup to "opt-out" of being included in the search results by setting the following in page frontmatter:
```yaml
simplesearch:
process: false
```

## Ignoring accented characters

You can tell Simplesearch to return a positive value when searching for characters that have an accent. So `éè` for example will be both equivalent to `e`.
Expand Down
47 changes: 28 additions & 19 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: SimpleSearch
version: 2.1.0
version: 2.2.0
description: "Don't be fooled, the **SimpleSearch** plugin provides a **fast** and highly **configurable** way to search your content."
icon: search
author:
Expand Down Expand Up @@ -111,6 +111,15 @@ form:
taxonomy: Taxonomy
use: keys

header_keys_ignored:
type: selectize
size: large
label: PLUGIN_SIMPLESEARCH.HEADER_KEYS_IGNORED
help: PLUGIN_SIMPLESEARCH.HEADER_KEYS_IGNORED_HELP
classes: fancy
validate:
type: commalist

template:
type: text
size: medium
Expand All @@ -136,23 +145,23 @@ form:
or: PLUGIN_SIMPLESEARCH.OR_COMBINATOR

order.by:
type: select
size: long
classes: fancy
label: PLUGIN_ADMIN.DEFAULT_ORDERING
help: PLUGIN_ADMIN.DEFAULT_ORDERING_HELP
options:
default: PLUGIN_ADMIN.DEFAULT_ORDERING_DEFAULT
folder: PLUGIN_ADMIN.DEFAULT_ORDERING_FOLDER
title: PLUGIN_ADMIN.DEFAULT_ORDERING_TITLE
date: PLUGIN_ADMIN.DEFAULT_ORDERING_DATE
type: select
size: long
classes: fancy
label: PLUGIN_ADMIN.DEFAULT_ORDERING
help: PLUGIN_ADMIN.DEFAULT_ORDERING_HELP
options:
default: PLUGIN_ADMIN.DEFAULT_ORDERING_DEFAULT
folder: PLUGIN_ADMIN.DEFAULT_ORDERING_FOLDER
title: PLUGIN_ADMIN.DEFAULT_ORDERING_TITLE
date: PLUGIN_ADMIN.DEFAULT_ORDERING_DATE

order.dir:
type: toggle
label: PLUGIN_ADMIN.DEFAULT_ORDER_DIRECTION
highlight: asc
default: desc
help: PLUGIN_ADMIN.DEFAULT_ORDER_DIRECTION_HELP
options:
asc: PLUGIN_ADMIN.ASCENDING
desc: PLUGIN_ADMIN.DESCENDING
type: toggle
label: PLUGIN_ADMIN.DEFAULT_ORDER_DIRECTION
highlight: asc
default: desc
help: PLUGIN_ADMIN.DEFAULT_ORDER_DIRECTION_HELP
options:
asc: PLUGIN_ADMIN.ASCENDING
desc: PLUGIN_ADMIN.DESCENDING
8 changes: 5 additions & 3 deletions languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ en:
AND_COMBINATOR: 'And - Boolean &&'
OR_COMBINATOR: 'Or - Boolean ||'
SEARCHABLE_TYPES: "Searchable Types"
SEARCHABLE_TYPES_DESCRIPTION: "<b>Title</b> = Search Page Title<br><b>Content</b> = Search Page Content<br><b>Header</b> = Search Raw Headers (excluding title, content, taxonomy)<br><b>Taxonomy</b> = Search Taxonomy"
SEARCHABLE_TYPES_DESCRIPTION: "<b>Title</b> = Search Page Title<br><b>Content</b> = Search Page Content<br><b>Header</b> = Search Raw Page Headers<br><b>Taxonomy</b> = Search Taxonomy"
HEADER_KEYS_IGNORED: Header Keys to Ignore
HEADER_KEYS_IGNORED_HELP: The root-level header keys that should be skipped when searching type "Header"

ro:
PLUGIN_SIMPLESEARCH:
Expand All @@ -53,7 +55,7 @@ fr:
SEARCH_RESULTS_SUMMARY_SINGULAR: "Recherche : Un résultat trouvé pour <strong>%s</strong>"
SEARCH_RESULTS_SUMMARY_PLURAL: "Recherche : %2$s résultats trouvés pour <strong>%1$s</strong>"
SEARCH_FIELD_MINIMUM_CHARACTERS: "Veuillez ajouter au moins %s caractères"

it:
PLUGIN_SIMPLESEARCH:
SEARCH_PLACEHOLDER: "Cerca …"
Expand Down Expand Up @@ -150,7 +152,7 @@ uk:
FILTER_COMBINATOR: 'Фільтр комбінатор'
AND_COMBINATOR: 'І - Булева &&'
OR_COMBINATOR: 'Або - Булева ||'

es:
PLUGIN_SIMPLESEARCH:
SEARCH_PLACEHOLDER: "Buscar …"
Expand Down
30 changes: 23 additions & 7 deletions simplesearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ public function onPagesInitialized()

if ($query) {
foreach ($this->collection as $cpage) {

$header = $cpage->header();
if (isset($header->simplesearch['process']) && $header->simplesearch['process'] === false) {
$this->collection->remove($cpage);
continue;
}

foreach ($this->query as $query) {
$query = trim($query);

Expand Down Expand Up @@ -393,15 +400,24 @@ public function onTwigSiteVariables()
}
}

protected function getArrayValues($array, $ignore_keys = ['title','taxonomy','content'], $output = '') {
protected function getArrayValues($array, $ignore_keys = null, $level = 0) {
$output = '';

if (is_null($ignore_keys)) {
$ignore_keys = $this->config()->header_keys_ignored;
}
foreach ($array as $key => $child) {
if (!in_array($key, $ignore_keys)) {
if (is_array($child)) {
$output .= " " . $this->getArrayValues($child, $ignore_keys, $output);
} else {
$output .= " " . $child;
}

if ($level === 0 && in_array($key, $ignore_keys)) {
continue;
}

if (is_array($child)) {
$output .= " " . $this->getArrayValues($child, $ignore_keys, $level + 1);
} else {
$output .= " " . $child;
}

}
return trim($output);
}
Expand Down
15 changes: 8 additions & 7 deletions simplesearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ route: /search
search_content: rendered
template: simplesearch_results
filters:
category:
category:
filter_combinator: and
ignore_accented_characters: false
order:
by: date
dir: desc
by: date
dir: desc
searchable_types:
title: true
content: true
taxonomy: true
header: false
title: true
content: true
taxonomy: true
header: false
header_keys_ignored: [ 'title', 'taxonomy','content', 'form', 'forms', 'media_order' ]

0 comments on commit 8ed2a50

Please sign in to comment.