Skip to content

Commit

Permalink
Merge branch 'release/1.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed May 31, 2017
2 parents f852b9f + ed35fc1 commit aa0c730
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v1.12.0
## 05/31/2017

1. [](#new)
* Added option to switch between Rendered HTML and Raw Markdown content searching. Raw Markdown is faster than default.

# v1.11.0
## 05/29/2017

Expand All @@ -14,7 +20,7 @@
## 04/11/2017

1. [](#new)
* Added portoguese translation
* Added Portuguese translation
* Add hint when the minimum search field length is not matched
1. [](#bugfix)
* Default `ignore_accented_characters` to false
Expand All @@ -30,10 +36,11 @@
* Added japanese translation
* Added persian translation
1. [](#improved)
* Added option to switch between Rendered HTML and Raw Markdown content searching. Raw Markdown is faster than default.
* Removed jQuery dependency, fixes issue when jQuery is loaded in the footer [#57](https://github.com/getgrav/grav-plugin-simplesearch/pull/57)
* Added option to ignore accents when searching [#89](https://github.com/getgrav/grav-plugin-simplesearch/pull/89)
1. [](#bugfix)
* Remove unpublished and unroutable pages from the result set
* Remove unpublished and un-routable pages from the result set
* Fixed issue when using @self as route
* Fix overloaded property issue when searching on a page with simplesearch header [#80](https://github.com/getgrav/grav-plugin-simplesearch/issues/80)
* Fix issue with empty string and leading commas [#71](https://github.com/getgrav/grav-plugin-simplesearch/issues/71)
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ You should now have all the plugin files under
To effectively use the plugin, you first need to create an override config. To do so, create the folder `user/config/plugins` (if it doesn't exist already) and copy the [simplesearch.yaml][simplesearch] config file in there.

```
search_content: rendered
enabled: true
built_in_css: true
display_button: false
Expand Down Expand Up @@ -132,6 +133,10 @@ Multiple filters can be provided, and in order to search in the page's **Tag** f
The only thing needed to provide this functionality is a search box that points to the current page and appends the `query` parameter. You can again simple include the sample `simplesearch_searchbox.html.twig` file or add your own. Because the route is configured to point to the blog page, and because the blog page already iterates over a collection, SimpleSearch will replace the page collection with the search-filtered collection. No results page is required.
## Performance
Simple search is not a full-fledged index-powered search engine. It merely iterates over the pages and searches the content and title for matching strings. That's it. This is not going to result in screaming fast searches if your site has lots of content. One way to optimize things a little is to change the `search_content` configuration option from `rendered` to `raw`. This means the `rawMarkdown()` method is used rather than the `content()` method, to retrieve the page content, and in turn means plugin events, markdown processing, image processing, and other time consuming tasks are not performed. This can often yield adequate search results without the need for all this extra work.
## Searching Taxonomy
By default **SimpleSearch** will search in the **Title**, **Content**, and **Taxonomy**. All taxonomy will be searched unless you provide a **taxonomy filter** either in the page, or in the global plugin configuration:
Expand Down
12 changes: 11 additions & 1 deletion blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: SimpleSearch
version: 1.11.0
version: 1.12.0
description: "Don't be fooled, the **SimpleSearch** plugin provides a **fast** and highly **configurable** way to search your content."
icon: search
author:
Expand All @@ -26,6 +26,16 @@ form:
validate:
type: bool

search_content:
type: select
size: medium
classes: fancy
label: Search Content
default: rendered
options:
rendered: Rendered Content (Slower)
raw: Raw Markdown Content (Faster)

built_in_css:
type: toggle
label: Use built in CSS
Expand Down
15 changes: 14 additions & 1 deletion simplesearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,18 @@ private function matchText($haystack, $needle) {
}
}

/**
* @param $query
* @param Page $page
* @param $taxonomies
* @return bool
*/
private function notFound($query, $page, $taxonomies)
{
$searchable_types = ['title', 'content', 'taxonomy'];
$results = true;
$search_content = $this->config->get('plugins.simplesearch.search_content');

foreach ($searchable_types as $type) {
if ($type === 'title') {
$result = $this->matchText(strip_tags($page->title()), $query) === false;
Expand All @@ -339,7 +347,12 @@ private function notFound($query, $page, $taxonomies)
}
$result = !$taxonomy_match;
} else {
$result = $this->matchText(strip_tags($page->content()), $query) === false;
if ($search_content == 'raw') {
$content = $page->rawMarkdown();
} else {
$content = $page->content();
}
$result = $this->matchText(strip_tags($content), $query) === false;
}
$results = $results && $result;
if ($results === false ) {
Expand Down
1 change: 1 addition & 0 deletions simplesearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ built_in_css: true
display_button: false
min_query_length: 3
route: /search
search_content: rendered
template: simplesearch_results
filters:
category: blog
Expand Down

0 comments on commit aa0c730

Please sign in to comment.