Merge branch 'master' into no-proxy-for-iiif

This commit is contained in:
Sebastian Meyer 2022-11-02 09:34:19 +01:00 committed by GitHub
commit da63257373
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 1234 additions and 368 deletions

View File

@ -40,25 +40,59 @@ class View3DController extends AbstractController
// Quit without doing anything if required variables are not set.
return '';
} else {
$url = $this->document->getDoc()->getFileLocation($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[1]]['files']['DEFAULT']);
if ($this->settings['useInternalProxy']) {
// Configure @action URL for form.
$uri = $this->uriBuilder->reset()
->setTargetPageUid($GLOBALS['TSFE']->id)
->setCreateAbsoluteUri(!empty($this->settings['forceAbsoluteUrl']) ? true : false)
->setArguments([
'eID' => 'tx_dlf_pageview_proxy',
'url' => urlencode($url),
'uHash' => GeneralUtility::hmac($url, 'PageViewProxy')
])
->build();
$url = $uri;
$model = trim($this->document->getDoc()->getFileLocation($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[1]]['files']['DEFAULT']));
$this->view->assign('3d', $model);
$modelConverted = trim($this->document->getDoc()->getFileLocation($this->document->getDoc()->physicalStructureInfo[$this->document->getDoc()->physicalStructure[1]]['files']['CONVERTED']));
$xml = $this->requestData['id'];
$settingsParts = explode("/", $model);
$fileName = end($settingsParts);
$path = substr($model, 0, strrpos($model, $fileName));
$modelSettings = $path . "metadata/" . $fileName . "_viewer";
if (!empty($modelConverted)) {
$model = $modelConverted;
}
$this->view->assign('url', $url);
$this->view->assign('scriptMain', '/typo3conf/ext/dlf/Resources/Public/Javascript/3DViewer/main.js');
$this->view->assign('scriptToastify', '/typo3conf/ext/dlf/Resources/Public/Javascript/Toastify/toastify.js');
$this->view->assign('scriptSpinner', '/typo3conf/ext/dlf/Resources/Public/Javascript/3DViewer/spinner/main.js');
if ($this->settings['useInternalProxy']) {
$absoluteUri = !empty($this->settings['forceAbsoluteUrl']) ? true : false;
$model = $this->uriBuilder->reset()
->setTargetPageUid($GLOBALS['TSFE']->id)
->setCreateAbsoluteUri($absoluteUri)
->setArguments([
'eID' => 'tx_dlf_pageview_proxy',
'url' => $model,
'uHash' => GeneralUtility::hmac($model, 'PageViewProxy')
])
->build();
$xml = $this->uriBuilder->reset()
->setTargetPageUid($GLOBALS['TSFE']->id)
->setCreateAbsoluteUri($absoluteUri)
->setArguments([
'eID' => 'tx_dlf_pageview_proxy',
'url' => $xml,
'uHash' => GeneralUtility::hmac($xml, 'PageViewProxy')
])
->build();
$modelSettings = $this->uriBuilder->reset()
->setTargetPageUid($GLOBALS['TSFE']->id)
->setCreateAbsoluteUri($absoluteUri)
->setArguments([
'eID' => 'tx_dlf_pageview_proxy',
'url' => $modelSettings,
'uHash' => GeneralUtility::hmac($modelSettings, 'PageViewProxy')
])
->build();
}
$this->view->assign('model', $model);
$this->view->assign('xml', $xml);
$this->view->assign('settings', $modelSettings);
$this->view->assign('proxy', $this->settings['useInternalProxy']);
}
}
}

View File

