diff --git a/themes/manual/controller/SiteController.php b/themes/manual/controller/SiteController.php index ffe3b33..a76ddec 100644 --- a/themes/manual/controller/SiteController.php +++ b/themes/manual/controller/SiteController.php @@ -10,13 +10,15 @@ Class SiteController extends Controller { public function actionIndex() { //获取数据 + $titles = []; + $content = ''; + $html = ''; + $scanner = new DirScanner(); $scanner->setWebRoot('/content/'); $dirTree = $scanner->scan(__DIR__ . '/../../../www/content/', 4); $readmeFile = $scanner->getDefaultReadme(); - $titles = []; - $content = ''; - $html = ''; + if (!empty($readmeFile)) { $titles = $scanner->getMDTitles($readmeFile['id']); $content = file_get_contents($readmeFile['realpath']); @@ -26,15 +28,9 @@ Class SiteController extends Controller { $html = $scanner->fixMDUrls($readmeFile['realpath'], $html); } - //alert message test - //$this->sendMsgToClient('Alert message - danger', 'danger'); - //$this->sendMsgToClient('Alert message - warning', 'warning'); - //$this->sendMsgToClient('Alert message - success', 'success'); - //$this->sendMsgToClient('Alert message - info', 'info'); - $pageTitle = "FileSite.io - 无数据库、基于文件和目录的网址导航、图书、图片、视频网站PHP开源系统"; $viewName = 'index'; - $params = compact('dirTree', 'readmeFile', 'titles', 'content', 'html'); + $params = compact('titles', 'content', 'html'); return $this->render($viewName, $params, $pageTitle); } diff --git a/themes/manual/controller/ViewController.php b/themes/manual/controller/ViewController.php new file mode 100644 index 0000000..8bc41fd --- /dev/null +++ b/themes/manual/controller/ViewController.php @@ -0,0 +1,45 @@ +get('id', ''); + if (!empty($fileId)) { + $fileId = preg_replace('/\W/', '', $fileId); + } + + //获取数据 + $titles = []; + $content = ''; + $html = ''; + + $scanner = new DirScanner(); + $scanner->setWebRoot('/content/'); + $dirTree = $scanner->scan(__DIR__ . '/../../../www/content/', 4); + + $scanResults = $scanner->getScanResults(); + if (!empty($scanResults[$fileId])) { + $readmeFile = $scanResults[$fileId]; + $titles = $scanner->getMDTitles($readmeFile['id']); + $content = file_get_contents($readmeFile['realpath']); + + $Parsedown = new Parsedown(); + $html = $Parsedown->text($content); + $html = $scanner->fixMDUrls($readmeFile['realpath'], $html); + }else { + throw new Exception("404 - 文件编号 {$fileId} 找不到", 404); + } + + $pageTitle = !empty($titles) ? $titles[0]['name'] : "404 - 文件找不到"; + $viewName = 'index'; + $params = compact('titles', 'content', 'html'); + return $this->render($viewName, $params, $pageTitle); + } + +} diff --git a/themes/manual/views/view/index.php b/themes/manual/views/view/index.php new file mode 100644 index 0000000..c3280ee --- /dev/null +++ b/themes/manual/views/view/index.php @@ -0,0 +1,16 @@ +
+{$title['name']} +eof; + } +} +?> +
+ +
+ +
\ No newline at end of file diff --git a/www/css/manual.css b/www/css/manual.css index 7483703..e5d0cfc 100644 --- a/www/css/manual.css +++ b/www/css/manual.css @@ -1,15 +1,15 @@ /* for theme manual */ *,html,body{padding:0:;margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"} -.indexes{width:23%;position:fixed;padding-left:0.5em;padding-top:1em} +.indexes{width:23%;position:fixed;text-align:left;padding-left:0.5em;padding-top:1em} .content{margin-left:23.8%;padding:0.5em} .footer{margin:1em auto;text-align:center} .indexes h1,.indexes h2,.indexes h3,.indexes h4,.indexes h5,.indexes h6{font-size:1.2em;font-weight:normal;margin-bottom:0.35em} .indexes h1{display:none} -.indexes h2{margin-top:1em} +.indexes h2{margin-top:1em;} .indexes h3{text-indent:1em} .indexes a{background-color:transparent;color:#0969da;text-decoration: none} @media (max-width: 640px) { - .indexes{position:static;width:auto} - .indexes h1{display:block;padding-bottom:0.3em;text-align:center;font-size:2em;border-bottom:1px solid hsla(210,18%,87%,1)} + .indexes{position:static;width:auto;padding-bottom:0.5em;margin-bottom:0.5em;border-bottom:1px solid hsla(210,18%,87%,1)} + .indexes h1{display:block;padding-left:0;padding-bottom:0.3em;text-align:center;font-size:2em;border-bottom:1px solid hsla(210,18%,87%,1)} .content{margin-left:0;} } \ No newline at end of file