Skip to content

Commit

Permalink
Merge pull request #52 from daniellienert/task/refactor-modernize
Browse files Browse the repository at this point in the history
TASK: Modernize Fusion code
  • Loading branch information
daniellienert authored Apr 9, 2020
2 parents 9ee0b21 + 5b866f3 commit 75b1a20
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 123 deletions.
38 changes: 0 additions & 38 deletions Classes/FusionObjects/CanRenderImplementation.php

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
prototype(Neos.Neos:DocumentSearchResult) < prototype(Neos.Fusion:Template) {
templatePath = 'resource://Flowpack.SearchPlugin/Private/Fusion/Component/DocumentSearchResult/DocumentSearchResult.html'
node = ${node}
highlight = ${Flowpack.SearchPlugin.Array.flatten(searchHit.highlight)}

title = ${q(node).property('title')}
description = ''
parents = ${Array.reverse(q(node).parents('[instanceof Neos.Neos:Document]').get())}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
prototype(Neos.NodeTypes:PageSearchResult) < prototype(Neos.Neos:DocumentSearchResult)
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
prototype(Flowpack.SearchPlugin:AjaxSearch) < prototype(Neos.Fusion:Template) {
templatePath = 'resource://Flowpack.SearchPlugin/Private/Templates/NodeTypes/AjaxSearch.html'
templatePath = 'resource://Flowpack.SearchPlugin/Private/Fusion/Content/SearchPlugin/AjaxSearch/AjaxSearch.html'

searchResultRenderer = Flowpack.SearchPlugin:SearchResultRenderer {
@context.searchResults = ${Search.query(site).fulltext(request.arguments.q).execute()}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
prototype(Flowpack.SearchPlugin:Search.Form) < prototype(Neos.Fusion:Template) {
node = ${site}
dimensionCombination = ${Json.stringify(this.node.context.dimensions)}
templatePath = 'resource://Flowpack.SearchPlugin/Private/Fusion/Content/SearchPlugin/Form/Form.html'

inputClassNames = ''
searchWord = ${request.arguments.search}
}
32 changes: 32 additions & 0 deletions Resources/Private/Fusion/Content/SearchPlugin/Search/Search.fusion
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
prototype(Flowpack.SearchPlugin:Search) < prototype(Neos.Neos:Content) {
templatePath = 'resource://Flowpack.SearchPlugin/Private/Fusion/Content/SearchPlugin/Search/Search.html'

searchTerm = ${request.arguments.search}
searchQuery = ${this.searchTerm ? Search.query(site).fulltext(this.searchTerm).nodeType('Neos.Neos:Document') : null}

totalSearchResults = ${this.searchQuery.count()}

searchForm = Flowpack.SearchPlugin:Search.Form

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

searchResultRenderer = Neos.Fusion:Tag {
tagName = 'ol'
content = Flowpack.SearchPlugin:SearchResultRenderer
}
prototype(Flowpack.SearchPlugin:SingleResult).@process.wrap = ${'<li>' + value + '</li>'}

@cache {
mode = 'uncached'
context {
1 = 'site'
2 = 'node'
3 = 'documentNode'
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
prototype(Flowpack.SearchPlugin:SingleResult) < prototype(Neos.Fusion:Case) {
default {
condition = Neos.Fusion:CanRender {
type = ${node.nodeType.name + 'SearchResult'}
}
type = ${node.nodeType.name + 'SearchResult'}
}

fallback {
condition = true
type = 'Neos.Neos:DocumentSearchResult'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
prototype(Flowpack.SearchPlugin:SearchResultRenderer) < prototype(Neos.Fusion:Collection) {
// the "searchResults" are filled from the <search:widget.paginate> ViewHelper.
collection = ${searchResults}
itemRenderer = Flowpack.SearchPlugin:SingleResult
itemName = 'node'
// we also make the full ElasticSearch hit available to nested rendering, if possible
itemRenderer.@context.searchHit = ${searchResults.searchHitForNode(node)}
}
25 changes: 0 additions & 25 deletions Resources/Private/Fusion/ResultRendering.fusion

This file was deleted.

6 changes: 1 addition & 5 deletions Resources/Private/Fusion/Root.fusion
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
prototype(Flowpack.SearchPlugin:CanRender).@class = 'Flowpack\\SearchPlugin\\FusionObjects\\CanRenderImplementation'

include: SearchPlugin.fusion
include: ResultRendering.fusion
include: AjaxSearch.fusion
include: **/*.fusion

ajaxSearch = Flowpack.SearchPlugin:AjaxSearch
49 changes: 0 additions & 49 deletions Resources/Private/Fusion/SearchPlugin.fusion

This file was deleted.

10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
"type": "neos-package",
"description": "Plugin for search integration via content node",
"require": {
"neos/content-repository": "^3.0 || ^4.0 || ^5.0",
"neos/content-repository": "^4.0 || ^5.0",
"neos/content-repository-search": "^3.0 || dev-master",
"neos/eel": "^4.0 || ^5.0 || ^6.0",
"neos/flow": "^4.0 || ^5.0 || ^6.0",
"neos/fusion": "^3.0 || ^4.0 || ^5.0",
"neos/neos": "^3.0 || ^4.0 || ^5.0"
"neos/eel": "^5.0 || ^6.0",
"neos/flow": "^5.0 || ^6.0",
"neos/fusion": "^4.0 || ^5.0",
"neos/neos": "^4.0 || ^5.0"
},
"suggest": {
"flowpack/elasticsearch-contentrepositoryadaptor": "Provides search using Elasticsearch",
Expand Down

0 comments on commit 75b1a20

Please sign in to comment.