Browse Source

add author and publish, update time

master
filesite 4 weeks ago
parent
commit
7ca9a508e5
  1. 10
      themes/manual/controller/SiteController.php
  2. 11
      themes/manual/controller/ViewController.php
  3. 12
      themes/manual/views/site/index.php
  4. 12
      themes/manual/views/view/index.php
  5. 1
      www/content/README_author.txt
  6. 1
      www/css/manual.css

10
themes/manual/controller/SiteController.php

@ -12,6 +12,8 @@ Class SiteController extends Controller {
$titles = array(); $titles = array();
$content = ''; $content = '';
$html = ''; $html = '';
$author = '';
$publishTime = $updateTime = 0;
$scanner = new DirScanner(); $scanner = new DirScanner();
$scanner->setWebRoot(FSC::$app['config']['content_directory']); $scanner->setWebRoot(FSC::$app['config']['content_directory']);
@ -25,11 +27,17 @@ Class SiteController extends Controller {
$Parsedown = new Parsedown(); $Parsedown = new Parsedown();
$html = $Parsedown->text($content); $html = $Parsedown->text($content);
$html = $scanner->fixMDUrls($readmeFile['realpath'], $html); $html = $scanner->fixMDUrls($readmeFile['realpath'], $html);
$publishTime = min($readmeFile['fstat']['ctime'], $readmeFile['fstat']['atime']);
$updateTime = $readmeFile['fstat']['mtime'];
if (!empty($readmeFile['author'])) {
$author = $readmeFile['author'];
}
} }
$pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统"; $pageTitle = !empty($titles) ? $titles[0]['name'] : "FileSite.io - 无数据库、基于文件和目录的Markdown文档、网址导航、图书、图片、视频网站PHP开源系统";
$viewName = 'index'; $viewName = 'index';
$params = compact('titles', 'content', 'html'); $params = compact('titles', 'content', 'html', 'author', 'publishTime', 'updateTime');
return $this->render($viewName, $params, $pageTitle); return $this->render($viewName, $params, $pageTitle);
} }

11
themes/manual/controller/ViewController.php

@ -8,7 +8,6 @@ require_once __DIR__ . '/../../../plugins/Parsedown.php';
Class ViewController extends Controller { Class ViewController extends Controller {
public function actionIndex() { public function actionIndex() {
$fileId = $this->get('id', ''); $fileId = $this->get('id', '');
if (!empty($fileId)) { if (!empty($fileId)) {
$fileId = preg_replace('/\W/', '', $fileId); $fileId = preg_replace('/\W/', '', $fileId);
@ -18,6 +17,8 @@ Class ViewController extends Controller {
$titles = array(); $titles = array();
$content = ''; $content = '';
$html = ''; $html = '';
$author = '';
$publishTime = $updateTime = 0;
$scanner = new DirScanner(); $scanner = new DirScanner();
$scanner->setWebRoot(FSC::$app['config']['content_directory']); $scanner->setWebRoot(FSC::$app['config']['content_directory']);
@ -32,13 +33,19 @@ Class ViewController extends Controller {
$Parsedown = new Parsedown(); $Parsedown = new Parsedown();
$html = $Parsedown->text($content); $html = $Parsedown->text($content);
$html = $scanner->fixMDUrls($readmeFile['realpath'], $html); $html = $scanner->fixMDUrls($readmeFile['realpath'], $html);
$publishTime = min($readmeFile['fstat']['ctime'], $readmeFile['fstat']['atime']);
$updateTime = $readmeFile['fstat']['mtime'];
if (!empty($readmeFile['author'])) {
$author = $readmeFile['author'];
}
}else { }else {
throw new Exception("404 - 文件编号 {$fileId} 找不到", 404); throw new Exception("404 - 文件编号 {$fileId} 找不到", 404);
} }
$pageTitle = !empty($titles) ? $titles[0]['name'] : "No title, 无标题"; $pageTitle = !empty($titles) ? $titles[0]['name'] : "No title, 无标题";
$viewName = 'index'; $viewName = 'index';
$params = compact('titles', 'content', 'html'); $params = compact('titles', 'content', 'html', 'author', 'publishTime', 'updateTime');
return $this->render($viewName, $params, $pageTitle); return $this->render($viewName, $params, $pageTitle);
} }

12
themes/manual/views/site/index.php

@ -9,6 +9,18 @@ eof;
} }
} }
?> ?>
<div class="author">
<?php
if (!empty($viewData['author'])) {
echo <<<eof
作者:<small>{$viewData['author']}</small>
<br>
eof;
}
?>
发布:<small><?php echo date('Y-m-d H:i:s', $viewData['publishTime']); ?></small>
<br>修改:<small><?php echo date('Y-m-d H:i:s', $viewData['updateTime']); ?></small>
</div>
</div> </div>
<div class="content markdown-body"> <div class="content markdown-body">

12
themes/manual/views/view/index.php

@ -10,6 +10,18 @@ eof;
} }
} }
?> ?>
<div class="author">
<?php
if (!empty($viewData['author'])) {
echo <<<eof
作者:<small>{$viewData['author']}</small>
<br>
eof;
}
?>
发布:<small><?php echo date('Y-m-d H:i:s', $viewData['publishTime']); ?></small>
<br>修改:<small><?php echo date('Y-m-d H:i:s', $viewData['updateTime']); ?></small>
</div>
</div> </div>
<div class="content markdown-body"> <div class="content markdown-body">

1
www/content/README_author.txt

@ -0,0 +1 @@
FileSite.io

1
www/css/manual.css

@ -15,6 +15,7 @@
.indexes h5{font-size:0.9em} .indexes h5{font-size:0.9em}
.indexes h6{font-size:0.8em} .indexes h6{font-size:0.8em}
.indexes a{background-color:transparent;color:#0969da;text-decoration:none} .indexes a{background-color:transparent;color:#0969da;text-decoration:none}
.author{margin-top:1em;padding:.5em;border:1px solid #EEE}
@media (max-width: 640px) { @media (max-width: 640px) {
.header{position: static} .header{position: static}
.indexes{position:static;width:auto;padding-bottom:0.5em;margin-bottom:0.5em;margin-top: 0} .indexes{position:static;width:auto;padding-bottom:0.5em;margin-bottom:0.5em;margin-top: 0}

Loading…
Cancel
Save