diff --git a/conf/app.php b/conf/app.php index acc6288..a564fb6 100644 --- a/conf/app.php +++ b/conf/app.php @@ -10,7 +10,7 @@ return array( //'theme' => 'manual', //name of theme which is enabled //in developing - 'content_directory' => 'dogs_2/', //directory of contents in /www/ + 'content_directory' => 'dogs/', //directory of contents in /www/ 'theme' => 'googleimage', //name of theme which is enabled 'default_layout' => 'main', //default layout diff --git a/controller/Controller.php b/controller/Controller.php index 9abdf87..b7e635b 100644 --- a/controller/Controller.php +++ b/controller/Controller.php @@ -25,8 +25,20 @@ Class Controller { //render view protected function render($viewName, $viewData = array(), $pageTitle = '') { $layoutFile = __DIR__ . '/../views/layout/' . $this->layout . '.php'; + $viewFile = __DIR__ . '/../views/' . FSC::$app['controller'] . '/' . $viewName . '.php'; + //双斜杠//开头的共享视图支持 + if (preg_match('/^\/\//', $viewName)) { + $viewFile = __DIR__ . '/../views/' . str_replace('//', '/', $viewName) . '.php'; + } + if (!empty(FSC::$app['config']['theme'])) { $layoutFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/layout/' . $this->layout . '.php'; + $viewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . FSC::$app['controller'] . '/' . $viewName . '.php'; + //双斜杠//开头的共享视图支持 + if (preg_match('/^\/\//', $viewName)) { + $viewFile = __DIR__ . '/../themes/' . FSC::$app['config']['theme'] . '/views/' . + str_replace('//', '/', $viewName) . '.php'; + } } //include layout and view diff --git a/themes/googleimage/controller/ListController.php b/themes/googleimage/controller/ListController.php new file mode 100644 index 0000000..845f4b6 --- /dev/null +++ b/themes/googleimage/controller/ListController.php @@ -0,0 +1,42 @@ +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); + } + +} diff --git a/themes/googleimage/views/layout/main.php b/themes/googleimage/views/layout/main.php index b359605..ea628be 100644 --- a/themes/googleimage/views/layout/main.php +++ b/themes/googleimage/views/layout/main.php @@ -30,8 +30,9 @@