Skip to content

Commit dca0bca

Browse files
Merge pull request #1 from lukaszuznanski/TASK/Initial-commit
[TASK] Initial commit
2 parents 762efe3 + 7ed0c8d commit dca0bca

File tree

19 files changed

+332
-340
lines changed

19 files changed

+332
-340
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
defined('TYPO3_MODE') || die();
3+
4+
call_user_func(function () {
5+
/**
6+
* Default TypoScript for Headless Solr
7+
*/
8+
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
9+
'headless_solr',
10+
'Configuration/TypoScript',
11+
'Headless Solr'
12+
);
13+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugin.tx_solr {
2+
view {
3+
templateRootPath = EXT:headless_solr/Resources/Private/Solr/Templates/
4+
partialRootPath = EXT:headless_solr/Resources/Private/Solr/Partials/
5+
layoutRootPath = EXT:headless_solr/Resources/Private/Solr/Layouts/
6+
}
7+
}
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
tt_content.list =< lib.contentElementWithHeader
2+
tt_content.list {
3+
fields {
4+
content {
5+
fields {
6+
data = CASE
7+
data {
8+
key.field = list_type
9+
10+
solr_pi_results = USER
11+
solr_pi_results {
12+
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
13+
vendorName = ApacheSolrForTypo3
14+
extensionName = Solr
15+
settings < plugin.tx_solr.settings
16+
persistence < plugin.tx_solr.persistence
17+
view < plugin.tx_solr.view
18+
pluginName = pi_results
19+
switchableControllerActions {
20+
Search {
21+
1 = results
22+
2 = form
23+
}
24+
}
25+
}
26+
}
27+
}
28+
29+
}
30+
}
31+
}

LICENSE

+21-339
Large diffs are not rendered by default.

README.md

+25-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,25 @@
1-
# headless_solr
1+
# TYPO3 Extension "headless_solr" - Provides fluid templates to render proper JSON from EXT:solr
2+
This extension provides integration to headless extension with solr extension.
3+
4+
If you have any questions just drop a line in #initiative-pwa Slack channel.
5+
6+
## Requirements
7+
Extension requires TYPO3 in version at least 9.5.
8+
9+
## Installation
10+
Install extension using composer\
11+
``composer require friendsoftypo3/headless_solr``
12+
13+
and then, include Typoscript template, and you are ready to go.
14+
15+
## Development
16+
Development for this extension is happening as part of the TYPO3 PWA initiative, see https://typo3.org/community/teams/typo3-development/initiatives/pwa/
17+
18+
## Credits
19+
20+
A special thanks goes to [macopedia.com](https://macopedia.com) company, which is sponsoring development of this solution.
21+
22+
### Developers involved in the project
23+
24+
- Łukasz Uznański (Macopedia)
25+
- Adam Marcinkowski (Macopedia)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<f:render section="content" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<f:render section="content" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
2+
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
3+
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers/">
4+
5+
<f:section name="Document">
6+
<f:spaceless>
7+
<f:if condition="{resultSet.hasSearched}">
8+
{"pagination": <s:widget.resultPaginate resultSet="{resultSet}">
9+
,"list": {
10+
"count": {resultSet.searchResults -> f:count()}
11+
,"results": [<f:for each="{resultSet.searchResults}" as="searchResult" iteration="iterator">
12+
<f:format.raw>
13+
<f:format.json value="{
14+
uid: searchResult.fields.uid,
15+
pid: searchResult.fields.pid,
16+
typeNum: searchResult.fields.typeNum,
17+
site: searchResult.fields.site,
18+
type: searchResult.fields.type,
19+
searchType: searchResult.searchType_stringS,
20+
title: searchResult.fields.title,
21+
titleExact: searchResult.fields.titleExact,
22+
subTitle: searchResult.fields.subTitle,
23+
navTitle: searchResult.fields.navTitle,
24+
author: searchResult.fields.author,
25+
content: searchResult.fields.content,
26+
contentExact: searchResult.fields.contentExact,
27+
teaser: searchResult.fields.teaser,
28+
form: searchResult.fields.form_textExactS,
29+
ingredients: searchResult.fields.ingredients_textExactS,
30+
dosing: searchResult.fields.dosing_textExactS,
31+
responsible: searchResult.fields.responsible_textExactS,
32+
warnings: searchResult.fields.warnings_textExactS,
33+
purpose: searchResult.fields.purpose_textExactS,
34+
url: '{searchResult.fields.url -> headless:format.json.decode()}',
35+
image: '{searchResult.fields.image_stringM.0 -> headless:format.json.decode()}'
36+
}"/>
37+
</f:format.raw>
38+
{f:if(condition: iterator.isLast, else: ',')}
39+
</f:for>]}
40+
</s:widget.resultPaginate>}
41+
</f:if>
42+
</f:spaceless>
43+
</f:section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
2+
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
3+
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers">
4+
5+
<f:section name="PerPage">
6+
<f:spaceless>
7+
[<f:for each="{resultSet.usedSearchRequest.contextTypoScriptConfiguration.searchResultsPerPageSwitchOptionsAsArray}" as="availablePerPage" iteration="iterator">
8+
<f:format.raw>
9+
<f:format.json value="{
10+
currentSearch: '{s:uri.search.currentSearch()}',
11+
usedResultsPerPage: resultSet.usedResultsPerPage,
12+
availablePerPage: availablePerPage
13+
}"/>
14+
</f:format.raw>
15+
{f:if(condition: iterator.isLast, else: ',')}
16+
</f:for>]
17+
</f:spaceless>
18+
</f:section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
2+
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
3+
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers">
4+
5+
<f:section name="Sorting">
6+
<f:for each="{resultSet.sortings}" as="sorting">
7+
8+
<f:if condition="{sorting.isResetOption}">
9+
<f:then>
10+
<li>
11+
<a href="{s:uri.sorting.removeSorting()}" class="solr-ajaxified">{sorting.label}</a>
12+
</li>
13+
</f:then>
14+
15+
<f:else>
16+
<f:if condition="{sorting.selected}">
17+
<f:then>
18+
<li class="active">
19+
<a href="{s:uri.sorting.setSorting(sortingName: sorting.name, sortingDirection: sorting.oppositeDirection)}" class="solr-ajaxified">
20+
<f:if condition="{sorting.isAscDirection}">
21+
<f:then><span class=" glyphicon glyphicon-arrow-up pull-right"></span></f:then>
22+
<f:else><span class=" glyphicon glyphicon-arrow-down pull-right"></span></f:else>
23+
</f:if>
24+
<span>{sorting.label}</span>
25+
26+
</a>
27+
</li>
28+
</f:then>
29+
<f:else>
30+
<li>
31+
<a href="{s:uri.sorting.setSorting(sortingName: sorting.name, sortingDirection: sorting.direction)}" class="solr-ajaxified">{sorting.label}</a>
32+
</li>
33+
</f:else>
34+
</f:if>
35+
</f:else>
36+
</f:if>
37+
38+
</f:for>
39+
</f:section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<f:section name="Form">
2+
<f:spaceless>
3+
<f:format.raw>
4+
<f:format.json value="{
5+
additionalFilters: additionalFilters,
6+
existingParameters: existingParameters,
7+
pluginNamespace: pluginNamespace,
8+
name: name,
9+
value: value,
10+
pageUid: pageUid,
11+
languageUid: languageUid,
12+
query: q
13+
}"/>
14+
</f:format.raw>
15+
</f:spaceless>
16+
</f:section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
2+
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
3+
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers/">
4+
<f:layout name="Fullwidth"/>
5+
<f:section name="content">
6+
<f:spaceless>
7+
<f:format.raw>
8+
[<f:format.json value="{
9+
document: document,
10+
title: document.title,
11+
content: document.content,
12+
url: document.url
13+
}"/>]
14+
</f:format.raw>
15+
</f:spaceless>
16+
</f:section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
2+
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
3+
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers/">
4+
5+
<f:layout name="Fullwidth"/>
6+
7+
<f:section name="content">
8+
<f:render partial="Search/Form" section="Form" arguments="{search:search, additionalFilters:additionalFilters, pluginNamespace:pluginNamespace}" />
9+
</f:section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
2+
xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
3+
xmlns:s="http://typo3.org/ns/ApacheSolrForTypo3/Solr/ViewHelpers">
4+
5+
<f:layout name="Split"/>
6+
7+
<f:section name="content">
8+
<f:spaceless>
9+
<f:format.raw>
10+
<f:format.json value="{
11+
form: '{f:render(partial: \'Search/Form\', section: \'Form\', arguments: \'{search:search, additionalFilters:additionalFilters, pluginNamespace: pluginNamespace, resultSet: resultSet}\') -> headless:format.json.decode()}',
12+
documents: '{f:render(partial: \'Result/Document\', section: \'Document\', arguments: \'{resultSet:resultSet}\') -> headless:format.json.decode()}',
13+
resultPerPage: '{f:render(partial: \'Result/PerPage\', section: \'PerPage\', arguments: \'{resultSet:resultSet}\') -> headless:format.json.decode()}',
14+
allResultCount: resultSet.allResultCount,
15+
currentSearch: '{s:uri.search.currentSearch()}',
16+
arguments: arguments.q
17+
}"/>
18+
</f:format.raw>
19+
</f:spaceless>
20+
</f:section>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<f:spaceless>
2+
<f:format.raw>
3+
<f:format.json value="Search is currently not available"/>
4+
</f:format.raw>
5+
</f:spaceless>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<f:spaceless>
2+
<f:format.raw>
3+
<f:format.json value="{
4+
current: contentArguments.pagination.current,
5+
numberOfPages: contentArguments.pagination.numberOfPages
6+
}"/>
7+
</f:format.raw>
8+
</f:spaceless>
9+
<f:renderChildren arguments="{contentArguments}" />

