Fix Mime Types - fix CLI param
This commit is contained in:
parent
9269b277e2
commit
e844b51f10
@ -14,6 +14,9 @@ class DauxCommand extends SymfonyCommand
|
|||||||
->addOption('value', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Set different configuration values')
|
->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('source', 's', InputOption::VALUE_REQUIRED, 'Where to take the documentation from')
|
||||||
->addOption('processor', 'p', InputOption::VALUE_REQUIRED, 'Manipulations on the tree');
|
->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)
|
private function setValue(&$array, $key, $value)
|
||||||
|
@ -24,8 +24,6 @@ class Generate extends DauxCommand
|
|||||||
// Confluence format only
|
// Confluence format only
|
||||||
->addOption('delete', null, InputOption::VALUE_NONE, 'Delete pages not linked to a documentation page (confluence)')
|
->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('destination', 'd', InputOption::VALUE_REQUIRED, $description, 'static')
|
||||||
->addOption('search', null, InputOption::VALUE_NONE, 'Generate full text search');
|
->addOption('search', null, InputOption::VALUE_NONE, 'Generate full text search');
|
||||||
}
|
}
|
||||||
|
25
libs/Server/ExtensionMimeTypeGuesser.php
Normal file
25
libs/Server/ExtensionMimeTypeGuesser.php
Normal file
@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,6 +4,7 @@ use Symfony\Component\Console\Output\NullOutput;
|
|||||||
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
use Symfony\Component\HttpFoundation\BinaryFileResponse;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
|
||||||
use Todaymade\Daux\Daux;
|
use Todaymade\Daux\Daux;
|
||||||
use Todaymade\Daux\DauxHelper;
|
use Todaymade\Daux\DauxHelper;
|
||||||
use Todaymade\Daux\Exception;
|
use Todaymade\Daux\Exception;
|
||||||
@ -93,6 +94,9 @@ class Server
|
|||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function createResponse(Page $page) {
|
public function createResponse(Page $page) {
|
||||||
|
|
||||||
|
MimeTypeGuesser::getInstance()->register(new ExtensionMimeTypeGuesser);
|
||||||
|
|
||||||
if ($page instanceof RawPage) {
|
if ($page instanceof RawPage) {
|
||||||
return new BinaryFileResponse($page->getFile());
|
return new BinaryFileResponse($page->getFile());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user