Update dependencies, min PHP 7.2
This commit is contained in:
parent
f62b2bec96
commit
e04335abeb
27
.github/workflows/php.yml
vendored
27
.github/workflows/php.yml
vendored
@ -9,7 +9,7 @@ jobs:
|
|||||||
matrix:
|
matrix:
|
||||||
# TODO : enable tests on windows
|
# TODO : enable tests on windows
|
||||||
operating-system: [ubuntu-latest, macOS-latest]
|
operating-system: [ubuntu-latest, macOS-latest]
|
||||||
php-versions: ['7.1', '7.2', '7.3']
|
php-versions: ['7.2', '7.3', '7.4']
|
||||||
|
|
||||||
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
|
name: PHP ${{ matrix.php-versions }} Test on ${{ matrix.operating-system }}
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
@ -21,8 +21,7 @@ jobs:
|
|||||||
uses: shivammathur/setup-php@master
|
uses: shivammathur/setup-php@master
|
||||||
with:
|
with:
|
||||||
php-version: ${{ matrix.php-versions }}
|
php-version: ${{ matrix.php-versions }}
|
||||||
extension-csv: mbstring, xdebug
|
extension-csv: mbstring
|
||||||
coverage: xdebug
|
|
||||||
|
|
||||||
- name: Get Composer Cache Directory
|
- name: Get Composer Cache Directory
|
||||||
id: composer-cache
|
id: composer-cache
|
||||||
@ -43,3 +42,25 @@ jobs:
|
|||||||
|
|
||||||
- name: Run test suite
|
- name: Run test suite
|
||||||
run: composer run-script test
|
run: composer run-script test
|
||||||
|
|
||||||
|
sonarcloud:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Setup PHP
|
||||||
|
uses: shivammathur/setup-php@master
|
||||||
|
with:
|
||||||
|
php-version: 7.4
|
||||||
|
extension-csv: mbstring, xdebug
|
||||||
|
coverage: xdebug
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: composer install --prefer-dist --no-progress --no-suggest
|
||||||
|
|
||||||
|
- name: Run test suite
|
||||||
|
run: composer run-script test -- --coverage-clover=coverage.clover
|
||||||
|
|
||||||
|
- run: wget https://scrutinizer-ci.com/ocular.phar
|
||||||
|
- name: Upload code coverage
|
||||||
|
run: php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@ node_modules
|
|||||||
static
|
static
|
||||||
|
|
||||||
/vendor
|
/vendor
|
||||||
|
.phpunit.result.cache
|
||||||
|
|
||||||
/prettier.config.js
|
/prettier.config.js
|
||||||
/.eslintrc.js
|
/.eslintrc.js
|
||||||
|
28
.travis.yml
28
.travis.yml
@ -1,9 +1,7 @@
|
|||||||
language: php
|
language: php
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- '7.1'
|
- '7.4'
|
||||||
- '7.2'
|
|
||||||
- '7.3'
|
|
||||||
- nightly
|
- nightly
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
@ -11,27 +9,7 @@ matrix:
|
|||||||
- php: nightly
|
- php: nightly
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer install --dev --prefer-source
|
- composer install --prefer-dist --no-progress --no-suggest
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- vendor/bin/phpunit --coverage-clover=coverage.clover
|
- vendor/bin/phpunit
|
||||||
|
|
||||||
after_script:
|
|
||||||
- wget https://scrutinizer-ci.com/ocular.phar
|
|
||||||
- php ocular.phar code-coverage:upload --format=php-clover coverage.clover
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- stage: "Deploy Documentation"
|
|
||||||
php: "7.3"
|
|
||||||
script: skip
|
|
||||||
before_deploy:
|
|
||||||
- composer install
|
|
||||||
- bin/daux generate
|
|
||||||
deploy:
|
|
||||||
provider: pages
|
|
||||||
local_dir: static
|
|
||||||
skip_cleanup: true
|
|
||||||
github_token: $GITHUB_TOKEN # Set in travis-ci.org dashboard
|
|
||||||
on:
|
|
||||||
branch: master
|
|
||||||
|
@ -234,7 +234,7 @@ You can then point your browser to http://localhost:8086
|
|||||||
|
|
||||||
## PHP Requirements
|
## PHP Requirements
|
||||||
|
|
||||||
Daux.io is compatible with PHP 7.1.3 and up.
|
Daux.io is compatible with PHP 7.2.0 and up.
|
||||||
|
|
||||||
The reason is because some dependencies we have (mainly Symfony and Guzzle) do not support PHP 5.6 anymore.
|
The reason is because some dependencies we have (mainly Symfony and Guzzle) do not support PHP 5.6 anymore.
|
||||||
|
|
||||||
|
@ -17,18 +17,19 @@
|
|||||||
],
|
],
|
||||||
"bin": ["bin/daux"],
|
"bin": ["bin/daux"],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.1.3",
|
"php": ">=7.2",
|
||||||
"guzzlehttp/guzzle": "~6.0",
|
"guzzlehttp/guzzle": "~6.0",
|
||||||
"league/commonmark": "^0.18",
|
"league/commonmark": "^1.0.0",
|
||||||
|
"league/commonmark-ext-table": "^2.0.0",
|
||||||
"league/plates": "~3.1",
|
"league/plates": "~3.1",
|
||||||
"myclabs/deep-copy": "^1.5",
|
"myclabs/deep-copy": "^1.5",
|
||||||
"symfony/console": "^4.0",
|
"symfony/console": "^5.0",
|
||||||
"symfony/http-foundation": "^4.0",
|
"symfony/http-foundation": "^5.0",
|
||||||
"symfony/polyfill-intl-icu": "^1.10",
|
"symfony/polyfill-intl-icu": "^1.10",
|
||||||
"symfony/process": "^4.0",
|
"symfony/process": "^5.0",
|
||||||
"webuni/commonmark-table-extension": "0.9.*",
|
|
||||||
"webuni/front-matter": "^1.0.0",
|
"webuni/front-matter": "^1.0.0",
|
||||||
"scrivo/highlight.php": "^9.15"
|
"scrivo/highlight.php": "^9.15",
|
||||||
|
"symfony/mime": "^5.0"
|
||||||
},
|
},
|
||||||
"suggest":{
|
"suggest":{
|
||||||
"ext-intl": "Allows to translate the modified at date"
|
"ext-intl": "Allows to translate the modified at date"
|
||||||
@ -42,7 +43,7 @@
|
|||||||
"justinwalsh/daux.io": "*"
|
"justinwalsh/daux.io": "*"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~7.4",
|
"phpunit/phpunit": "^8.0",
|
||||||
"mikey179/vfsstream": "^1.6"
|
"mikey179/vfsstream": "^1.6"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
530
composer.lock
generated
530
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -145,7 +145,7 @@ Now that you got the basics, you can also [see what you can configure](05_Config
|
|||||||
|
|
||||||
## PHP Requirements
|
## PHP Requirements
|
||||||
|
|
||||||
Daux.io is compatible with PHP 7.1.3 and up.
|
Daux.io is compatible with PHP 7.2.0 and up.
|
||||||
|
|
||||||
The reason is because some dependencies we have (mainly Symfony and Guzzle) do not support PHP 5.6 anymore.
|
The reason is because some dependencies we have (mainly Symfony and Guzzle) do not support PHP 5.6 anymore.
|
||||||
|
|
||||||
|
@ -3,8 +3,9 @@
|
|||||||
use League\CommonMark\DocParser;
|
use League\CommonMark\DocParser;
|
||||||
use League\CommonMark\Environment;
|
use League\CommonMark\Environment;
|
||||||
use League\CommonMark\HtmlRenderer;
|
use League\CommonMark\HtmlRenderer;
|
||||||
|
use League\CommonMark\Ext\Table\TableExtension;
|
||||||
|
use League\CommonMark\Inline\Element as InlineElement;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
use Webuni\CommonMark\TableExtension\TableExtension;
|
|
||||||
|
|
||||||
class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
||||||
{
|
{
|
||||||
@ -39,6 +40,6 @@ class CommonMarkConverter extends \League\CommonMark\CommonMarkConverter
|
|||||||
|
|
||||||
protected function extendEnvironment(Environment $environment, Config $config)
|
protected function extendEnvironment(Environment $environment, Config $config)
|
||||||
{
|
{
|
||||||
$environment->addInlineRenderer('Link', $this->getLinkRenderer($environment));
|
$environment->addInlineRenderer(InlineElement\Link::class, $this->getLinkRenderer($environment));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,15 @@ use League\CommonMark\ElementRendererInterface;
|
|||||||
use League\CommonMark\HtmlElement;
|
use League\CommonMark\HtmlElement;
|
||||||
use League\CommonMark\Inline\Element\AbstractInline;
|
use League\CommonMark\Inline\Element\AbstractInline;
|
||||||
use League\CommonMark\Inline\Element\Link;
|
use League\CommonMark\Inline\Element\Link;
|
||||||
|
use League\CommonMark\Inline\Renderer\InlineRendererInterface;
|
||||||
|
use League\CommonMark\Util\ConfigurationAwareInterface;
|
||||||
|
use League\CommonMark\Util\ConfigurationInterface;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
use Todaymade\Daux\DauxHelper;
|
use Todaymade\Daux\DauxHelper;
|
||||||
use Todaymade\Daux\Exception\LinkNotFoundException;
|
use Todaymade\Daux\Exception\LinkNotFoundException;
|
||||||
use Todaymade\Daux\Tree\Entry;
|
use Todaymade\Daux\Tree\Entry;
|
||||||
|
|
||||||
class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
class LinkRenderer implements InlineRendererInterface, ConfigurationAwareInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var Config
|
* @var Config
|
||||||
@ -66,6 +69,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
|||||||
protected function isExternalUrl($url)
|
protected function isExternalUrl($url)
|
||||||
{
|
{
|
||||||
return preg_match('#^(?:[a-z]+:)?//|^mailto:#', $url);
|
return preg_match('#^(?:[a-z]+:)?//|^mailto:#', $url);
|
||||||
|
$this->parent = new \League\CommonMark\Inline\Renderer\LinkRenderer();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -87,7 +91,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$element = parent::render($inline, $htmlRenderer);
|
$element = $this->parent->render($inline, $htmlRenderer);
|
||||||
|
|
||||||
$url = $inline->getUrl();
|
$url = $inline->getUrl();
|
||||||
|
|
||||||
@ -116,7 +120,7 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
|||||||
$url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
|
$url = DauxHelper::getRelativePath($this->daux->getCurrentPage()->getUrl(), $file->getUrl());
|
||||||
} catch (LinkNotFoundException $e) {
|
} catch (LinkNotFoundException $e) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// For some reason, the filename could contain a # and thus the link needs to resolve to that.
|
// For some reason, the filename could contain a # and thus the link needs to resolve to that.
|
||||||
try {
|
try {
|
||||||
@ -148,4 +152,13 @@ class LinkRenderer extends \League\CommonMark\Inline\Renderer\LinkRenderer
|
|||||||
|
|
||||||
return $element;
|
return $element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ConfigurationInterface $configuration
|
||||||
|
*/
|
||||||
|
public function setConfiguration(ConfigurationInterface $configuration)
|
||||||
|
{
|
||||||
|
$this->config = $configuration;
|
||||||
|
$this->parent->setConfiguration($configuration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,17 +12,7 @@ class TableOfContents extends AbstractBlock
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function canContain(AbstractBlock $block)
|
public function canContain(AbstractBlock $block): bool
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if block type can accept lines of text
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
public function acceptsLines()
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -32,7 +22,7 @@ class TableOfContents extends AbstractBlock
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isCode()
|
public function isCode(): bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -42,7 +32,7 @@ class TableOfContents extends AbstractBlock
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function matchesNextLine(Cursor $cursor)
|
public function matchesNextLine(Cursor $cursor): bool
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
|
<?php namespace Todaymade\Daux\ContentTypes\Markdown;
|
||||||
|
|
||||||
use League\CommonMark\Block\Parser\AbstractBlockParser;
|
use League\CommonMark\Block\Parser\BlockParserInterface;
|
||||||
use League\CommonMark\ContextInterface;
|
use League\CommonMark\ContextInterface;
|
||||||
use League\CommonMark\Cursor;
|
use League\CommonMark\Cursor;
|
||||||
|
|
||||||
class TableOfContentsParser extends AbstractBlockParser
|
class TableOfContentsParser implements BlockParserInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param ContextInterface $context
|
* @param ContextInterface $context
|
||||||
@ -12,7 +12,7 @@ class TableOfContentsParser extends AbstractBlockParser
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function parse(ContextInterface $context, Cursor $cursor)
|
public function parse(ContextInterface $context, Cursor $cursor): bool
|
||||||
{
|
{
|
||||||
if ($cursor->isIndented()) {
|
if ($cursor->isIndented()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\Confluence\ContentTypes\Markdown;
|
<?php namespace Todaymade\Daux\Format\Confluence\ContentTypes\Markdown;
|
||||||
|
|
||||||
use League\CommonMark\Environment;
|
use League\CommonMark\Environment;
|
||||||
|
use League\CommonMark\Block\Element as BlockElement;
|
||||||
|
use League\CommonMark\Inline\Element as InlineElement;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
|
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
|
||||||
|
|
||||||
class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMarkConverter
|
class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMarkConverter
|
||||||
{
|
{
|
||||||
@ -14,12 +17,12 @@ class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMa
|
|||||||
{
|
{
|
||||||
parent::extendEnvironment($environment, $config);
|
parent::extendEnvironment($environment, $config);
|
||||||
|
|
||||||
$environment->addBlockRenderer('Todaymade\Daux\ContentTypes\Markdown\TableOfContents', new TOCRenderer());
|
$environment->addBlockRenderer(TableOfContents::class, new TOCRenderer());
|
||||||
|
|
||||||
//Add code renderer
|
//Add code renderer
|
||||||
$environment->addBlockRenderer('FencedCode', new FencedCodeRenderer());
|
$environment->addBlockRenderer(BlockElement\FencedCode::class, new FencedCodeRenderer());
|
||||||
$environment->addBlockRenderer('IndentedCode', new IndentedCodeRenderer());
|
$environment->addBlockRenderer(BlockElement\IndentedCode::class, new IndentedCodeRenderer());
|
||||||
|
|
||||||
$environment->addInlineRenderer('Image', new ImageRenderer());
|
$environment->addInlineRenderer(InlineElement\Image::class, new ImageRenderer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,20 @@ use League\CommonMark\ElementRendererInterface;
|
|||||||
use League\CommonMark\HtmlElement;
|
use League\CommonMark\HtmlElement;
|
||||||
use League\CommonMark\Inline\Element\AbstractInline;
|
use League\CommonMark\Inline\Element\AbstractInline;
|
||||||
use League\CommonMark\Inline\Element\Image;
|
use League\CommonMark\Inline\Element\Image;
|
||||||
|
use League\CommonMark\Util\ConfigurationAwareInterface;
|
||||||
|
use League\CommonMark\Util\ConfigurationInterface;
|
||||||
|
|
||||||
class ImageRenderer extends \League\CommonMark\Inline\Renderer\ImageRenderer
|
class ImageRenderer implements InlineRendererInterface, ConfigurationAwareInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var ConfigurationInterface
|
||||||
|
*/
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
public function __construct() {
|
||||||
|
$this->parent = new \League\CommonMark\Inline\Renderer\ImageRenderer();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Image $inline
|
* @param Image $inline
|
||||||
* @param ElementRendererInterface $htmlRenderer
|
* @param ElementRendererInterface $htmlRenderer
|
||||||
@ -30,4 +41,13 @@ class ImageRenderer extends \League\CommonMark\Inline\Renderer\ImageRenderer
|
|||||||
|
|
||||||
return parent::render($inline, $htmlRenderer);
|
return parent::render($inline, $htmlRenderer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ConfigurationInterface $configuration
|
||||||
|
*/
|
||||||
|
public function setConfiguration(ConfigurationInterface $configuration)
|
||||||
|
{
|
||||||
|
$this->config = $configuration;
|
||||||
|
$this->parent->setConfiguration($configuration);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<?php namespace Todaymade\Daux\Format\HTML\ContentTypes\Markdown;
|
<?php namespace Todaymade\Daux\Format\HTML\ContentTypes\Markdown;
|
||||||
|
|
||||||
use League\CommonMark\Environment;
|
use League\CommonMark\Environment;
|
||||||
|
use League\CommonMark\Block\Element as BlockElement;
|
||||||
|
use League\CommonMark\Event\DocumentParsedEvent;
|
||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
|
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
|
||||||
|
|
||||||
class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMarkConverter
|
class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMarkConverter
|
||||||
{
|
{
|
||||||
@ -9,9 +12,10 @@ class CommonMarkConverter extends \Todaymade\Daux\ContentTypes\Markdown\CommonMa
|
|||||||
{
|
{
|
||||||
parent::extendEnvironment($environment, $config);
|
parent::extendEnvironment($environment, $config);
|
||||||
|
|
||||||
$environment->addBlockRenderer('FencedCode', new FencedCodeRenderer());
|
$environment->addBlockRenderer(BlockElement\FencedCode::class, new FencedCodeRenderer());
|
||||||
|
|
||||||
$environment->addDocumentProcessor(new TOC\Processor($config));
|
$processor = new TOC\Processor($config);
|
||||||
$environment->addBlockRenderer('Todaymade\Daux\ContentTypes\Markdown\TableOfContents', new TOC\Renderer($config));
|
$environment->addEventListener(DocumentParsedEvent::class, [$processor, 'onDocumentParsed']);
|
||||||
|
$environment->addBlockRenderer(TableOfContents::class, new TOC\Renderer($config));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ use League\CommonMark\Block\Element\ListBlock;
|
|||||||
use League\CommonMark\Block\Element\ListData;
|
use League\CommonMark\Block\Element\ListData;
|
||||||
use League\CommonMark\Block\Element\ListItem;
|
use League\CommonMark\Block\Element\ListItem;
|
||||||
use League\CommonMark\Block\Element\Paragraph;
|
use League\CommonMark\Block\Element\Paragraph;
|
||||||
use League\CommonMark\DocumentProcessorInterface;
|
use League\CommonMark\Event\DocumentParsedEvent;
|
||||||
use League\CommonMark\Inline\Element\Link;
|
use League\CommonMark\Inline\Element\Link;
|
||||||
use League\CommonMark\Inline\Element\Text;
|
use League\CommonMark\Inline\Element\Text;
|
||||||
use League\CommonMark\Node\Node;
|
use League\CommonMark\Node\Node;
|
||||||
@ -15,7 +15,7 @@ use ReflectionMethod;
|
|||||||
use Todaymade\Daux\Config;
|
use Todaymade\Daux\Config;
|
||||||
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
|
use Todaymade\Daux\ContentTypes\Markdown\TableOfContents;
|
||||||
|
|
||||||
class Processor implements DocumentProcessorInterface
|
class Processor
|
||||||
{
|
{
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
@ -30,12 +30,13 @@ class Processor implements DocumentProcessorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Document $document
|
* @param DocumentParsedEvent $event
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function processDocument(Document $document)
|
public function onDocumentParsed(DocumentParsedEvent $event)
|
||||||
{
|
{
|
||||||
|
$document = $event->getDocument();
|
||||||
/** @var TableOfContents[] $tocs */
|
/** @var TableOfContents[] $tocs */
|
||||||
$tocs = [];
|
$tocs = [];
|
||||||
|
|
||||||
|
@ -1,29 +1,12 @@
|
|||||||
<?php namespace Todaymade\Daux\Server;
|
<?php namespace Todaymade\Daux\Server;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface as FileMimeTypeGuesserInterface;
|
|
||||||
use Symfony\Component\Mime\MimeTypeGuesserInterface;
|
use Symfony\Component\Mime\MimeTypeGuesserInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Guesses the mime type using the file's extension
|
* Guesses the mime type using the file's extension
|
||||||
*/
|
*/
|
||||||
class ExtensionMimeTypeGuesser implements FileMimeTypeGuesserInterface, MimeTypeGuesserInterface
|
class ExtensionMimeTypeGuesser implements MimeTypeGuesserInterface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function guess($path)
|
|
||||||
{
|
|
||||||
$extension = pathinfo($path,PATHINFO_EXTENSION);
|
|
||||||
|
|
||||||
if ($extension == "css") {
|
|
||||||
return "text/css";
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($extension == "js") {
|
|
||||||
return "application/javascript";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
@ -37,6 +20,14 @@ class ExtensionMimeTypeGuesser implements FileMimeTypeGuesserInterface, MimeType
|
|||||||
*/
|
*/
|
||||||
public function guessMimeType(string $path): ?string
|
public function guessMimeType(string $path): ?string
|
||||||
{
|
{
|
||||||
return $this->guess($path);
|
$extension = pathinfo($path,PATHINFO_EXTENSION);
|
||||||
|
|
||||||
|
if ($extension == "css") {
|
||||||
|
return "text/css";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($extension == "js") {
|
||||||
|
return "application/javascript";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,8 @@ class Server
|
|||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function createResponse(Page $page) {
|
public function createResponse(Page $page) {
|
||||||
|
// Add a custom MimeType guesser in case the default ones are not available
|
||||||
|
// This makes sure that at least CSS and JS work fine.
|
||||||
$mimeTypes = MimeTypes::getDefault();
|
$mimeTypes = MimeTypes::getDefault();
|
||||||
$mimeTypes->registerGuesser(new ExtensionMimeTypeGuesser());
|
$mimeTypes->registerGuesser(new ExtensionMimeTypeGuesser());
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class BuilderIntegrationTest extends TestCase
|
|||||||
*/
|
*/
|
||||||
private $root;
|
private $root;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp(): void
|
||||||
{
|
{
|
||||||
$structure = [
|
$structure = [
|
||||||
'Contents' => [
|
'Contents' => [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user