X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=mdref%2FAction.php;h=3e318be34d4d45af301d5da2309fa35adcea7d90;hb=c5efaeee1075614b4f8cc1ce373df1adcc4ee9fb;hp=dafc8e55f493346e5f324fd9592bba7b2c69ce1f;hpb=6478b415c59070f70ed860f3a592377eef9783b1;p=mdref%2Fmdref diff --git a/mdref/Action.php b/mdref/Action.php index dafc8e5..3e318be 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()))); @@ -135,12 +123,15 @@ class Action extends Observer { return; } + $cnn = null; if (($repo = $this->reference->getRepoForEntry($pld->ref, $cnn))) { - /* direct match */ - $pld->entry = $repo->getEntry($pld->ref); - } else if (strlen($cnn)) { - /* redirect */ - $this->serveCanonical($ctl, $cnn); + if (strlen($cnn)) { + /* redirect */ + $this->serveCanonical($ctl, $cnn); + } else { + /* direct match */ + $pld->entry = $repo->getEntry($pld->ref); + } } else { $this->servePreset($ctl, $pld); }