Fix Mime Types - fix CLI param

This commit is contained in:
Stéphane Goetz 2017-12-08 16:29:44 +01:00
bovenliggende 9269b277e2
commit e844b51f10
4 gewijzigde bestanden met toevoegingen van 32 en 2 verwijderingen

Bestand weergeven

@ -14,6 +14,9 @@ class DauxCommand extends SymfonyCommand
->addOption('value', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Set different configuration values')
->addOption('source', 's', InputOption::VALUE_REQUIRED, 'Where to take the documentation from')
->addOption('processor', 'p', InputOption::VALUE_REQUIRED, 'Manipulations on the tree');
// HTML Format only
$this->addOption('themes', 't', InputOption::VALUE_REQUIRED, 'Set a different themes directory');
}
private function setValue(&$array, $key, $value)

Bestand weergeven

@ -24,8 +24,6 @@ class Generate extends DauxCommand
// Confluence format only
->addOption('delete', null, InputOption::VALUE_NONE, 'Delete pages not linked to a documentation page (confluence)')
// HTML Format only
->addOption('themes', 't', InputOption::VALUE_REQUIRED, 'Set a different themes directory')
->addOption('destination', 'd', InputOption::VALUE_REQUIRED, $description, 'static')
->addOption('search', null, InputOption::VALUE_NONE, 'Generate full text search');
}

Bestand weergeven

@ -0,0 +1,25 @@
<?php namespace Todaymade\Daux\Server;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesserInterface;
/**
* Guesses the mime type using the file's extension
*/
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";
}
}
}

Bestand weergeven

@ -4,6 +4,7 @@ use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Todaymade\Daux\Daux;
use Todaymade\Daux\DauxHelper;
use Todaymade\Daux\Exception;
@ -93,6 +94,9 @@ class Server
* @return Response
*/
public function createResponse(Page $page) {
MimeTypeGuesser::getInstance()->register(new ExtensionMimeTypeGuesser);
if ($page instanceof RawPage) {
return new BinaryFileResponse($page->getFile());
}