X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=mdref%2FAction.php;h=37b3d51321ebab4400b8400420b621f91e07d5ec;hb=31c2b666caffa28ea1576ed9c2f4c2280f2a2d45;hp=dcd8fcbed025d24f4725c9b9c0976a2c19d8e2ba;hpb=3d804b7c153990d081d5acfaee7e594873666f13;p=mdref%2Fmdref diff --git a/mdref/Action.php b/mdref/Action.php index dcd8fcb..37b3d51 100644 --- a/mdref/Action.php +++ b/mdref/Action.php @@ -36,20 +36,8 @@ class Action extends Observer { $pld = new \stdClass; try { - $pld->quick = function($string) { - $md = \MarkdownDocument::createFromString($string); - $md->compile(\MarkdownDocument::AUTOLINK); - return $md->getHtml(); - }; - - $pld->file = function($file) { - $fd = fopen($file, "r"); - $md = \MarkdownDocument::createFromStream($fd); - $md->compile(\MarkdownDocument::AUTOLINK | \MarkdownDocument::TOC); - $html = $md->getHtml(); - fclose($fd); - return $html; - }; + $pld->quick = [$this->reference, "formatString"]; + $pld->file = [$this->reference, "formatFile"]; $pld->ref = implode("/", $this->baseUrl->params( $this->baseUrl->mod($ctl->getRequest()->getRequestUrl()))); @@ -71,7 +59,7 @@ class Action extends Observer { */ private function serveCanonical($ctl, $cnn) { $ctl->detachAll(Observer\View::class); - $ctl->getResponse()->setHeader("Location", $this->baseUrl->mod($cnn)); + $ctl->getResponse()->setHeader("Location", $this->baseUrl->mod(["path" => $cnn])); $ctl->getResponse()->setResponseCode(301); }