1
0
mirror of https://github.com/suk-ws/ph-Bookshelf.git synced 2025-01-18 23:12:23 +08:00

added site icon support, add css mixins

This commit is contained in:
A.C.Sukazyo Eyre 2024-01-15 20:26:56 +08:00
parent 730d7486a0
commit c565bfd240
Signed by: Eyre_S
GPG Key ID: C17CE40291207874
12 changed files with 103 additions and 26 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
# 忽略开发文件夹
.vs/
.vscode/
debug/
.idea/

View File

@ -0,0 +1,15 @@
/******************************************************************************
##############################################################################
##### #####
##### Markdown StyleSheet of ui design BreadCard #####
##### Mixins classes support #####
##### #####
##### @author: Sukazyo Workshop #####
##### @version: 1.0 #####
##### #####
##############################################################################
******************************************************************************/
.em-height {
height: 1em;
}

View File

@ -102,6 +102,7 @@ a {
}
a:hover {
text-decoration: none;
color: var(--bcm-color-font-base-link-hover);
}
@ -137,8 +138,10 @@ ul, ol, table,
pre {
margin-block-start: 1.6rem;
margin-block-end: 1.6rem;
line-height: 1.6;
/* for some capability */
border: none;
outline: none;
}
ul ul,

21
assets/ph-bookshelf.svg Normal file
View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="_圖層_1" data-name="圖層 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 405.73 514.65">
<defs>
<style>
.cls-1 {
fill: #91c6ff;
}
.cls-1, .cls-2 {
stroke-width: 0px;
}
.cls-2 {
fill: #e8f0fe;
}
</style>
</defs>
<rect class="cls-1" width="405.73" height="514.65" rx="55.41" ry="55.41"/>
<rect class="cls-2" x="53.03" y="118.03" width="60.47" height="265.36" rx="30.24" ry="30.24"/>
<rect class="cls-2" x="53.03" y="37.39" width="60.47" height="60.47" rx="30.24" ry="30.24"/>
</svg>

After

Width:  |  Height:  |  Size: 615 B

View File

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="https://book.sukazyo.cc/"
xmlns:phb="https://book.sukazyo.cc/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://book.sukazyo.cc"
xmlns="https://book.sukazyo.cc"
elementFormDefault="qualified"
>
<xs:include schemaLocation="https://book.sukazyo.cc/assets/xsd/configurations.xsd" />
<xs:include schemaLocation="./configurations.xsd" />
<xs:element name="Book">
<xs:complexType>
@ -14,9 +14,9 @@
<xs:element name="book_name" type="xs:string" />
<xs:element name="configurations" type="phb-config-level-book" minOccurs="0" />
<xs:element name="configurations" type="phb:phb-config-level-book" minOccurs="0" />
<xs:element name="contents" type="bookContents" />
<xs:element name="contents" type="phb:bookContents" />
</xs:sequence>
<xs:attribute name="version" type="xs:string" />
@ -25,9 +25,9 @@
<xs:complexType name="bookContents">
<xs:sequence>
<xs:element name="Page" type="bookPage" />
<xs:element name="Page" type="phb:bookPage" />
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:group ref="bookContent" />
<xs:group ref="phb:bookContent" />
<xs:element name="Separator" />
<xs:element name="Title" type="xs:string" />
</xs:choice>
@ -37,9 +37,9 @@
<xs:group name="bookContent">
<xs:choice>
<xs:element name="Chapter" type="bookChapter" />
<xs:element name="Chapter" type="phb:bookChapter" />
<xs:element name="Page" type="bookPage" />
<xs:element name="Page" type="phb:bookPage" />
</xs:choice>
</xs:group>
@ -49,7 +49,7 @@
<xs:element name="caption" type="xs:string" />
<xs:group ref="bookContent" maxOccurs="unbounded" />
<xs:group ref="phb:bookContent" maxOccurs="unbounded" />
</xs:sequence>
<xs:attribute name="root" type="xs:string" />

View File

