|
|
|
@ -8,7 +8,6 @@ require_once __DIR__ . '/../../../plugins/Parsedown.php';
@@ -8,7 +8,6 @@ require_once __DIR__ . '/../../../plugins/Parsedown.php';
|
|
|
|
|
Class ViewController extends Controller { |
|
|
|
|
|
|
|
|
|
public function actionIndex() { |
|
|
|
|
|
|
|
|
|
$fileId = $this->get('id', ''); |
|
|
|
|
if (!empty($fileId)) { |
|
|
|
|
$fileId = preg_replace('/\W/', '', $fileId); |
|
|
|
@ -18,6 +17,8 @@ Class ViewController extends Controller {
@@ -18,6 +17,8 @@ Class ViewController extends Controller {
|
|
|
|
|
$titles = array(); |
|
|
|
|
$content = ''; |
|
|
|
|
$html = ''; |
|
|
|
|
$author = ''; |
|
|
|
|
$publishTime = $updateTime = 0; |
|
|
|
|
|
|
|
|
|
$scanner = new DirScanner(); |
|
|
|
|
$scanner->setWebRoot(FSC::$app['config']['content_directory']); |
|
|
|
@ -32,13 +33,19 @@ Class ViewController extends Controller {
@@ -32,13 +33,19 @@ Class ViewController extends Controller {
|
|
|
|
|
$Parsedown = new Parsedown(); |
|
|
|
|
$html = $Parsedown->text($content); |
|
|
|
|
$html = $scanner->fixMDUrls($readmeFile['realpath'], $html); |
|
|
|
|
|
|
|
|
|
$publishTime = min($readmeFile['fstat']['ctime'], $readmeFile['fstat']['atime']); |
|
|
|
|
$updateTime = $readmeFile['fstat']['mtime']; |
|
|
|
|
if (!empty($readmeFile['author'])) { |
|
|
|
|
$author = $readmeFile['author']; |
|
|
|
|
} |
|
|
|
|
}else { |
|
|
|
|
throw new Exception("404 - 文件编号 {$fileId} 找不到", 404); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$pageTitle = !empty($titles) ? $titles[0]['name'] : "No title, 无标题"; |
|
|
|
|
$viewName = 'index'; |
|
|
|
|
$params = compact('titles', 'content', 'html'); |
|
|
|
|
$params = compact('titles', 'content', 'html', 'author', 'publishTime', 'updateTime'); |
|
|
|
|
return $this->render($viewName, $params, $pageTitle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|