Skip to content

Commit

Permalink
Merge pull request #208 from dvoracek-slub/pr-extbase-fluid
Browse files Browse the repository at this point in the history
Migrate to Kitodo.Presentation 4
  • Loading branch information
sebastian-meyer authored Aug 31, 2022
2 parents 6494b9b + 2d53fec commit 30a744c
Show file tree
Hide file tree
Showing 87 changed files with 1,319 additions and 1,933 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{composer.json,package.json}]
indent_size = 2
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
.vscode/
.DS_Store
node_modules
Resources/Public/Css/allStyles.css.map
Resources/Public/Css/webStyles.css.map
*.css.map
Documentation-GENERATED-temp/
1 change: 1 addition & 0 deletions Build/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16
2 changes: 2 additions & 0 deletions Build/Documentation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_build
venv
35 changes: 35 additions & 0 deletions Build/Documentation/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""
Basic Sphinx configuration for TYPO3 theme. Uses configuration from Settings.cfg.
"""

import ConfigParser

settings = globals()
settings['general'] = settings

config = ConfigParser.RawConfigParser()
config.read('../../Documentation/Settings.cfg')

for section in config.sections():
target = settings.setdefault(section, {})

for (name, value) in config.items(section):
if section == 'intersphinx_mapping':
target[name] = (value, None)
else:
target[name] = value

extensions = [
'sphinx_typo3_theme',
'sphinx.ext.intersphinx',
'sphinxcontrib.t3fieldlisttable'
]

html_theme = 'sphinx_typo3_theme'

# The TYPO3 convention is to capitalize the index filename, which would require
# us to visit http://127.0.0.1:8000/Index.html. We thus add an `index.html` that
# redirects to `Index.html`.
master_doc = 'Index'
html_extra_path = ['index.html']
exclude_patterns = []
7 changes: 7 additions & 0 deletions Build/Documentation/docker-compose.t3docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '3'
services:
t3docs:
image: t3docs/render-documentation:latest
volumes:
- ../../:/PROJECT:ro
- ../../Documentation-GENERATED-temp:/RESULT
10 changes: 10 additions & 0 deletions Build/Documentation/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="0; url=Index.html">
</head>
<body>
The documentation entry is <a href="Index.html">Index.html</a>.
</body>
</html>
55 changes: 55 additions & 0 deletions Build/Documentation/sphinx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/bin/bash

BASE_DIR=$(dirname "$0")
VENV_DIR="$BASE_DIR/venv"
DOCS_DIR="$BASE_DIR/../../Documentation"

function usage()
{
cat << EOF
Usage: sphinx.sh <command> [options]
Commands:
i, install Install Sphinx in a virtualenv
s, serve Serve documentation. Options are forwared to sphinx-autobuild.
-H <host> Server host
-p <port> Server port
-a Write all files (from sphinx-build)
-E Don't use a saved environment (from sphinx-build)
EOF

exit
}

function use_sphinx()
{
source "$VENV_DIR/bin/activate"
}

COMMAND=$1
shift

case $COMMAND in
i|install)
if [ ! -e "$VENV_DIR" ]; then
# t3fieldlisttable doesn't seem to work with Python 3
virtualenv -p python2 "$VENV_DIR"
fi

use_sphinx

pip install sphinx-autobuild
pip install t3fieldlisttable
pip install sphinx_typo3_theme

;;

s|serve)
use_sphinx
sphinx-autobuild -c "$BASE_DIR" "$@" "$DOCS_DIR" "$BASE_DIR/_build"
;;

*)
usage
;;
esac
2 changes: 2 additions & 0 deletions Build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"description": "This TYPO3 extension provides the configuration and setup for the DFG-Viewer",
"main": "gruntfile.js",
"scripts": {
"watch": "grunt watch",
"build": "grunt terser less",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand Down
89 changes: 89 additions & 0 deletions Classes/Controller/SruController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?php

namespace Slub\Dfgviewer\Controller;

use Kitodo\Dlf\Domain\Model\Document;
use Kitodo\Dlf\Common\MetsDocument;
use Kitodo\Dlf\Domain\Repository\StructureRepository;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Controller class for the SRU plugin.
*
* Checks if the METS document contains a link to an SRU endpoint, and if so,
* adds a search form to the pageview.
*
* @package TYPO3
* @subpackage tx_dfgviewer
* @access public
*/
class SruController extends \Kitodo\Dlf\Controller\AbstractController
{
public function mainAction()
{
// Load current document.
$this->loadDocument($this->requestData);
if (
$this->document === null
|| $this->document->getDoc() === null
|| !$this->document->getDoc() instanceof MetsDocument
) {
// Quit without doing anything if required variables are not set.
return '';
}

// Get digital provenance information.
$digiProv = $this->document->getDoc()->mets->xpath('//mets:amdSec/mets:digiprovMD/mets:mdWrap[@OTHERMDTYPE="DVLINKS"]/mets:xmlData');

if ($digiProv) {
$links = $digiProv[0]->children('http://dfg-viewer.de/')->links;

// if no children found with given namespace, skip the following section
if ($links && $links->sru) {
$sruLink = htmlspecialchars(trim((string)$links->sru));
}
}

if (empty($sruLink)) {
// Quit without doing anything if required variables are not set.
return '';
}

$actionUrl = $this->uriBuilder->reset()
->setTargetPageUid($GLOBALS['TSFE']->id)
->setCreateAbsoluteUri(true)
->build();

$this->addSruResultsJS();

$this->view->assign('sruLink', $sruLink);
$this->view->assign('currentDocument', $this->document->getLocation());
$this->view->assign('actionUrl', $actionUrl);
}

/**
* Adds SRU Search result javascript
*
* @access protected
*
* @return string Viewer script tags ready for output
*/
protected function addSruResultsJS()
{
if (!empty($this->requestData['highlight']) && !empty($this->requestData['origimage'])) {
$highlight = unserialize(urldecode($this->requestData['highlight']));
$origImage = $this->requestData['origimage'];

// Add SRU Results if any
$javascriptFooter = '$(document).ready(function(){';
foreach ($highlight as $field) {
$javascriptFooter .= 'tx_dlf_viewer.addHighlightField([' . $field . '],' . $origImage . ');';
}
$javascriptFooter .= '})';

$pageRenderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRenderer::class);
$pageRenderer->addJsFooterInlineCode('tx-dfgviewer-footer', $javascriptFooter);
}
}
}
106 changes: 106 additions & 0 deletions Classes/Controller/UriController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?php
namespace Slub\Dfgviewer\Controller;

/***************************************************************
* Copyright notice
*
* (c) 2012 Sebastian Meyer <[email protected]>
* (c) 2022 Alexander Bigga <[email protected]>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/

use Kitodo\Dlf\Common\Helper;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
* Controller class for plugin 'Uri'.
*
* @author Sebastian Meyer <[email protected]>
* @package TYPO3
* @subpackage dlf
* @access public
*/
class UriController extends \Kitodo\Dlf\Controller\AbstractController
{
/**
* The main method of the plugin
*
* @return void
*/
public function mainAction()
{
// Load current document.
$this->loadDocument($this->requestData);

if ($this->document === null) {
return;
}

$doc = $this->document->getDoc();

// Get persistent identifier of book.
$uriBook = GeneralUtility::trimExplode(' ', $doc->physicalStructureInfo[$doc->physicalStructure[0]]['contentIds'], TRUE);

if (empty($uriBook)) {
$uriBook = $doc->getLogicalStructure($doc->toplevelId);
$uriBook = GeneralUtility::trimExplode(' ', $uriBook['contentIds'], TRUE);
}

if (!empty($uriBook)) {
$uris = [];
foreach ($uriBook as $uri) {
if (Helper::isValidHttpUrl($uri)) {
$uris[] = $uri;
} elseif (strpos($uri, 'urn:') === 0) {
if (strpos($uri, '/fragment/') === false) {
$uris[] = 'https://nbn-resolving.de/' . $uri;
} else {
$uris[] = 'https://nbn-resolving.org/' . $uri;
}
}
}
if (!empty($uris)) {
$this->view->assign('uriBooks', $uris);
}
}

// Get persistent identifier of page.
$uriPage = GeneralUtility::trimExplode(' ', $doc->physicalStructureInfo[$doc->physicalStructure[$this->requestData['page']]]['contentIds'], TRUE);

if (!empty($uriPage)) {
$uris = [];

foreach ($uriPage as $uri) {
if (Helper::isValidHttpUrl($uri)) {
$uris[] = $uri;
} elseif (strpos($uri, 'urn:') === 0) {
if (strpos($uri, '/fragment/') === false) {
$uris[] = 'https://nbn-resolving.de/' . $uri;
} else {
$uris[] = 'https://nbn-resolving.org/' . $uri;
}
}
}
if (!empty($uris)) {
$this->view->assign('uriPages', $uris);
}
}
}
}
6 changes: 3 additions & 3 deletions Classes/Plugins/Sru/SruEid.php → Classes/Eid/SruEid.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Slub\Dfgviewer\Plugins\Sru;
namespace Slub\Dfgviewer\Eid;

/***************************************************************
* Copyright notice
*
* (c) 2014 Alexander Bigga <alexander.bigga@slub-dresden.de>
* (c) 2014 Alexander Bigga <typo3@slub-dresden.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
Expand Down Expand Up @@ -33,7 +33,7 @@
/**
* Plugin 'DFG-Viewer: SRU Client eID script' for the 'dfgviewer' extension.
*
* @author Alexander Bigga <alexander.bigga@slub-dresden.de>
* @author Alexander Bigga <typo3@slub-dresden.de>
* @copyright Copyright (c) 2014, Alexander Bigga, SLUB Dresden
* @package TYPO3
* @subpackage tx_dfgviewer
Expand Down
Loading

0 comments on commit 30a744c

Please sign in to comment.