Browse Source

improve page title and cate title

master
filesite 3 years ago
parent
commit
ec9fee1706
  1. 13
      lib/DirScanner.php
  2. 3
      themes/googleimage/controller/ListController.php
  3. 3
      themes/googleimage/controller/SiteController.php
  4. 9
      themes/googleimage/views/site/index.php

13
lib/DirScanner.php

@ -87,11 +87,14 @@ Class DirScanner {
//snapshot相对路径完善,支持secure_link //snapshot相对路径完善,支持secure_link
private function parseDescriptionFiles($realpath) { private function parseDescriptionFiles($realpath) {
$pathinfo = pathinfo($realpath); $pathinfo = pathinfo($realpath);
$field = preg_replace('/^.+_/', '', $pathinfo['filename']); $tmp = explode('_', $pathinfo['filename']);
$content = file_get_contents($realpath); $field = array_pop($tmp);
$content = @file_get_contents($realpath);
if (empty($content)) {return [];}
$content = trim($content);
$data = []; $data = [];
if (in_array($field, ['title', 'snapshot'])) { if (in_array($field, ['title', 'snapshot'])) {
$content = preg_replace('/\s/', '', $content);
if ($field == 'snapshot') { if ($field == 'snapshot') {
$img_realpath = realpath("{$pathinfo['dirname']}/{$content}"); $img_realpath = realpath("{$pathinfo['dirname']}/{$content}");
if (file_exists($img_realpath)) { if (file_exists($img_realpath)) {
@ -112,8 +115,9 @@ Class DirScanner {
//解析快捷方式文件内容 //解析快捷方式文件内容
private function parseShortCuts($realpath, $filename) { private function parseShortCuts($realpath, $filename) {
$content = file_get_contents($realpath); $content = @file_get_contents($realpath);
if (empty($content) || !preg_match('/\[InternetShortcut\]/i', $content)) {return false;} if (empty($content) || !preg_match('/\[InternetShortcut\]/i', $content)) {return false;}
$content = trim($content);
preg_match('/URL=(\S+)/i', $content, $matches); preg_match('/URL=(\S+)/i', $content, $matches);
if (empty($matches) || empty($matches[1])) { if (empty($matches) || empty($matches[1])) {
@ -608,6 +612,7 @@ Class DirScanner {
$content = @file_get_contents($file['realpath']); $content = @file_get_contents($file['realpath']);
if (empty($content)) {return [];} if (empty($content)) {return [];}
$content = trim($content);
# standardize line breaks # standardize line breaks
$content = str_replace(array("\r\n", "\r"), "\n", $content); $content = str_replace(array("\r\n", "\r"), "\n", $content);

3
themes/googleimage/controller/ListController.php

@ -47,6 +47,9 @@ Class ListController extends Controller {
$pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; $pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统";
if (!empty($subcate)) { if (!empty($subcate)) {
$pageTitle = "{$subcate['directory']}的照片,来自{$pageTitle}"; $pageTitle = "{$subcate['directory']}的照片,来自{$pageTitle}";
if (!empty($subcate['title'])) {
$pageTitle = $subcate['title'];
}
} }
$viewName = '//site/index'; //共享视图 $viewName = '//site/index'; //共享视图
$params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme'); $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'breadcrumbs', 'htmlCateReadme');

3
themes/googleimage/controller/SiteController.php

@ -45,6 +45,9 @@ Class SiteController extends Controller {
$pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; $pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统";
if (!empty($subcate)) { if (!empty($subcate)) {
$pageTitle = "{$subcate['directory']}的照片,来自{$pageTitle}"; $pageTitle = "{$subcate['directory']}的照片,来自{$pageTitle}";
if (!empty($readmeFile['title'])) {
$pageTitle = $readmeFile['title'];
}
} }
$viewName = 'index'; $viewName = 'index';
$params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'htmlCateReadme'); $params = compact('cateId', 'dirTree', 'scanResults', 'menus', 'htmlReadme', 'htmlCateReadme');

9
themes/googleimage/views/site/index.php

@ -87,18 +87,21 @@ eof;
} }
} }
$title = !empty($dir['title']) ? $dir['title'] : $dir['directory'];
echo <<<eof echo <<<eof
<strong>{$dir['directory']}</strong> <strong>{$title}</strong>
</a> </a>
eof; eof;
} }
}else if (!empty($category['files'])) { //一级目录支持 }else if (!empty($category['files'])) { //一级目录支持
foreach($category['files'] as $file) { foreach($category['files'] as $file) {
if (!in_array($file['extension'], $imgExts)) {continue;} if (!in_array($file['extension'], $imgExts)) {continue;}
$title = !empty($file['title']) ? $file['title'] : $file['filename'];
echo <<<eof echo <<<eof
<a href="{$file['path']}" class="img-item img-preview" target="_blank"> <a href="{$file['path']}" class="img-item img-preview" target="_blank">
<img data-src="{$file['path']}" class="lazyload" alt="{$file['filename']}"> <img data-src="{$file['path']}" class="lazyload" alt="{$file['filename']}">
<strong>{$file['filename']}</strong> <strong>{$title}</strong>
</a> </a>
eof; eof;
} }
@ -109,7 +112,7 @@ eof;
<div class="modal-mask" id="modal_about"> <div class="modal-mask" id="modal_about">
<div class="modal-about"> <div class="modal-about">
<div class="modal-head"> <div class="modal-head">
<h3>关于GoogleImage</h3> <h3>联系我</h3>
<span class="btn-close" role="button"><svg width="24" height="24" viewBox="0 0 24 24" focusable="false" class=" NMm5M"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path></svg></span> <span class="btn-close" role="button"><svg width="24" height="24" viewBox="0 0 24 24" focusable="false" class=" NMm5M"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12 19 6.41z"></path></svg></span>
</div> </div>
<div class="hr"></div> <div class="hr"></div>

Loading…
Cancel
Save