@ -67,7 +67,7 @@ class PageViewProxy
$origin = (string) ($request->getHeaderLine('Origin') ? : '*');
return $response
->withHeader('Access-Control-Allow-Methods', 'GET, OPTIONS')
->withHeader('Access-Control-Allow-Methods', 'GET, OPTIONS, HEAD')
->withHeader('Access-Control-Allow-Origin', $origin)
->withHeader('Access-Control-Max-Age', '86400');
}
@ -113,6 +113,39 @@ class PageViewProxy
return $this->withCorsResponseHeaders($response, $request);
}
/**
* Handle an HEAD request.
*
* @param ServerRequestInterface $request
* @return ResponseInterface
*/
protected function handleHead(ServerRequestInterface $request): ResponseInterface
{
$queryParams = $request->getQueryParams();
$url = (string) ($queryParams['url'] ?? '');
try {
$targetResponse = $this->requestFactory->request($url, 'HEAD', [
'headers' => [
'User-Agent' => $this->extConf['useragent'] ?? 'Kitodo.Presentation Proxy',
]
]);
} catch (\Exception $e) {
return new JsonResponse(['message' => 'Could not fetch resource of given URL.'], 500);
}
$clientResponse = GeneralUtility::makeInstance(Response::class)
->withStatus($targetResponse->getStatusCode());
$clientResponse = $this->copyHeaders($targetResponse, $clientResponse, [
'Content-Length',
'Content-Type',
'Last-Modified',
]);
return $this->withCorsResponseHeaders($clientResponse, $request);
}
/**
* Handle a GET request.
*
@ -133,7 +166,6 @@ class PageViewProxy
if (!hash_equals(GeneralUtility::hmac($url, 'PageViewProxy'), $uHash)) {
return new JsonResponse(['message' => 'No valid uHash passed!'], 401);
}
try {
$targetResponse = $this->requestFactory->request($url, 'GET', [
'headers' => [
@ -185,6 +217,9 @@ class PageViewProxy
case 'GET':
return $this->handleGet($request);
case 'HEAD':
return $this->handleHead($request);
default:
// 405 Method Not Allowed
return GeneralUtility::makeInstance(Response::class)

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<!--
* (c) Kitodo. Key to digital objects e.V. <contact@kitodo.org>
*
* This file is part of the Kitodo and TYPO3 projects.
*
* @license GNU General Public License version 3 or later.
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
-->
<T3DataStructure>
<meta>
<langDisable>1</langDisable>
</meta>
<sheets>
<sDEF>
<ROOT>
<TCEforms>
<sheetTitle>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:flexform.sheet_general</sheetTitle>
</TCEforms>
<type>array</type>
<el>
<settings.useInternalProxy>
<TCEforms>
<exclude>1</exclude>
<label>LLL:EXT:dlf/Resources/Private/Language/locallang_be.xlf:plugins.pageview.flexform.useInternalProxy</label>
<config>
<type>check</type>
<default>1</default>
</config>
</TCEforms>
</settings.useInternalProxy>
</el>
</ROOT>
</sDEF>
</sheets>
</T3DataStructure>

View File

@ -73,6 +73,10 @@ $GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_tableofc
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_toolbox'] = 'layout,select_key,pages,recursive';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_toolbox'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_toolbox', 'FILE:EXT:' . 'dlf/Configuration/Flexforms/Toolbox.xml');
// Plugin "view3d".
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_excludelist']['dlf_view3d'] = 'layout,select_key,pages,recursive';
$GLOBALS['TCA']['tt_content']['types']['list']['subtypes_addlist']['dlf_view3d'] = 'pi_flexform';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('dlf_view3d', 'FILE:EXT:' . 'dlf/Configuration/Flexforms/View3D.xml');
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'Kitodo.Dlf',

View File

@ -5,6 +5,7 @@ plugin.tx_dlf {
}
settings {
storagePid = {$plugin.tx_dlf.persistence.storagePid}
useInternalProxy = 1
}
}

View File

@ -13,8 +13,11 @@
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
data-namespace-typo3-fluid="true">
<p id="DFG_3DViewer" 3d="{url}" class="tx-dlf-view-3d"></p>
<script src="{scriptMain}" type="module"></script>
<script src="{scriptToastify}"></script>
<script src="{scriptSpinner}"></script>
<p id="DFG_3DViewer" 3d="{3d}" model="{model}" xml="{xml}" settings="{settings}" proxy="{proxy}" class="tx-dlf-view-3d"></p>
<f:section name="FooterAssets">
<script src="/typo3conf/ext/dlf/Resources/Public/Javascript/3DViewer/main.js" type="module"></script>
<script src="/typo3conf/ext/dlf/Resources/Public/Javascript/Toastify/toastify.js" type="text/javascript"></script>
<script src="/typo3conf/ext/dlf/Resources/Public/Javascript/3DViewer/spinner/main.js" type="text/javascript"></script>
</f:section>
</html>

View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-cloud-arrow-down" viewBox="0 0 16 16">
<path fill-rule="evenodd" d="M7.646 10.854a.5.5 0 0 0 .708 0l2-2a.5.5 0 0 0-.708-.708L8.5 9.293V5.5a.5.5 0 0 0-1 0v3.793L6.354 8.146a.5.5 0 1 0-.708.708l2 2z"/>
<path d="M4.406 3.342A5.53 5.53 0 0 1 8 2c2.69 0 4.923 2 5.166 4.579C14.758 6.804 16 8.137 16 9.773 16 11.569 14.502 13 12.687 13H3.781C1.708 13 0 11.366 0 9.318c0-1.763 1.266-3.223 2.942-3.593.143-.863.698-1.723 1.464-2.383zm.653.757c-.757.653-1.153 1.44-1.153 2.056v.448l-.445.049C2.064 6.805 1 7.952 1 9.318 1 10.785 2.23 12 3.781 12h8.906C13.98 12 15 10.988 15 9.773c0-1.216-1.02-2.228-2.313-2.228h-.5v-.5C12.188 4.825 10.328 3 8 3a4.53 4.53 0 0 0-2.941 1.1z"/>
</svg>

After

Width:  |  Height:  |  Size: 772 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-share" viewBox="0 0 16 16">
<path d="M13.5 1a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zM11 2.5a2.5 2.5 0 1 1 .603 1.628l-6.718 3.12a2.499 2.499 0 0 1 0 1.504l6.718 3.12a2.5 2.5 0 1 1-.488.876l-6.718-3.12a2.5 2.5 0 1 1 0-3.256l6.718-3.12A2.5 2.5 0 0 1 11 2.5zm-8.5 4a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3zm11 5.5a1.5 1.5 0 1 0 0 3 1.5 1.5 0 0 0 0-3z"/>
</svg>

After

Width:  |  Height:  |  Size: 448 B

View File

@ -1,5 +1,3 @@
{
"imports": {
"three": "/typo3conf/ext/dlf/Resources/Public/Javascript/3DViewer/build/three.module.js"
}
"imports": {
"three": "./build/three.module.js"
}

File diff suppressed because it is too large Load Diff