@ -1,35 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="https://book.sukazyo.cc/"
xmlns:phb="https://book.sukazyo.cc/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://book.sukazyo.cc"
xmlns="https://book.sukazyo.cc"
elementFormDefault="qualified"
>
<xs:include schemaLocation="https://book.sukazyo.cc/assets/xsd/book.xsd" />
<xs:include schemaLocation="https://book.sukazyo.cc/assets/xsd/configurations.xsd" />
<xs:include schemaLocation="./book.xsd" />
<xs:include schemaLocation="./configurations.xsd" />
<xs:element name="BookShelf">
<xs:complexType>
<xs:sequence>
<xs:element name="site_name" type="xs:string" />
<xs:element name="site_icon" type="xs:string" minOccurs="0" />
<xs:element name="configurations" type="phb-config-level-site" />
<xs:element name="configurations" type="phb:phb-config-level-site" />
<xs:element name="links">
<xs:complexType>
<xs:group ref="linkElement" maxOccurs="unbounded"/>
<xs:group ref="phb:linkElement" maxOccurs="unbounded"/>
</xs:complexType>
</xs:element>
<xs:element name="books">
<xs:complexType>
<xs:group ref="bookElement" maxOccurs="unbounded" />
<xs:group ref="phb:bookElement" maxOccurs="unbounded" />
</xs:complexType>
</xs:element>
<xs:element name="root_book" type="bookContents" />
<xs:element name="root_book" type="phb:bookContents" />
</xs:sequence>
<xs:attribute name="version" type="xs:string" />
@ -53,7 +54,7 @@
<xs:complexType>
<xs:sequence>
<xs:element name="caption" type="xs:string" />
<xs:group ref="linkElement" maxOccurs="unbounded" />
<xs:group ref="phb:linkElement" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
@ -78,7 +79,7 @@
<xs:complexType>
<xs:sequence>
<xs:element name="caption" type="xs:string" />
<xs:group ref="bookElement" maxOccurs="unbounded" />
<xs:group ref="phb:bookElement" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
targetNamespace="https://book.sukazyo.cc/"
xmlns:phb="https://book.sukazyo.cc/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://book.sukazyo.cc"
xmlns="https://book.sukazyo.cc"
elementFormDefault="qualified"
>

View File

@ -2,6 +2,6 @@
const APP_NAME = "ph-Bookshelf";
const VERSION = "0.5.0-alpha12";
const VERSION = "0.5.0-alpha13";
const CHANNEL = "suk-ws";
const BRANCH = "config-v2.0";

View File

@ -38,6 +38,12 @@ try {
exit(SiteMeta::getConfigurationLevelShelf("site.robots"));
}
} else if (sizeof($uri) == 1 && $uri[0] == "favicon.ico") { // 为 favicon.ico 进行特别支持
$iconPath = SiteMeta::getGlobalIcon();
PageParse::output301($iconPath);
} else if (PageMeta::init($uri)) {
require "./template/header.php";

View File

@ -32,7 +32,9 @@ class SiteMeta {
}
public static function getGlobalIcon (): string {
return "/favicon.ico"; // TODO ICON
$icon = self::$BOOKSHELF->getSiteIcon();
if ($icon != null) return $icon;
else return "/assets/ph-bookshelf.svg";
}
public static function getStylesheetsList (): array {
@ -45,7 +47,8 @@ class SiteMeta {
null:"https://cdn.jsdelivr.net/gh/PrismJS/prism-themes@master/themes/".PageMeta::prismTheme().".min.css"),
(PageMeta::getConfigurationLevelPage(ConfigName::regex_highlight)=="false")?
null:"//cdn.jsdelivr.net/gh/suk-ws/regex-colorizer@master/regex-colorizer-default.min.css",
"/assets/bread-card-markdown.css?ver=3",
"/assets/bread-card-markdown.css?ver=4",
"/assets/bread-card-markdown-mixins.css?ver=1",
"/assets/bread-card-markdown-footnote.css?ver=1",
"/assets/bread-card-markdown-task-list.css?ver=1",
"/assets/bread-card-markdown-heading-permalink.css?ver=1",

View File

@ -13,6 +13,7 @@ class Bookshelf {
private string $configureVersion;
private string $siteName;
private ?string $siteIcon;
private LinkCollection $links;
private BookCollection $books;
@ -56,6 +57,9 @@ class Bookshelf {
case "site_name":
$return->siteName = self::parseSiteName($rc);
break;
case "site_icon":
$return->siteIcon = self::parseSiteIcon($rc);
break;
case "#comment":
break;
case "#text":
@ -118,10 +122,27 @@ class Bookshelf {
return $siteNameValue;
}
private static function parseSiteIcon (DOMNode $siteNameNode): string {
$siteNameValue = "";
for ($child = $siteNameNode->firstChild; $child != null; $child = $child->nextSibling) {
$siteNameValue .= match ($child->nodeName) {
"#text", "#cdata-section" => $child->nodeValue,
default => throw new Exception(
"Unsupported element type \"$child->nodeName\" in parsing configuration $siteNameNode->nodeName"
),
};
}
return $siteNameValue;
}
public function getSiteName (): string {
return $this->siteName;
}
public function getSiteIcon (): string {
return $this->siteIcon;
}
public function getLinks (): LinkCollection {
return $this->links;
}

View File

@ -57,6 +57,12 @@ class PageParse {
exit;
}
#[NoReturn]
public static function output301 (string $url): void {
header("Location: $url", true, 301);
exit;
}
/**
* 根据链接数组生成对应的链接/路径
*