mirror of
https://github.com/suk-ws/ph-Bookshelf.git
synced 2024-12-05 09:26:52 +08:00
.tex 简单支持,测试性质的资源(图片)文件获取支持
This commit is contained in:
parent
c02929c7b1
commit
8dcd83c78d
@ -23,6 +23,7 @@
|
||||
"ext-mbstring": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"league/commonmark": ">=2.3.8",
|
||||
"gregwar/rst": "^1.0"
|
||||
"gregwar/rst": "^1.0",
|
||||
"xemlock/php-latex": "dev-master"
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
const APP_NAME = "ph-Bookshelf";
|
||||
|
||||
const VERSION = "0.3.2";
|
||||
const VERSION = "0.3.3";
|
||||
const CHANNEL = "suk-ws";
|
||||
const BRANCH = "master";
|
||||
|
18
index.php
18
index.php
@ -52,8 +52,22 @@ try {
|
||||
|
||||
// 页面寻找失败,寻找资源文件
|
||||
|
||||
if (!is_file($resLoc = "./data/%assets/$req")) { // 全局文件夹的资源文件
|
||||
throw $e;
|
||||
if ( // 搜索全局资源文件夹的指定文件
|
||||
file_exists($resLoc = "./data/%assets/$req")
|
||||
) {} else if ( // 搜索原始路径上的文件
|
||||
file_exists($resLoc = "./data/$req")
|
||||
) {} else if ( // 搜索可能存在的书籍资源文件夹中的指定文件
|
||||
sizeof($uri) > 1 && ($resBook = (SiteMeta::getBookshelf()->getBook($uri[0]))) != null &&
|
||||
file_exists($resLoc = "./data/{$resBook->getId()}/%assets/$uri[1]")
|
||||
) {} else if ( // 上面的 %root 兼容
|
||||
sizeof($uri) > 1 && ($resBook = $uri[0]) == "%root" &&
|
||||
file_exists($resLoc = "./data/$resBook/%assets/$uri[1]")
|
||||
) {} else if ( // 搜索以root书为根目录的原始路径上的文件
|
||||
file_exists($resLoc = "./data/%root/$req")
|
||||
) {} else if ( // 搜索root书中的书籍资源文件夹中的文件
|
||||
file_exists($resLoc = "./data/%root/%assets/$req")
|
||||
) {} else {
|
||||
throw $e; // 找不到资源文件
|
||||
}
|
||||
PageParse::outputBinaryFile($resLoc);
|
||||
|
||||
|
19
src/Utils/HTML/HTML.php
Normal file
19
src/Utils/HTML/HTML.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace SukWs\Bookshelf\Utils\HTML;
|
||||
|
||||
use SukWs\Bookshelf\Utils\PageContentType;
|
||||
|
||||
class HTML implements PageContentType {
|
||||
|
||||
public const type = array("html", "htm");
|
||||
|
||||
public function type (): array {
|
||||
return self::type;
|
||||
}
|
||||
|
||||
public function parse (string $raw): string {
|
||||
return $raw;
|
||||
}
|
||||
|
||||
}
|
24
src/Utils/LaTeX/LaTeX.php
Normal file
24
src/Utils/LaTeX/LaTeX.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace SukWs\Bookshelf\Utils\LaTeX;
|
||||
|
||||
use PhpLatex_Parser;
|
||||
use PhpLatex_Renderer_Html;
|
||||
use SukWs\Bookshelf\Utils\PageContentType;
|
||||
|
||||
class LaTeX implements PageContentType {
|
||||
|
||||
public const type = array("tex");
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function type (): array {
|
||||
return self::type;
|
||||
}
|
||||
|
||||
public function parse (string $raw): string {
|
||||
return (new PhpLatex_Renderer_Html())->render((new PhpLatex_Parser())->parse($raw));
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use SukWs\Bookshelf\Data\PageMeta;
|
||||
use SukWs\Bookshelf\Utils\HTML\HTML;
|
||||
use SukWs\Bookshelf\Utils\LaTeX\LaTeX;
|
||||
use SukWs\Bookshelf\Utils\Markdown\Markdown;
|
||||
use SukWs\Bookshelf\Utils\ReST\ReST;
|
||||
|
||||
@ -25,7 +27,9 @@ if (PageMeta::compatibilityOldTitlePolicy() && PageMeta::$page->hasContent(Markd
|
||||
}
|
||||
|
||||
$parsers = array(
|
||||
new HTML(),
|
||||
new Markdown(),
|
||||
new LaTeX(),
|
||||
new ReST()
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user