From d3426364ca8db6eab7fa5a8c041c9f131710a726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20F=C3=B6rster?= Date: Thu, 16 Jan 2025 23:01:12 +0100 Subject: [PATCH 1/4] [WIP] t3:13 SiteSets #156 --- Classes/Manipulation/RemoveComments.php | 2 +- Classes/Middleware/AbstractMiddleware.php | 11 +++ Classes/Service/CleanHtmlService.php | 11 +-- .../Sets/SourceOpt/settings.definitions.yaml | 68 ++++++++++--------- Configuration/Sets/SourceOpt/setup.typoscript | 1 - Configuration/TypoScript/setup.typoscript | 7 +- README.md | 6 +- 7 files changed, 61 insertions(+), 45 deletions(-) delete mode 100644 Configuration/Sets/SourceOpt/setup.typoscript diff --git a/Classes/Manipulation/RemoveComments.php b/Classes/Manipulation/RemoveComments.php index 3187419..c5c5911 100644 --- a/Classes/Manipulation/RemoveComments.php +++ b/Classes/Manipulation/RemoveComments.php @@ -19,7 +19,7 @@ class RemoveComments implements ManipulationInterface */ public function manipulate(string $html, array $configuration = []): string { - if (isset($configuration['keep.'])) { + if (isset($configuration['keep.'])) {// DEPRECATED $this->whiteListCommentsPatterns = $configuration['keep.']; } diff --git a/Classes/Middleware/AbstractMiddleware.php b/Classes/Middleware/AbstractMiddleware.php index 158afd7..c7b7eb8 100644 --- a/Classes/Middleware/AbstractMiddleware.php +++ b/Classes/Middleware/AbstractMiddleware.php @@ -34,6 +34,17 @@ protected function responseIsAlterable(ResponseInterface $response): bool return true; } + protected function getConfiguration(ServerRequestInterface $request): array + { + if(isset($GLOBALS['TSFE']->config['config']['sourceopt.']))// DEPRECATED + return $GLOBALS['TSFE']->config['config']['sourceopt.']; + + if($request->getAttribute('site')->getSettings()->get('sourceopt')) + return $request->getAttribute('site')->getSettings()->get('sourceopt'); + + throw new \Exception('SiteConfig:SourceOpt ist missing'); + } + protected function getStringStream(string $content): StreamInterface { $body = new Stream('php://temp', 'rw'); diff --git a/Classes/Service/CleanHtmlService.php b/Classes/Service/CleanHtmlService.php index 8125861..08529e1 100644 --- a/Classes/Service/CleanHtmlService.php +++ b/Classes/Service/CleanHtmlService.php @@ -56,11 +56,14 @@ public function setVariables(array $config): void $this->headerComment = $config['headerComment']; } - if (isset($config['formatHtml']) && is_numeric($config['formatHtml'])) { + if (isset($config['formatHtml']) && is_numeric($config['formatHtml'])) {// DEPRECATED $this->formatType = (int) $config['formatHtml']; } + if (isset($config['formatHtml.']['enabled']) && is_numeric($config['formatHtml.']['enabled']) && 0 <= $config['formatHtml.']['enabled']) { + $this->formatType = (int) $config['formatHtml.']['enabled']; + } - if (isset($config['formatHtml.']['tabSize']) && is_numeric($config['formatHtml.']['tabSize'])) { + if (isset($config['formatHtml.']['tabSize']) && is_numeric($config['formatHtml.']['tabSize']) && 0 < $config['formatHtml.']['tabSize']) { $this->tab = str_pad('', (int) $config['formatHtml.']['tabSize'], ' '); } @@ -68,7 +71,7 @@ public function setVariables(array $config): void $this->debugComment = (bool) $config['formatHtml.']['debugComment']; } - if (isset($config['dropEmptySpaceChar']) && (bool) $config['dropEmptySpaceChar']) { + if (isset($config['dropEmptySpaceChar']) && (bool) $config['dropEmptySpaceChar']) {// DEPRECATED ?! $this->emptySpaceChar = ''; } } @@ -115,7 +118,7 @@ public function clean(string $html, array $config = []): string ); } - if ($this->formatType > 0) { + if ($this->formatType) { $html = $this->formatHtml($html); } diff --git a/Configuration/Sets/SourceOpt/settings.definitions.yaml b/Configuration/Sets/SourceOpt/settings.definitions.yaml index d341f9e..05e0296 100644 --- a/Configuration/Sets/SourceOpt/settings.definitions.yaml +++ b/Configuration/Sets/SourceOpt/settings.definitions.yaml @@ -1,6 +1,6 @@ categories: sourceopt: - label: 'SourceOpt' + label: 'SourceOpt[imization]' sourceopt.cleaner: label: 'Cleaner' parent: sourceopt @@ -12,59 +12,61 @@ categories: parent: sourceopt settings: - plugin.sourceopt.enabled: + sourceopt.enabled: + category: sourceopt.cleaner label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.enabled - default: true type: bool + default: true + sourceopt.removeGenerator: category: sourceopt.cleaner - plugin.sourceopt.removeGenerator: label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.removeGenerator - default: true type: bool + default: true + sourceopt.removeComments: category: sourceopt.cleaner - plugin.sourceopt.removeComments: label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.removeComments - default: true type: bool + default: true + sourceopt.keepComments: category: sourceopt.cleaner - plugin.sourceopt.removeComments.keep.10: - label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.removeCommentsKeep10 - default: '/^TYPO3SEARCH_/usi' - type: string + label: 'Spare these listed comments [RegEx]' + type: stringlist + default: + - '/^TYPO3SEARCH_/usi' + sourceopt.headerComment: category: sourceopt.cleaner - plugin.sourceopt.headerComment: label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.headerComment - default: '' type: string - category: sourceopt.cleaner - plugin.sourceopt.formatHtml: + default: '' + sourceopt.formatHtml.enabled: + category: sourceopt.formater label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.formatHtml - default: '4' type: string + default: '4' + enum: + '0': 'off' + '1': 'no line break at all (code in one line)' + '2': 'minimalistic line breaks (structure defining box-elements)' + '3': 'aesthetic line breaks (important box-elements)' + '4': 'logic line breaks (all box-elements)' + '5': 'max line breaks (all elements)' + sourceopt.formatHtml.tabSize: category: sourceopt.formater - # enum: - # '0': Disable - # '1': No line break at all (code in one line) - # '2': Minimalistic line breaks (structure defining box-elements) - # '3': Aesthetic line breaks (important box-elements) - # '4': Logic line breaks (all box-elements) - plugin.sourceopt.formatHtml.tabSize: label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.formatHtmlTabSize - default: '' - type: string + type: int + default: 0 + sourceopt.formatHtml.debugComment: category: sourceopt.formater - plugin.sourceopt.formatHtml.debugComment: label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.formatHtmlDebugComment - default: false type: bool - category: sourceopt.formater - plugin.svgstore.enabled: + default: false + svgstore.enabled: + category: sourceopt.svgstore label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:svgstore.enabled - default: true type: bool + default: true + svgstore.fileSize: category: sourceopt.svgstore - plugin.svgstore.fileSize: label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:svgstore.fileSize - default: 50000 type: int - category: sourceopt.svgstore + default: 50000 diff --git a/Configuration/Sets/SourceOpt/setup.typoscript b/Configuration/Sets/SourceOpt/setup.typoscript deleted file mode 100644 index 540cfca..0000000 --- a/Configuration/Sets/SourceOpt/setup.typoscript +++ /dev/null @@ -1 +0,0 @@ -@import 'EXT:sourceopt/Configuration/TypoScript/setup.typoscript' diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 3ea2ad4..3bcea2c 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -4,6 +4,7 @@ config.sourceopt { formatHtml = {$sourceopt.formatHtml} formatHtml { + enabled = {$sourceopt.formatHtml.enabled} tabSize = {$sourceopt.formatHtml.tabSize} debugComment = {$sourceopt.formatHtml.debugComment} } @@ -13,6 +14,9 @@ config.sourceopt { removeGenerator = {$sourceopt.removeGenerator} removeComments = {$sourceopt.removeComments} removeComments.keep { + # for typo-search + 10 = {$sourceopt.removeComments.keep.10} + # TYPO3 specific comment 87 = /This website is powered by TYPO3/usi @@ -32,9 +36,6 @@ config.sourceopt { # Google pagespeed 104 = /^gps(e|s)/usi - - # for typo-search - 10 = {$sourceopt.removeComments.keep.10} } } config.svgstore { diff --git a/README.md b/README.md index 48b9bd8..c861cba 100644 --- a/README.md +++ b/README.md @@ -58,9 +58,9 @@ Note: The following features are executed in reverse order | sourceopt.removeComments.keep | array | Spare these listed comments: Regular expressions that match comments that should not be removed. Very useful e.g. to keep the TYPO3SEARCH-Comments so indexed_search can work properly | ``.10`` | | sourceopt.removeComments.keep.10 | string | Spare TYPO3SEARCH-Comments from removal | /^TYPO3SEARCH_/usi | | sourceopt.headerComment | string | Your additional (appended) header comment | `[empty]` | -| sourceopt.formatHtml | integer | Formats the code beautiful and easy readable. New lines and tabs are used in the usual way of illustrating the structure of an XML code.
**Options**https://github.com/lochmueller/sourceopt/blob/2346673ee51d2b64308e1ddb1433cea2f37eafcb/Classes/Service/CleanHtmlService.php#L156-L161
| 4 | -| sourceopt.formatHtml.tabSize | integer | Defines the size of the tabs used for formating. If blank one tab is used. If a number is specified the specified number of blank spaces is used instead. This will only work together with `formatHtml` | `[empty]` | -| sourceopt.formatHtml.debugComment | boolean | Includes a comment at the end of the html source code that points the numbers of open html tags. This will only work together with `formatHtml` | `[empty]` +| sourceopt.formatHtml.variant | integer | Formats the code beautiful and easy readable. New lines and tabs are used in the usual way of illustrating the structure of an XML code.
**Options**https://github.com/lochmueller/sourceopt/blob/2346673ee51d2b64308e1ddb1433cea2f37eafcb/Classes/Service/CleanHtmlService.php#L156-L161
| 4 | +| sourceopt.formatHtml.tabSize | integer | Defines the amount of spaces used for formating. If blank one tab is used. If a number is specified the specified number of blank spaces is used instead. This will only work together with `formatHtml` | 0 | +| sourceopt.formatHtml.debugComment | boolean | Includes a comment at the end of the HTML source code that points the numbers of open html tags. This will only work together with `formatHtml` | 0 ### RegEx Replace From 6373e346aae247f05eb100a5f27a175898dfd7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20F=C3=B6rster?= Date: Thu, 27 Feb 2025 20:10:36 +0100 Subject: [PATCH 2/4] [WIP] t3:13 SiteSets #156 --- Classes/Middleware/AbstractMiddleware.php | 15 +++++++++++++++ Configuration/TypoScript/constants.typoscript | 3 --- Configuration/TypoScript/setup.typoscript | 3 +-- README.md | 4 ++-- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/Classes/Middleware/AbstractMiddleware.php b/Classes/Middleware/AbstractMiddleware.php index c7b7eb8..858d052 100644 --- a/Classes/Middleware/AbstractMiddleware.php +++ b/Classes/Middleware/AbstractMiddleware.php @@ -10,9 +10,24 @@ use TYPO3\CMS\Core\Http\NullResponse; use TYPO3\CMS\Core\Http\Stream; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; +use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; abstract class AbstractMiddleware implements MiddlewareInterface { + /** @var ConfigurationManagerInterface */ + protected $configurationManager; + + /** + * Injects the Configuration Manager and loads the settings + * + * @param ConfigurationManagerInterface $configurationManager An instance of the Configuration Manager + */ + public function injectConfigurationManager( + ConfigurationManagerInterface $configurationManager + ): void { + $this->configurationManager = $configurationManager; + } + protected function responseIsAlterable(ResponseInterface $response): bool { if ($response instanceof NullResponse) { diff --git a/Configuration/TypoScript/constants.typoscript b/Configuration/TypoScript/constants.typoscript index 2bbdb11..62944cf 100644 --- a/Configuration/TypoScript/constants.typoscript +++ b/Configuration/TypoScript/constants.typoscript @@ -7,9 +7,6 @@ sourceopt.removeGenerator = 1 # cat=plugin.sourceopt/enable/50; type=boolean; label=LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.removeComments sourceopt.removeComments = 1 -# cat=plugin.sourceopt/typo/55; type=string; label=LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.removeCommentsKeep10 -sourceopt.removeComments.keep.10 = /^TYPO3SEARCH_/usi - # cat=plugin.sourceopt/typo/70; type=string; label=LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.headerComment sourceopt.headerComment = diff --git a/Configuration/TypoScript/setup.typoscript b/Configuration/TypoScript/setup.typoscript index 3bcea2c..6b6bc4f 100644 --- a/Configuration/TypoScript/setup.typoscript +++ b/Configuration/TypoScript/setup.typoscript @@ -4,7 +4,6 @@ config.sourceopt { formatHtml = {$sourceopt.formatHtml} formatHtml { - enabled = {$sourceopt.formatHtml.enabled} tabSize = {$sourceopt.formatHtml.tabSize} debugComment = {$sourceopt.formatHtml.debugComment} } @@ -15,7 +14,7 @@ config.sourceopt { removeComments = {$sourceopt.removeComments} removeComments.keep { # for typo-search - 10 = {$sourceopt.removeComments.keep.10} + 10 = /^TYPO3SEARCH_/usi # TYPO3 specific comment 87 = /This website is powered by TYPO3/usi diff --git a/README.md b/README.md index c861cba..db66a45 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Version -#### >= 5.2.5 +#### >= 5.3 https://github.com/lochmueller/sourceopt/blob/173f7bd2a44b546844961ced1f0831371badd620/composer.json#L8-L9 #### <= 5.2.0 (legacy) @@ -58,7 +58,7 @@ Note: The following features are executed in reverse order | sourceopt.removeComments.keep | array | Spare these listed comments: Regular expressions that match comments that should not be removed. Very useful e.g. to keep the TYPO3SEARCH-Comments so indexed_search can work properly | ``.10`` | | sourceopt.removeComments.keep.10 | string | Spare TYPO3SEARCH-Comments from removal | /^TYPO3SEARCH_/usi | | sourceopt.headerComment | string | Your additional (appended) header comment | `[empty]` | -| sourceopt.formatHtml.variant | integer | Formats the code beautiful and easy readable. New lines and tabs are used in the usual way of illustrating the structure of an XML code.
**Options**https://github.com/lochmueller/sourceopt/blob/2346673ee51d2b64308e1ddb1433cea2f37eafcb/Classes/Service/CleanHtmlService.php#L156-L161
| 4 | +| sourceopt.formatHtml | integer | Formats the code beautiful and easy readable. New lines and tabs are used in the usual way of illustrating the structure of an XML code.
**Options**https://github.com/lochmueller/sourceopt/blob/2346673ee51d2b64308e1ddb1433cea2f37eafcb/Classes/Service/CleanHtmlService.php#L156-L161
| 4 | | sourceopt.formatHtml.tabSize | integer | Defines the amount of spaces used for formating. If blank one tab is used. If a number is specified the specified number of blank spaces is used instead. This will only work together with `formatHtml` | 0 | | sourceopt.formatHtml.debugComment | boolean | Includes a comment at the end of the HTML source code that points the numbers of open html tags. This will only work together with `formatHtml` | 0 From 275a0be0062453f413f91e6177a9f2fcfb7ecad2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20F=C3=B6rster?= Date: Tue, 8 Apr 2025 15:29:20 +0200 Subject: [PATCH 3/4] [OPT] regex @ Manipulation & Service/SVG --- Classes/Manipulation/RemoveComments.php | 34 ++++++++--------------- Classes/Manipulation/RemoveGenerator.php | 2 +- Classes/Middleware/AbstractMiddleware.php | 12 ++++---- Classes/Service/SvgStoreService.php | 4 +-- Tests/UnitTests.xml | 4 +-- 5 files changed, 24 insertions(+), 32 deletions(-) diff --git a/Classes/Manipulation/RemoveComments.php b/Classes/Manipulation/RemoveComments.php index c5c5911..6cb085b 100644 --- a/Classes/Manipulation/RemoveComments.php +++ b/Classes/Manipulation/RemoveComments.php @@ -23,18 +23,16 @@ public function manipulate(string $html, array $configuration = []): string $this->whiteListCommentsPatterns = $configuration['keep.']; } - // match all comments, styles and scripts - $matches = []; - preg_match_all( - '/(?s)(()|(<[ \n\r]*style[^>]*>.*?<[ \n\r]*\/style[^>]*>)|(<[ \n\r]*script[^>]*>.*?<[ \n\r]*\/script[^>]*>))/im', - $html, - $matches + return preg_replace_callback( + '/\s*/', + function (array $match): string { + if ($this->keepComment($match[1])) { + return $match[0]; + } + return ''; + }, + $html ); - foreach ($matches[0] as $tag) { - if (false === $this->keepComment($tag)) { - $html = str_replace($tag, '', $html); - } - } return $html; } @@ -42,25 +40,17 @@ public function manipulate(string $html, array $configuration = []): string /** * Check if a comment is defined to be kept in a pattern whiteListOfComments. */ - protected function keepComment(string $commentHtml): bool + protected function keepComment(string $comment): bool { - // if not even a comment, skip this - if (!preg_match('/^\<\!\-\-(.*?)\-\-\>$/usi', $commentHtml)) { - return true; - } - // if not defined in white list if (!empty($this->whiteListCommentsPatterns)) { - $commentHtml = str_replace('', '', $commentHtml); - $commentHtml = trim($commentHtml); + $comment = trim($comment); foreach ($this->whiteListCommentsPatterns as $pattern) { - if (!empty($pattern) && preg_match($pattern, $commentHtml)) { + if (preg_match($pattern, $comment)) { return true; } } } - return false; } } diff --git a/Classes/Manipulation/RemoveGenerator.php b/Classes/Manipulation/RemoveGenerator.php index 9a108a8..714a05e 100644 --- a/Classes/Manipulation/RemoveGenerator.php +++ b/Classes/Manipulation/RemoveGenerator.php @@ -16,6 +16,6 @@ public function manipulate(string $html, array $configuration = []): string { $regex = ']+>'; - return (string) preg_replace('/' . $regex . '/is', '', $html); + return (string) preg_replace('/' . $regex . '/i', '', $html); } } diff --git a/Classes/Middleware/AbstractMiddleware.php b/Classes/Middleware/AbstractMiddleware.php index 858d052..39de605 100644 --- a/Classes/Middleware/AbstractMiddleware.php +++ b/Classes/Middleware/AbstractMiddleware.php @@ -51,13 +51,15 @@ protected function responseIsAlterable(ResponseInterface $response): bool protected function getConfiguration(ServerRequestInterface $request): array { - if(isset($GLOBALS['TSFE']->config['config']['sourceopt.']))// DEPRECATED - return $GLOBALS['TSFE']->config['config']['sourceopt.']; + if (isset($GLOBALS['TSFE']->config['config']['sourceopt.'])) {// DEPRECATED + return $GLOBALS['TSFE']->config['config']['sourceopt.']; + } - if($request->getAttribute('site')->getSettings()->get('sourceopt')) - return $request->getAttribute('site')->getSettings()->get('sourceopt'); + if ($request->getAttribute('site')->getSettings()->get('sourceopt')) { + return $request->getAttribute('site')->getSettings()->get('sourceopt'); + } - throw new \Exception('SiteConfig:SourceOpt ist missing'); + throw new \Exception('SiteConfig:SourceOpt ist missing'); } protected function getStringStream(string $content): StreamInterface diff --git a/Classes/Service/SvgStoreService.php b/Classes/Service/SvgStoreService.php index cb6704a..9494ce5 100644 --- a/Classes/Service/SvgStoreService.php +++ b/Classes/Service/SvgStoreService.php @@ -232,8 +232,8 @@ function (array $match): string { $svg = preg_replace('/\s{2,}/', ' ', $svg); // shrink whitespace } - $svg = preg_replace('/<([a-z\-]+)\s*(\/|>\s*<\/\1)>\s*|\s+(?=\/>)/i', '', $svg); // remove emtpy TAGs & shorten endings - $svg = preg_replace('/<((circle|ellipse|line|path|polygon|polyline|rect|stop|use)\s[^>]+?)\s*>\s*<\/\2>/', '<$1/>', $svg); // shorten/minify TAG syntax + $svg = preg_replace('/<([a-z]+)\s*(\/|>\s*<\/\1)>\s*|\s+(?=\/>)/i', '', $svg); // remove emtpy TAGs & shorten endings + $svg = preg_replace('/<(([a-z]+)\s[^>]+?)\s*>\s*<\/\2>/i', '<$1/>', $svg); // shorten/minify TAG syntax if (!is_dir($this->sitePath . $this->outputDir)) { GeneralUtility::mkdir_deep($this->sitePath . $this->outputDir); diff --git a/Tests/UnitTests.xml b/Tests/UnitTests.xml index 2595430..c971005 100644 --- a/Tests/UnitTests.xml +++ b/Tests/UnitTests.xml @@ -12,11 +12,11 @@ stopOnIncomplete="false" stopOnSkipped="false" verbose="false" -> + > Unit/ - ./Unit/AbstractUnitTest.php + ./Unit/AbstractUnitTest.php From e43b21de3a8728cc9d27e775bf113fa77a409a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20F=C3=B6rster?= Date: Tue, 4 Nov 2025 19:23:33 +0100 Subject: [PATCH 4/4] [WIP] t3:13 SiteSets #156 --- Classes/Resource/SvgFileRepository.php | 1 + Classes/Service/SvgStoreService.php | 2 ++ .../Sets/SourceOpt/settings.definitions.yaml | 32 ++++++++++++------- Resources/Private/Language/locallang.xlf | 3 ++ composer.json | 14 +++++--- 5 files changed, 36 insertions(+), 16 deletions(-) diff --git a/Classes/Resource/SvgFileRepository.php b/Classes/Resource/SvgFileRepository.php index 0b06144..7bc4a0e 100644 --- a/Classes/Resource/SvgFileRepository.php +++ b/Classes/Resource/SvgFileRepository.php @@ -23,6 +23,7 @@ public function findAllByStorageUids(array $storageUids): \Traversable return $queryBuilder ->select('sys_file.storage', 'sys_file.identifier', 'sys_file.sha1') + ->addSelectLiteral('COUNT(*) AS ' . $queryBuilder->quoteIdentifier('count')) ->from('sys_file') ->innerJoin( 'sys_file', diff --git a/Classes/Service/SvgStoreService.php b/Classes/Service/SvgStoreService.php index 9494ce5..f3a795d 100644 --- a/Classes/Service/SvgStoreService.php +++ b/Classes/Service/SvgStoreService.php @@ -201,6 +201,8 @@ private function populateCache(): bool $file['path'] = '/' . $storageArr[$file['storage']] . $file['identifier']; // ^[/] $file['defs'] = $this->addFileToSpriteArr($file['sha1'], $file['path']); +// TODO ; if(--$file['count']) INLINE @
+ if (null !== $file['defs']) { $this->svgFileArr[$file['path']] = $file['defs']; } diff --git a/Configuration/Sets/SourceOpt/settings.definitions.yaml b/Configuration/Sets/SourceOpt/settings.definitions.yaml index 05e0296..6a5cbca 100644 --- a/Configuration/Sets/SourceOpt/settings.definitions.yaml +++ b/Configuration/Sets/SourceOpt/settings.definitions.yaml @@ -41,30 +41,40 @@ settings: sourceopt.formatHtml.enabled: category: sourceopt.formater label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.formatHtml - type: string - default: '4' - enum: - '0': 'off' - '1': 'no line break at all (code in one line)' - '2': 'minimalistic line breaks (structure defining box-elements)' - '3': 'aesthetic line breaks (important box-elements)' - '4': 'logic line breaks (all box-elements)' - '5': 'max line breaks (all elements)' + type: bool + default: true sourceopt.formatHtml.tabSize: category: sourceopt.formater label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.formatHtmlTabSize type: int - default: 0 + default: 4 + sourceopt.formatHtml.indentation: + category: sourceopt.formater + label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.formatHtmlIndentation + type: int + default: 2 sourceopt.formatHtml.debugComment: category: sourceopt.formater label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:sourceopt.formatHtmlDebugComment - type: bool default: false + type: bool svgstore.enabled: category: sourceopt.svgstore label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:svgstore.enabled type: bool default: true + svgstore.renderMode: + category: sourceopt.svgstore + label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:svgstore.renderMode + type: select + default: symbol + items: + - label: 'Reference all SVGs (default)' + value: symbol + - label: 'Inline single-use SVGs (optimize traffic)' + value: distinct + - label: 'Inline all SVGs at HTML (not recommended)' + value: inline svgstore.fileSize: category: sourceopt.svgstore label: LLL:EXT:sourceopt/Resources/Private/Language/locallang.xlf:svgstore.fileSize diff --git a/Resources/Private/Language/locallang.xlf b/Resources/Private/Language/locallang.xlf index 1d4a212..c28ae89 100644 --- a/Resources/Private/Language/locallang.xlf +++ b/Resources/Private/Language/locallang.xlf @@ -43,6 +43,9 @@ Formatting Tab-Size: Spezify number of blank-space for formatting. If empty a tab will be used. + + Formatting `count`: Spezify number of blank-space for indentation. If empty a tab will be used. + Show debugging comment: A comment at the end of the html code that points out the number of open html tags. diff --git a/composer.json b/composer.json index e80e5fe..9202374 100644 --- a/composer.json +++ b/composer.json @@ -13,11 +13,6 @@ "HTML\\Sourceopt\\": "Classes/" } }, - "replace": { - "maxserv/replacecontent": "*", - "typo3-ter/replacecontent": "*", - "typo3-ter/sourceopt": "self.version" - }, "require-dev": { "typo3/testing-framework": "^8.2", "friendsofphp/php-cs-fixer": "^3.3", @@ -29,6 +24,15 @@ "TYPO3\\CMS\\Core\\Tests\\": ".Build/vendor/typo3/cms/typo3/sysext/core/Tests/" } }, + "suggest": { + "lochmueller/staticfilecache": "Ultra-fast TYPO3 caching via static HTML file delivery", + "webcoast/deferred-image-processing": "Faster TYPO3 processing via on-demand image generation" + }, + "replace": { + "maxserv/replacecontent": "*", + "typo3-ter/replacecontent": "*", + "typo3-ter/sourceopt": "self.version" + }, "config": { "vendor-dir": ".Build/vendor", "bin-dir": ".Build/bin",