diff --git a/lib/DirScanner.php b/lib/DirScanner.php index 7a3d834..99b696b 100644 --- a/lib/DirScanner.php +++ b/lib/DirScanner.php @@ -46,6 +46,7 @@ Class DirScanner { 'webp', //图片 'gif', //图片 'ico', //图标 + 'mp3', //音乐 'mp4', //视频 'ts', //视频 'm3u8', //视频 @@ -60,17 +61,19 @@ Class DirScanner { 'webp' => 512000, //图片 'gif' => 512000, //图片 'ico' => 51200, //图标 - 'mp4' => 104857600, //视频 - 'ts' => 10485760, //视频 - 'm3u8' => 10485760, //视频 + 'mp3' => 10485760, //音乐,10M + 'mp4' => 104857600, //视频,100M + 'ts' => 10485760, //视频,10M + 'm3u8' => 10485760, //视频,10M ); protected $securedFileExtensions = array( //开启Nginx防盗链的文件类型 'jpg', //图片 - 'jpeg', //图片 + 'jpeg', //图片 'png', //图片 - 'webp', //图片 + 'webp', //图片 'gif', //图片 'ico', //图标 + 'mp3', //音乐 'mp4', //视频 'ts', //视频 'm3u8', //视频 @@ -368,6 +371,7 @@ Class DirScanner { 'webp' => "{$webRoot}{$directory}{$filename}.{$extension}", 'gif' => "{$webRoot}{$directory}{$filename}.{$extension}", 'ico' => "{$webRoot}{$directory}{$filename}.{$extension}", + 'mp3' => "{$webRoot}{$directory}{$filename}.{$extension}", 'mp4' => "{$webRoot}{$directory}{$filename}.{$extension}", 'ts' => "{$webRoot}{$directory}{$filename}.{$extension}", ); @@ -719,26 +723,31 @@ Class DirScanner { //获取指定目录下名称为README.md的文件 public function getDefaultReadme($dirid = '') { + return $this->getDefaultFile('md', $dirid); + } + + //根据扩展名在根目录下或者指定目录下获取一个文件 + public function getDefaultFile($extension, $dirid = '') { $readme = null; $md = null; if (empty($dirid) && !empty($this->tree)) { foreach($this->tree as $id => $file) { - if (!empty($file['extension']) && $file['extension'] == 'md') { + if (!empty($file['extension']) && $file['extension'] == $extension) { $md = $file; - if (strtoupper($file['filename']) == 'README') { + if ($extension == 'md' && strtoupper($file['filename']) == 'README') { $readme = $file; break; } } } - }else if (!empty($this->scanResults)) { + }else if (!empty($dirid) && !empty($this->scanResults)) { $directory = $this->scanResults[$dirid]; if (!empty($directory) && !empty($directory['files'])) { foreach($directory['files'] as $id => $file) { - if (!empty($file['extension']) && $file['extension'] == 'md') { + if (!empty($file['extension']) && $file['extension'] == $extension) { if (empty($md)) {$md = $file;} //取第一个md文件 - if (strtoupper($file['filename']) == 'README') { + if ($extension == 'md' && strtoupper($file['filename']) == 'README') { $readme = $file; break; } diff --git a/themes/googleimage/controller/ListController.php b/themes/googleimage/controller/ListController.php index 5e60b7d..c80f88a 100644 --- a/themes/googleimage/controller/ListController.php +++ b/themes/googleimage/controller/ListController.php @@ -58,6 +58,13 @@ Class ListController extends Controller { $htmlCateReadme = $scanner->fixMDUrls($cateReadmeFile['realpath'], $htmlCateReadme); } + //获取默认mp3文件 + $rootCateId = $this->get('id', ''); + $mp3File = $scanner->getDefaultFile('mp3', $rootCateId); + if (empty($mp3File)) { + $mp3File = $scanner->getDefaultFile('mp3'); + } + $pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; if (!empty($subcate)) { $pageTitle = "{$subcate['directory']}的照片,来自{$pageTitle}"; @@ -66,7 +73,10 @@ Class ListController extends Controller { } } $viewName = '//site/index'; //共享视图 - $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme'); + $params = compact( + 'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme', + 'mp3File' + ); return $this->render($viewName, $params, $pageTitle); } diff --git a/themes/googleimage/controller/SiteController.php b/themes/googleimage/controller/SiteController.php index 5069597..2e630ce 100644 --- a/themes/googleimage/controller/SiteController.php +++ b/themes/googleimage/controller/SiteController.php @@ -18,7 +18,6 @@ Class SiteController extends Controller { $scanner->setWebRoot(FSC::$app['config']['content_directory']); $dirTree = $scanner->scan(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'], 4); $scanResults = $scanner->getScanResults(); - //获取目录 $menus = $scanner->getMenus(); @@ -56,6 +55,13 @@ Class SiteController extends Controller { $htmlCateReadme = $scanner->fixMDUrls($cateReadmeFile['realpath'], $htmlCateReadme); } + //获取默认mp3文件 + $rootCateId = $this->get('id', ''); + $mp3File = $scanner->getDefaultFile('mp3', $rootCateId); + if (empty($mp3File)) { + $mp3File = $scanner->getDefaultFile('mp3'); + } + $pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; if (!empty($readmeFile['title'])) { $pageTitle = $readmeFile['title']; @@ -64,7 +70,10 @@ Class SiteController extends Controller { $pageTitle = "{$subcate['directory']}照片,来自{$pageTitle}"; } $viewName = 'index'; - $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'htmlCateReadme'); + $params = compact( + 'cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'htmlCateReadme', + 'mp3File' + ); return $this->render($viewName, $params, $pageTitle); } diff --git a/themes/googleimage/views/site/index.php b/themes/googleimage/views/site/index.php index ce4126d..7b102d3 100644 --- a/themes/googleimage/views/site/index.php +++ b/themes/googleimage/views/site/index.php @@ -2,13 +2,13 @@ $item) { - $selected = $item['id'] == $selectedId || (!empty($breadcrumbs) && $item['id'] == $breadcrumbs[0]['id']) ? 'selected' : ''; - echo <<{$item['directory']} +if (!empty($viewData['menus'])) { //只显示第一级目录 + foreach($viewData['menus'] as $index => $item) { + $selected = $item['id'] == $selectedId || (!empty($breadcrumbs) && $item['id'] == $breadcrumbs[0]['id']) ? 'selected' : ''; + echo <<{$item['directory']} eof; - } + } } ?> @@ -17,100 +17,153 @@ eof; - 当前位置: + echo << + 当前位置: eof; - foreach($breadcrumbs as $bread) { - if ($bread['id'] != $selectedId) { - echo <<{$bread['name']} / + foreach($breadcrumbs as $bread) { + if ($bread['id'] != $selectedId) { + echo <<{$bread['name']} / eof; - }else { - echo <<{$bread['name']} + }else { + echo <<{$bread['name']} eof; - } - } + } + } - echo << + echo << eof; } ?>
- {$category['description']}

+ //当前目录的描述介绍 + if (!empty($category['description'])) { + echo <<{$category['description']}

eof; - } + } - //当前目录的readme详细介绍 - if (!empty($viewData['htmlCateReadme'])) { - echo <<{$viewData['htmlCateReadme']}
+ //当前目录的readme详细介绍 + if (!empty($viewData['htmlCateReadme'])) { + echo <<{$viewData['htmlCateReadme']} eof; - } + } - if (!empty($category['directories'])) { //两级目录支持 - foreach($category['directories'] as $dir) { - echo << + if (!empty($category['directories'])) { //两级目录支持 + foreach($category['directories'] as $dir) { + echo << eof; - if (!empty($dir['snapshot'])) { - echo << + if (!empty($dir['snapshot'])) { + echo << eof; - }else if (!empty($dir['files'])) { - $first_img = array_shift($dir['files']); - if (!in_array($first_img['extension'], $imgExts)) { - foreach($dir['files'] as $file) { - if (in_array($file['extension'], $imgExts)) { - $first_img = $file; - break; - } - } - } + }else if (!empty($dir['files'])) { + $first_img = array_shift($dir['files']); + if (!in_array($first_img['extension'], $imgExts)) { + foreach($dir['files'] as $file) { + if (in_array($file['extension'], $imgExts)) { + $first_img = $file; + break; + } + } + } - if (in_array($first_img['extension'], $imgExts)) { - echo << + if (in_array($first_img['extension'], $imgExts)) { + echo << eof; }else { echo << eof; - } - } + } + } - $title = !empty($dir['title']) ? $dir['title'] : $dir['directory']; - echo <<{$title} - + $title = !empty($dir['title']) ? $dir['title'] : $dir['directory']; + echo <<{$title} + eof; - } - } + } + } - if (!empty($category['files'])) { //一级目录支持 - foreach($category['files'] as $file) { - if (!in_array($file['extension'], $imgExts)) {continue;} + if (!empty($category['files'])) { //一级目录支持 + foreach($category['files'] as $file) { + if (!in_array($file['extension'], $imgExts)) {continue;} - $title = !empty($file['title']) ? $file['title'] : $file['filename']; - echo << - {$file['filename']} - {$title} - + $title = !empty($file['title']) ? $file['title'] : $file['filename']; + echo << + {$file['filename']} + {$title} + eof; - } - } - ?> + } + } + ?> + + + + +
+
+ + + + +
+
+ + + + +
+ + \ No newline at end of file diff --git a/www/css/googleimage.css b/www/css/googleimage.css index ec3f680..aa0f7f5 100644 --- a/www/css/googleimage.css +++ b/www/css/googleimage.css @@ -26,6 +26,10 @@ a{color: #aaadb2;text-decoration: none} .img-item strong{display: block;color: #bdc1c6;font-family: Roboto,Arial,sans-serif;font-size: 12px;letter-spacing: .2px;line-height: 20px;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;} .catedesc{padding: 0 10px} .cateinfo{margin-bottom: 1em;padding: 5px 10px 10px 10px} +.hide{display:none} +.mbtns{position:fixed;width:30px;height:30px;z-index:100;right:15px;top:102px;border-radius:5px;cursor:pointer} +.mbtn{width:100%;height:100%;color:#FFF} +.mbtn svg{width:100%;height:100%} /* for mobile */ @media only screen and (max-width: 767px) {