Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Classes/Controller/DocModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
use TYPO3\CMS\Backend\Routing\UriBuilder;
use TYPO3\CMS\Core\Configuration\ExtensionConfiguration;
use TYPO3\CMS\Core\Http\HtmlResponse;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Core\Page\PageRenderer;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ControllerInterface;
use TYPO3\CMS\Extbase\Mvc\RequestInterface;
use TYPO3\CMS\Fluid\View\StandaloneView;
Expand Down Expand Up @@ -59,7 +55,7 @@ private function getStandaloneView(): StandaloneView
$view = GeneralUtility::makeInstance(StandaloneView::class);
$view->setTemplatePathAndFilename($templatePathAndFilename);
$view->assignMultiple([
'docRootPath' => $uri,
'docRootPath' => $uri->__toString(),
'documentationName' => $documentationName,
'darkMode' => $settings['darkMode'] ?? false
]);
Expand Down
10 changes: 8 additions & 2 deletions Classes/Controller/DocServeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,22 @@ public function mainAction(ServerRequestInterface $request): ResponseInterface
private function getFile(string $path): string
{
$path = PathUtility::getCanonicalPath($path);
if (!StringUtility::beginsWith($path, $this->extensionConfiguration['documentationRootPath'] ?? '')) {
if (!str_starts_with($path, $this->extensionConfiguration['documentationRootPath'] ?? '')) {
return '';
}


$fileInfo = pathinfo($path);
if (!in_array(strtolower($fileInfo['extension']), ['png', 'svg', 'gif', 'md', 'doc', 'docx', 'jpeg', 'jpg'], true)) {
return '';
}

$file = Environment::getPublicPath() . $path;
if (\str_starts_with($path, 'EXT:')) {
$file = GeneralUtility::getFileAbsFileName($path);
} else {
$file = Environment::getPublicPath() . $path;
}

if (!is_file($file)) {
return '';
}
Expand Down
19 changes: 19 additions & 0 deletions Classes/Widgets/CtaWidget.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace GeorgRinger\Doc\Widgets;

use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Dashboard\Widgets\AdditionalJavaScriptInterface;

class CtaWidget extends \TYPO3\CMS\Dashboard\Widgets\CtaWidget implements AdditionalJavaScriptInterface
{

public function getJsFiles(): array
{
return [
'EXT:doc/Resources/Public/JavaScript/widget-cta.js',
];
}
}
2 changes: 1 addition & 1 deletion Classes/Widgets/Provider/ExtDocButtonProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getTitle(): string
public function getLink(): string
{
if (ExtensionManagementUtility::isLoaded('doc')) {
return 'javascript:top.goToModule(' . GeneralUtility::quoteJSvalue('help_doc') . ');';
return 'open-docs-module';
}

return '';
Expand Down
31 changes: 31 additions & 0 deletions Configuration/ContentSecurityPolicies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Directive;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Mutation;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\MutationCollection;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\MutationMode;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\Scope;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\SourceScheme;
use TYPO3\CMS\Core\Security\ContentSecurityPolicy\UriValue;
use TYPO3\CMS\Core\Type\Map;

return Map::fromEntries([
Scope::backend(),

new MutationCollection(
new Mutation(
MutationMode::Extend,
Directive::FontSrc,
SourceScheme::https,
new UriValue('https://fonts.gstatic.com/s/robotomono/')
),
new Mutation(
MutationMode::Extend,
Directive::StyleSrc,
SourceScheme::https,
new UriValue('https://fonts.googleapis.com/css')
),
)
]);
31 changes: 15 additions & 16 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,31 @@

namespace GeorgRinger\Doc;

use GeorgRinger\Doc\Widgets\CtaWidget;
use GeorgRinger\Doc\Widgets\Provider\ExtDocButtonProvider;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symfony\Component\DependencyInjection\Reference;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Dashboard\Dashboard;
use TYPO3\CMS\Dashboard\Widgets\CtaWidget;

return static function (ContainerConfigurator $configurator, ContainerBuilder $containerBuilder) {
$services = $configurator->services();

if ($containerBuilder->hasDefinition(Dashboard::class)) {
$services->set('dashboard.widget.gotoProjectDocumentation')
->class(CtaWidget::class)
->arg('$view', new Reference('dashboard.views.widget'))
->arg('$buttonProvider', new Reference(ExtDocButtonProvider::class))
->arg('$options', ['text' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.text'])
->tag('dashboard.widget', [
'identifier' => 'gotoProjectDocumentation',
'groupNames' => 'documentation',
'title' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.title',
'description' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.description',
'iconIdentifier' => 'content-widget-text',
'height' => 'small'
])
;
$services->set('dashboard.widget.gotoProjectDocumentation')->class(CtaWidget::class)
->autoconfigure()
->autowire()
->arg('$buttonProvider', new Reference(ExtDocButtonProvider::class))
->arg('$options', ['text' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.text'])
->tag('dashboard.widget', [
'identifier' => 'gotoProjectDocumentation',
'groupNames' => 'documentation',
'title' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.title',
'description' => 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.description',
'iconIdentifier' => 'content-widget-text',
'height' => 'small'
]);


$services->set('GeorgRinger\Doc\Widgets\Provider\ExtDocButtonProvider')
->arg('$title', 'LLL:EXT:doc/Resources/Private/Language/locallang.xlf:widget.buttonText')
Expand Down
7 changes: 4 additions & 3 deletions Resources/Private/Templates/Module.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
</head>
<body>
<div id="app"></div>
<script>
var docRootPath = '{docRoothPath.path}';

<script nonce="{f:security.nonce(directive: 'script-src')}">
var docRootPath = '{docRootPath}';
var documentationName = '{documentationName}';
window.$docsify = {
name: documentationName,
Expand All @@ -37,7 +38,7 @@
loadNavbar: false,
subMaxLevel: 0,
autoHeader: false
}
};
</script>
<script src="{f:uri.resource(path: 'EXT:doc/Resources/Public/docsify/docsify_4.11.6.js')}"></script>
<script src="{f:uri.resource(path: 'EXT:doc/Resources/Public/docsify/prism-php.min.js')}"></script>
Expand Down
11 changes: 11 additions & 0 deletions Resources/Public/JavaScript/widget-cta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
document.addEventListener('DOMContentLoaded', function () {
setTimeout(() => {
document.querySelectorAll('.widget-cta[href="open-docs-module"]').forEach(element => {
element.addEventListener('click', function (event) {
event.preventDefault();
var TYPO3 = TYPO3 || top.TYPO3;
TYPO3.ModuleMenu.App.showModule('help_doc');
});
});
}, 750);
});
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "georgringer/doc",
"type": "typo3-cms-extension",
"description": "Render documentation based on markdown files directly in the backend",
"version": "2.0.0",
"version": "3.0.0",
"keywords": [
"TYPO3",
"documentation",
Expand All @@ -19,7 +19,7 @@
"GPL-2.0-or-later"
],
"require": {
"typo3/cms-core": "^9 || ^10 || ^11 || ^12"
"typo3/cms-core": "^13"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
'title' => 'Markdown docs for everybody',
'description' => 'Render documentation based on markdown files directly in the backend',
'category' => 'be',
'version' => '1.1.1',
'version' => '3.0.0',
'state' => 'beta',
'author' => 'Georg Ringer',
'author_email' => 'mail@ringer.it',
'constraints' => [
'depends' => [
'typo3' => '9.5.9-11.6.99',
'typo3' => '13.0.0-13.4.99',
],
'conflicts' => [],
'suggests' => []
Expand Down
15 changes: 0 additions & 15 deletions ext_tables.php

This file was deleted.