Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions Classes/Controller/AjaxSearchController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,31 @@
* source code.
*/

use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\Neos\View\FusionView;

/**
* Class AjaxSearchController
*/
class AjaxSearchController extends ActionController
{
/**
* Override the default view from the ActionController to output TypoScript directly
* Override the default view from the ActionController to output Fusion directly
*
* @var string
* @api
*/
protected $defaultViewObjectName = \Neos\Neos\View\TypoScriptView::class;
protected $defaultViewObjectName = FusionView::class;

/**
* @param NodeInterface $node
*
* @return void
*/
public function searchAction(NodeInterface $node)
{
/* @var $view \Neos\Neos\View\TypoScriptView */
/* @var FusionView $view */
$view = $this->view;
$view->setTypoScriptPath('ajaxSearch');
$view->setFusionPath('ajaxSearch');
$view->assign('value', $node);
}
}
10 changes: 5 additions & 5 deletions Classes/Controller/SuggestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,29 @@
* source code.
*/

use Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient;
use Neos\Flow\Annotations as Flow;
use Neos\Flow\Mvc\Controller\ActionController;
use Neos\Flow\Mvc\View\JsonView;

/**
* Class SuggestController
*/
class SuggestController extends ActionController
{
/**
* @Flow\Inject
* @var \Flowpack\ElasticSearch\ContentRepositoryAdaptor\ElasticSearchClient
* @var ElasticSearchClient
*/
protected $elasticSearchClient;

/**
* @var array
*/
protected $viewFormatToObjectNameMap = [
'json' => 'Neos\Flow\Mvc\View\JsonView'
'json' => JsonView::class
];

/**
* @param string $term
*
* @return void
*/
public function indexAction($term)
Expand Down
2 changes: 2 additions & 0 deletions Classes/EelHelper/SearchArrayHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class SearchArrayHelper implements ProtectedContextAwareInterface
* Concatenate arrays or values to a new array
*
* @param array|mixed $arrays First array or value
*
* @return array The array with concatenated arrays or values
*/
public function flatten($arrays)
Expand All @@ -43,6 +44,7 @@ public function flatten($arrays)
* All methods are considered safe
*
* @param string $methodName
*
* @return boolean
*/
public function allowsCallOfMethod($methodName)
Expand Down
20 changes: 8 additions & 12 deletions Classes/FusionObjects/CanRenderImplementation.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,25 @@
use Neos\Flow\Annotations as Flow;
use Neos\Fusion\FusionObjects\AbstractFusionObject;

/**
* Class CanRenderImplementation
*
*/
class CanRenderImplementation extends AbstractFusionObject
{
/**
* TypoScript Type which shall be rendered
* Evaluate this Fusion object and return the result
*
* @return string
* @return mixed
*/
public function getType()
public function evaluate()
{
return $this->tsValue('type');
return $this->runtime->canRender('/type<' . $this->getType() . '>');
}

/**
* Evaluate this TypoScript object and return the result
* Fusion Type which shall be rendered
*
* @return mixed
* @return string
*/
public function evaluate()
public function getType()
{
return $this->tsRuntime->canRender('/type<' . $this->getType() . '>');
return $this->fusionValue('type');
}
}
2 changes: 1 addition & 1 deletion Configuration/Policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ roles:
permission: GRANT
-
privilegeTarget: Flowpack_SearchPlugin_Controller_AjaxSearchController
permission: GRANT
permission: GRANT
6 changes: 3 additions & 3 deletions Configuration/Routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
'@controller': 'Suggest'
'@action': 'index'
'@format': 'json'
appendExceedingArguments: TRUE
appendExceedingArguments: true
httpMethods: ['GET']
-
name: 'flowpack/searchplugin - SuggestController->ajax'
Expand All @@ -17,5 +17,5 @@
'@controller': 'AjaxSearch'
'@action': 'search'
'@format': 'html'
appendExceedingArguments: TRUE
httpMethods: ['GET']
appendExceedingArguments: true
httpMethods: ['GET']
14 changes: 9 additions & 5 deletions Configuration/Settings.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@

Neos:
Neos:
typoScript:
autoInclude:
Flowpack.SearchPlugin: true
Flow:
mvc:
routes:
'Flowpack.SearchPlugin':
position: 'before Neos.Neos'
Fusion:
defaultContext:
Flowpack.SearchPlugin.Array: Flowpack\SearchPlugin\EelHelper\SearchArrayHelper
Neos:
fusion:
autoInclude:
Flowpack.SearchPlugin: true
26 changes: 10 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
# Flowpack.SearchPlugin

This plugin is just a very bare-bones basis for a Search-Plugin, to be used together with
Flowpack.ElasticSearch.ContentRepositoryAdaptor or Flowpack.SimpleSearch.ContentRepositoryAdaptor.
This plugin is just a very bare-bones basis for a Search Plugin, to be used together with
[Flowpack.ElasticSearch.ContentRepositoryAdaptor](https://github.com/Flowpack/Flowpack.ElasticSearch.ContentRepositoryAdaptor)
or [Flowpack.SimpleSearch.ContentRepositoryAdaptor](https://github.com/Flowpack/Flowpack.SimpleSearch.ContentRepositoryAdaptor).

## Installation

Make sure to include the Routes from this package into your main `Configuration/Routes.yaml` by the following snippet:

-
name: 'Flowpack.SearchPlugin'
uriPattern: '<SearchSubroutes>'
subRoutes:
'SearchSubroutes':
package: 'Flowpack.SearchPlugin'
Inclusion of the routes from this package into your main `Configuration/Routes.yaml` is no longer needed as of Flow 4.0.

## Configuration


### Pagination

The pagination search results can be configured via TypoScript. The following shows the defaults:
The pagination search results can be configured via Fusion. The following shows the defaults:

prototype(Flowpack.SearchPlugin:Search).configuration {
itemsPerPage = 25
insertAbove = ${false}
insertBelow = ${true}
insertAbove = false
insertBelow = true
maximumNumberOfLinks = 10
}

### Custom result rendering

The result list is rendered using a TypoScript object of type `nodeType + 'SearchResult'` for each hit.
The result list is rendered using a Fusion object of type `nodeType + 'SearchResult'` for each hit.
Thus you can easily adjust the rendering per type like this for an imaginary `Acme.AcmeCom:Product` nodetype:

prototype(Acme.AcmeCom:ProductSearchResult) < prototype(TYPO3.Neos:DocumentSearchResult) {
prototype(Acme.AcmeCom:ProductSearchResult) < prototype(Neos.Neos:DocumentSearchResult) {
templatePath = 'resource://Acme.AcmeCom/Private/Templates/SearchResult/ProductSearchResult.html'
}

Expand All @@ -57,6 +51,6 @@ The plugin comes with a controller that can be reached like this per default, us

{f:uri.action(action: 'index', controller: 'AjaxSearch', package: 'Flowpack.SearchPlugin', absolute: 1)}

It expects the search term as a parameter named `q` (as defined in `AjaxSearch.ts2`). This controller
It expects the search term as a parameter named `q` (as defined in `AjaxSearch.fusion`). This controller
renders the search results and returns them as HTML without any of the page template. It can therefore
be used to request search results via AJAX and display the result by adding it to the DOM as needed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
prototype(Flowpack.SearchPlugin:AjaxSearch) < prototype(Neos.Fusion:Template) {
templatePath = 'resource://Flowpack.SearchPlugin/Private/Templates/NodeTypes/AjaxSearch.html'

searchResultRenderer = Flowpack.SearchPlugin:SearchResultRenderer {
@context.searchResults = ${Search.query(site).fulltext(request.arguments.q).execute()}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ prototype(Flowpack.SearchPlugin:SingleResult) < prototype(Neos.Fusion:Case) {
}

fallback {
condition = TRUE
condition = true
type = 'Neos.Neos:DocumentSearchResult'
}
}
Expand Down
6 changes: 3 additions & 3 deletions Resources/Private/Fusion/Root.fusion
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prototype(Flowpack.SearchPlugin:CanRender).@class = 'Flowpack\\SearchPlugin\\FusionObjects\\CanRenderImplementation'

include: SearchPlugin.ts2
include: ResultRendering.ts2
include: AjaxSearch.ts2
include: SearchPlugin.fusion
include: ResultRendering.fusion
include: AjaxSearch.fusion

ajaxSearch = Flowpack.SearchPlugin:AjaxSearch
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ prototype(Flowpack.SearchPlugin:Search) < prototype(Neos.Neos:Content) {

configuration = Neos.Fusion:RawArray {
itemsPerPage = 25
insertAbove = ${false}
insertBelow = ${true}
insertAbove = false
insertBelow = true
maximumNumberOfLinks = 10
}

Expand Down
1 change: 0 additions & 1 deletion Resources/Private/Translations/de/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="" product-name="Flowpack.SearchPlugin" source-language="en" datatype="plaintext" target-language="de">
<body>

<trans-unit id="search" xml:space="preserve">
<source>Search</source>
<target xml:lang="de" state="translated">Suchen</target>
Expand Down
2 changes: 0 additions & 2 deletions Resources/Private/Translations/en/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="" product-name="Flowpack.SearchPlugin" source-language="en" datatype="plaintext">
<body>

<trans-unit id="search" xml:space="preserve">
<source>Search</source>
</trans-unit>
Expand All @@ -12,7 +11,6 @@
<trans-unit id="path" xml:space="preserve">
<source>Path</source>
</trans-unit>

</body>
</file>
</xliff>
2 changes: 0 additions & 2 deletions Resources/Private/Translations/pl/Main.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file original="" product-name="Flowpack.SearchPlugin" source-language="en" datatype="plaintext" target-language="pl">
<body>

<trans-unit id="search" xml:space="preserve">
<source>Search</source>
<target xml:lang="pl" state="translated">Szukaj</target>
Expand All @@ -15,7 +14,6 @@
<source>Path</source>
<target xml:lang="pl" state="translated">Ścieżka</target>
</trans-unit>

</body>
</file>
</xliff>
24 changes: 19 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{
"name": "flowpack/searchplugin",
"license": "MIT",
"type": "neos-package",
"description": "Plugin for search integration via content node",
"require": {
"typo3/flow": "~4.0 || dev-master",
"flowpack/elasticsearch": "~2.0 || dev-master",
"neos/content-repository-search": "~3.0 || dev-master"
"flowpack/elasticsearch-contentrepositoryadaptor": "^3.0",
"neos/content-repository": "^3.0",
"neos/content-repository-search": "^3.0",
"neos/eel": "^4.0",
"neos/flow": "^4.0",
"neos/fusion": "^3.0",
"neos/neos": "^3.0"
},
"autoload": {
"psr-4": {
Expand Down Expand Up @@ -73,7 +78,16 @@
"Neos.Fusion-20161201202543",
"Neos.Neos-20161201222211",
"Neos.Fusion-20161202215034",
"Neos.ContentRepository.Search-20161210231100"
"Neos.ContentRepository.Search-20161210231100",
"Neos.SwiftMailer-20161130105617",
"Neos.Fusion-20161219092345",
"Neos.ContentRepository-20161219093512",
"Neos.Media-20161219094126",
"Neos.Neos-20161219094403",
"Neos.Neos-20161219122512",
"Neos.Fusion-20161219130100",
"Neos.Neos-20161220163741",
"Neos.Fusion-20170120013047"
]
}
}
}