filesite
3 years ago
5 changed files with 59 additions and 3 deletions
@ -0,0 +1,42 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* List Controller |
||||||
|
*/ |
||||||
|
require_once __DIR__ . '/../../../lib/DirScanner.php'; |
||||||
|
require_once __DIR__ . '/../../../plugins/Parsedown.php'; |
||||||
|
|
||||||
|
Class ListController extends Controller { |
||||||
|
|
||||||
|
public function actionIndex() { |
||||||
|
//获取数据 |
||||||
|
$scanner = new DirScanner(); |
||||||
|
$scanner->setWebRoot(FSC::$app['config']['content_directory']); |
||||||
|
$dirTree = $scanner->scan(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'], 4); |
||||||
|
$scanResults = $scanner->getScanResults(); |
||||||
|
|
||||||
|
//获取目录 |
||||||
|
$menus = $scanner->getMenus(); |
||||||
|
$cateId = $this->get('id', $menus[0]['id']); |
||||||
|
|
||||||
|
$titles = []; |
||||||
|
$html = ''; |
||||||
|
$readmeFile = $scanner->getDefaultReadme(); |
||||||
|
if (!empty($readmeFile)) { |
||||||
|
$titles = $scanner->getMDTitles($readmeFile['id']); |
||||||
|
|
||||||
|
$Parsedown = new Parsedown(); |
||||||
|
$content = file_get_contents($readmeFile['realpath']); |
||||||
|
$html = $Parsedown->text($content); |
||||||
|
$html = $scanner->fixMDUrls($readmeFile['realpath'], $html); |
||||||
|
} |
||||||
|
|
||||||
|
//TODO: 获取父目录,生成面包屑 |
||||||
|
|
||||||
|
|
||||||
|
$pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; |
||||||
|
$viewName = '//site/index'; //共享视图 |
||||||
|
$params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'html'); |
||||||
|
return $this->render($viewName, $params, $pageTitle); |
||||||
|
} |
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue