Skip to content

Commit

Permalink
Merge pull request #1 from lukaszuznanski/TASK/Initial-commit
Browse files Browse the repository at this point in the history
[TASK] Initial commit
  • Loading branch information
lukaszuznanski authored Jul 10, 2020
2 parents 762efe3 + 7ed0c8d commit dca0bca
Show file tree
Hide file tree
Showing 19 changed files with 332 additions and 340 deletions.
13 changes: 13 additions & 0 deletions Configuration/TCA/Overrides/sys_template.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
defined('TYPO3_MODE') || die();

call_user_func(function () {
/**
* Default TypoScript for Headless Solr
*/
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
'headless_solr',
'Configuration/TypoScript',
'Headless Solr'
);
});
7 changes: 7 additions & 0 deletions Configuration/TypoScript/constants.typoscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugin.tx_solr {
view {
templateRootPath = EXT:headless_solr/Resources/Private/Solr/Templates/
partialRootPath = EXT:headless_solr/Resources/Private/Solr/Partials/
layoutRootPath = EXT:headless_solr/Resources/Private/Solr/Layouts/
}
}
31 changes: 31 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
tt_content.list =< lib.contentElementWithHeader
tt_content.list {
fields {
content {
fields {
data = CASE
data {
key.field = list_type

solr_pi_results = USER
solr_pi_results {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
vendorName = ApacheSolrForTypo3
extensionName = Solr
settings < plugin.tx_solr.settings
persistence < plugin.tx_solr.persistence
view < plugin.tx_solr.view
pluginName = pi_results
switchableControllerActions {
Search {
1 = results
2 = form
}
}
}
}
}

}
}
}
360 changes: 21 additions & 339 deletions LICENSE

Large diffs are not rendered by default.

26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
# headless_solr
# TYPO3 Extension "headless_solr" - Provides fluid templates to render proper JSON from EXT:solr
This extension provides integration to headless extension with solr extension.

If you have any questions just drop a line in #initiative-pwa Slack channel.

## Requirements
Extension requires TYPO3 in version at least 9.5.

## Installation
Install extension using composer\
``composer require friendsoftypo3/headless_solr``

and then, include Typoscript template, and you are ready to go.

## Development
Development for this extension is happening as part of the TYPO3 PWA initiative, see https://typo3.org/community/teams/typo3-development/initiatives/pwa/

## Credits

A special thanks goes to [macopedia.com](https://macopedia.com) company, which is sponsoring development of this solution.

### Developers involved in the project

- Łukasz Uznański (Macopedia)
- Adam Marcinkowski (Macopedia)
1 change: 1 addition & 0 deletions Resources/Private/Solr/Layouts/Fullwidth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<f:render section="content" />
1 change: 1 addition & 0 deletions Resources/Private/Solr/Layouts/Split.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<f:render section="content" />
43 changes: 43 additions & 0 deletions Resources/Private/Solr/Partials/Result/Document.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers/">

<f:section name="Document">
<f:spaceless>
<f:if condition="{resultSet.hasSearched}">
{"pagination": <s:widget.resultPaginate resultSet="{resultSet}">
,"list": {
"count": {resultSet.searchResults -> f:count()}
,"results": [<f:for each="{resultSet.searchResults}" as="searchResult" iteration="iterator">
<f:format.raw>
<f:format.json value="{
uid: searchResult.fields.uid,
pid: searchResult.fields.pid,
typeNum: searchResult.fields.typeNum,
site: searchResult.fields.site,
type: searchResult.fields.type,
searchType: searchResult.searchType_stringS,
title: searchResult.fields.title,
titleExact: searchResult.fields.titleExact,
subTitle: searchResult.fields.subTitle,
navTitle: searchResult.fields.navTitle,
author: searchResult.fields.author,
content: searchResult.fields.content,
contentExact: searchResult.fields.contentExact,
teaser: searchResult.fields.teaser,
form: searchResult.fields.form_textExactS,
ingredients: searchResult.fields.ingredients_textExactS,
dosing: searchResult.fields.dosing_textExactS,
responsible: searchResult.fields.responsible_textExactS,
warnings: searchResult.fields.warnings_textExactS,
purpose: searchResult.fields.purpose_textExactS,
url: '{searchResult.fields.url -> headless:format.json.decode()}',
image: '{searchResult.fields.image_stringM.0 -> headless:format.json.decode()}'
}"/>
</f:format.raw>
{f:if(condition: iterator.isLast, else: ',')}
</f:for>]}
</s:widget.resultPaginate>}
</f:if>
</f:spaceless>
</f:section>
18 changes: 18 additions & 0 deletions Resources/Private/Solr/Partials/Result/PerPage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers">

<f:section name="PerPage">
<f:spaceless>
[<f:for each="{resultSet.usedSearchRequest.contextTypoScriptConfiguration.searchResultsPerPageSwitchOptionsAsArray}" as="availablePerPage" iteration="iterator">
<f:format.raw>
<f:format.json value="{
currentSearch: '{s:uri.search.currentSearch()}',
usedResultsPerPage: resultSet.usedResultsPerPage,
availablePerPage: availablePerPage
}"/>
</f:format.raw>
{f:if(condition: iterator.isLast, else: ',')}
</f:for>]
</f:spaceless>
</f:section>
39 changes: 39 additions & 0 deletions Resources/Private/Solr/Partials/Result/Sorting.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers">

