diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 2cd581604..10a534910 100755 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -266,8 +266,6 @@ class ActionController extends Zend_Controller_Action return call_user_func_array(array($this, $deprecatedMethod), $params); } - parent::__call($name, $params); - - return null; + return parent::__call($name, $params); } } diff --git a/modules/doc/application/controllers/IndexController.php b/modules/doc/application/controllers/IndexController.php index a83cbdec5..d18eff5db 100644 --- a/modules/doc/application/controllers/IndexController.php +++ b/modules/doc/application/controllers/IndexController.php @@ -3,13 +3,21 @@ // {{{ICINGA_LICENSE_HEADER}}} // {{{ICINGA_LICENSE_HEADER}}} +use Icinga\Application\Icinga; +use Icinga\Module\Doc\Parser as DocParser; use Icinga\Web\Controller\ActionController; class Doc_IndexController extends ActionController { + /** + * Display the application's documentation + */ public function indexAction() { - $this->_forward('index', 'view'); + $parser = new DocParser(); + list($html, $toc) = $parser->parseDirectory(Icinga::app()->getApplicationDir('/../doc')); + $this->view->html = $html; + $this->view->toc = $toc; } } // @codingStandardsIgnoreEnd diff --git a/modules/doc/application/controllers/ModuleController.php b/modules/doc/application/controllers/ModuleController.php new file mode 100644 index 000000000..f59467505 --- /dev/null +++ b/modules/doc/application/controllers/ModuleController.php @@ -0,0 +1,44 @@ +getModuleManager(); + $moduleName = substr($methodName, 0, -6); // Strip 'Action' suffix + if (!$moduleManager->hasEnabled($moduleName)) { + // TODO(el): Throw a not found exception once the code has been moved to the moduleAction (see TODO above) + return parent::__call($methodName, $args); + } + } +} +// @codingStandardsIgnoreEnd diff --git a/modules/doc/application/controllers/ViewController.php b/modules/doc/application/controllers/ViewController.php deleted file mode 100644 index b2174872d..000000000 --- a/modules/doc/application/controllers/ViewController.php +++ /dev/null @@ -1,52 +0,0 @@ -_helper->viewRenderer->setRender('view'); - } - - /** - * Populate view - * - * @param string $dir - */ - private function populateView($dir) - { - $parser = new DocParser(); - list($html, $toc) = $parser->parseDirectory($dir); - $this->view->html = $html; - $this->view->toc = $toc; - } - - public function indexAction() - { - $this->populateView(Icinga::app()->getApplicationDir('/../doc')); - } - - /** - * Provide run-time dispatching of module documentation - * - * @param string $methodName - * @param array $args - */ - public function __call($methodName, $args) - { - $moduleManager = Icinga::app()->getModuleManager(); - $moduleName = substr($methodName, 0, -6); // Strip 'Action' suffix - if ($moduleManager->hasEnabled($moduleName)) { - $this->populateView($moduleManager->getModuleDir($moduleName, '/doc')); - } else { - parent::__call($methodName, $args); - } - } -} -// @codingStandardsIgnoreEnd diff --git a/modules/doc/application/views/scripts/index/index.phtml b/modules/doc/application/views/scripts/index/index.phtml new file mode 100644 index 000000000..9be7c042a --- /dev/null +++ b/modules/doc/application/views/scripts/index/index.phtml @@ -0,0 +1,14 @@ +
+
+ +
+
+ +
+
diff --git a/modules/doc/application/views/scripts/view/view.phtml b/modules/doc/application/views/scripts/view/view.phtml deleted file mode 100644 index c9b7cb46b..000000000 --- a/modules/doc/application/views/scripts/view/view.phtml +++ /dev/null @@ -1,10 +0,0 @@ -
- -
- diff --git a/modules/doc/library/Doc/MarkdownFileIterator.php b/modules/doc/library/Doc/MarkdownFileIterator.php index cbf23ac35..e8d982ba6 100644 --- a/modules/doc/library/Doc/MarkdownFileIterator.php +++ b/modules/doc/library/Doc/MarkdownFileIterator.php @@ -6,6 +6,9 @@ namespace Icinga\Module\Doc; use \RecursiveFilterIterator; +/** + * Iterator over Markdown files recursively + */ class MarkdownFileIterator extends RecursiveFilterIterator { /** diff --git a/modules/doc/library/Doc/Parser.php b/modules/doc/library/Doc/Parser.php index c96934f7c..49f61229b 100644 --- a/modules/doc/library/Doc/Parser.php +++ b/modules/doc/library/Doc/Parser.php @@ -4,21 +4,20 @@ namespace Icinga\Module\Doc; -require_once 'vendor/Michelf/Markdown.php'; -require_once 'vendor/Michelf/MarkdownExtra.php'; +require_once 'vendor/Parsedown/Parsedown.php'; use \RecursiveIteratorIterator; use \RecursiveDirectoryIterator; use \Exception; -use Michelf\MarkdownExtra; +use \Parsedown; /** - * Markdown parser + * Parser for documentation written in Markdown */ class Parser { /** - * Retrieve table of contents and HTML converted from all markdown files in the given directory sorted by filename + * Retrieve table of contents and HTML converted from all Markdown files in the given directory sorted by filename * * @param $dir * @@ -87,7 +86,7 @@ class Parser } $fileObject->flock(LOCK_UN); } - $html = MarkdownExtra::defaultTransform(implode('', $cat)); + $html = Parsedown::instance()->parse(implode('', $cat)); return array($html, $toc); } }