$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())));
*/
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);
}
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);
}