composer.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "friendsoftypo3/headless_solr",
3+
"type": "typo3-cms-extension",
4+
"description": "This extension provides integration with solr to output content from TYPO3 in JSON format.",
5+
"keywords": [
6+
"TYPO3",
7+
"headless",
8+
"pwa",
9+
"json",
10+
"solr"
11+
],
12+
"license": [
13+
"GPL-2.0-or-later"
14+
],
15+
"authors": [
16+
{
17+
"name": "Tymoteusz Motylewski",
18+
"role": "Head"
19+
},
20+
{
21+
"name": "Łukasz Uznański",
22+
"role": "Developer"
23+
},
24+
{
25+
"name": "TYPO3 PWA Initiative",
26+
"role": "Developer",
27+
"email": "[email protected]"
28+
}
29+
],
30+
"require": {
31+
"typo3/cms-core": "^9.5 || ^10.0"
32+
},
33+
"suggest": {
34+
"friendsoftypo3/headless": "^2.0"
35+
}
36+
}

ext_emconf.php

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
$EM_CONF[$_EXTKEY] = [
4+
'title' => 'Headless Solr',
5+
'description' => 'This extension provides integration with solr to output content from TYPO3 in JSON format.',
6+
'state' => 'beta',
7+
'author' => 'Łukasz Uznański',
8+
'author_email' => '[email protected]',
9+
'category' => 'fe',
10+
'internal' => '',
11+
'version' => '1.0.0',
12+
'constraints' => [
13+
'depends' => [
14+
'typo3' => '9.5.0-10.0.99',
15+
'frontend' => '9.5.0-10.0.99'
16+
],
17+
'conflicts' => [],
18+
'suggests' => [
19+
'headless' => '2.0.0-2.9.9'
20+
]
21+
],
22+
];

ext_icon.gif

177 Bytes
Loading

0 commit comments

Comments
 (0)