<f:section name="Sorting">
<f:for each="{resultSet.sortings}" as="sorting">

<f:if condition="{sorting.isResetOption}">
<f:then>
<li>
<a href="{s:uri.sorting.removeSorting()}" class="solr-ajaxified">{sorting.label}</a>
</li>
</f:then>

<f:else>
<f:if condition="{sorting.selected}">
<f:then>
<li class="active">
<a href="{s:uri.sorting.setSorting(sortingName: sorting.name, sortingDirection: sorting.oppositeDirection)}" class="solr-ajaxified">
<f:if condition="{sorting.isAscDirection}">
<f:then><span class=" glyphicon glyphicon-arrow-up pull-right"></span></f:then>
<f:else><span class=" glyphicon glyphicon-arrow-down pull-right"></span></f:else>
</f:if>
<span>{sorting.label}</span>

</a>
</li>
</f:then>
<f:else>
<li>
<a href="{s:uri.sorting.setSorting(sortingName: sorting.name, sortingDirection: sorting.direction)}" class="solr-ajaxified">{sorting.label}</a>
</li>
</f:else>
</f:if>
</f:else>
</f:if>

</f:for>
</f:section>
16 changes: 16 additions & 0 deletions Resources/Private/Solr/Partials/Search/Form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<f:section name="Form">
<f:spaceless>
<f:format.raw>
<f:format.json value="{
additionalFilters: additionalFilters,
existingParameters: existingParameters,
pluginNamespace: pluginNamespace,
name: name,
value: value,
pageUid: pageUid,
languageUid: languageUid,
query: q
}"/>
</f:format.raw>
</f:spaceless>
</f:section>
16 changes: 16 additions & 0 deletions Resources/Private/Solr/Templates/Search/Detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers/">
<f:layout name="Fullwidth"/>
<f:section name="content">
<f:spaceless>
<f:format.raw>
[<f:format.json value="{
document: document,
title: document.title,
content: document.content,
url: document.url
}"/>]
</f:format.raw>
</f:spaceless>
</f:section>
9 changes: 9 additions & 0 deletions Resources/Private/Solr/Templates/Search/Form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers/">

<f:layout name="Fullwidth"/>

<f:section name="content">
<f:render partial="Search/Form" section="Form" arguments="{search:search, additionalFilters:additionalFilters, pluginNamespace:pluginNamespace}" />
</f:section>
20 changes: 20 additions & 0 deletions Resources/Private/Solr/Templates/Search/Results.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers">

<f:layout name="Split"/>

<f:section name="content">
<f:spaceless>
<f:format.raw>
<f:format.json value="{
form: '{f:render(partial: \'Search/Form\', section: \'Form\', arguments: \'{search:search, additionalFilters:additionalFilters, pluginNamespace: pluginNamespace, resultSet: resultSet}\') -> headless:format.json.decode()}',
documents: '{f:render(partial: \'Result/Document\', section: \'Document\', arguments: \'{resultSet:resultSet}\') -> headless:format.json.decode()}',
resultPerPage: '{f:render(partial: \'Result/PerPage\', section: \'PerPage\', arguments: \'{resultSet:resultSet}\') -> headless:format.json.decode()}',
allResultCount: resultSet.allResultCount,
currentSearch: '{s:uri.search.currentSearch()}',
arguments: arguments.q
}"/>
</f:format.raw>
</f:spaceless>
</f:section>
5 changes: 5 additions & 0 deletions Resources/Private/Solr/Templates/Search/SolrNotAvailable.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<f:spaceless>
<f:format.raw>
<f:format.json value="Search is currently not available"/>
</f:format.raw>
</f:spaceless>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<f:spaceless>
<f:format.raw>
<f:format.json value="{
current: contentArguments.pagination.current,
numberOfPages: contentArguments.pagination.numberOfPages
}"/>
</f:format.raw>
</f:spaceless>
<f:renderChildren arguments="{contentArguments}" />
36 changes: 36 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "friendsoftypo3/headless_solr",
"type": "typo3-cms-extension",
"description": "This extension provides integration with solr to output content from TYPO3 in JSON format.",
"keywords": [
"TYPO3",
"headless",
"pwa",
"json",
"solr"
],
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Tymoteusz Motylewski",
"role": "Head"
},
{
"name": "Łukasz Uznański",
"role": "Developer"
},
{
"name": "TYPO3 PWA Initiative",
"role": "Developer",
"email": "extensions@macopedia.com"
}
],
"require": {
"typo3/cms-core": "^9.5 || ^10.0"
},
"suggest": {
"friendsoftypo3/headless": "^2.0"
}
}
22 changes: 22 additions & 0 deletions ext_emconf.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

$EM_CONF[$_EXTKEY] = [
'title' => 'Headless Solr',
'description' => 'This extension provides integration with solr to output content from TYPO3 in JSON format.',
'state' => 'beta',
'author' => 'Łukasz Uznański',
'author_email' => 'extensions@macopedia.com',
'category' => 'fe',
'internal' => '',
'version' => '1.0.0',
'constraints' => [
'depends' => [
'typo3' => '9.5.0-10.0.99',
'frontend' => '9.5.0-10.0.99'
],
'conflicts' => [],
'suggests' => [
'headless' => '2.0.0-2.9.9'
]
],
];
Binary file added ext_icon.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dca0bca

Please sign in to comment.