From 31611969bf600dccf7428ccd6e857705562ed1cb Mon Sep 17 00:00:00 2001 From: Eyre_S Date: Sat, 20 May 2023 01:06:16 +0800 Subject: [PATCH] add Title for book contents --- assets/main.css | 16 +++++++++++++ assets/xsd/book.xsd | 1 + constant.php | 2 +- src/Data/SiteMeta.php | 3 +-- src/Element/BookContent/Chapter.php | 3 +++ src/Element/BookContent/Title.php | 37 +++++++++++++++++++++++++++++ 6 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 src/Element/BookContent/Title.php diff --git a/assets/main.css b/assets/main.css index 2584d34..df9718d 100644 --- a/assets/main.css +++ b/assets/main.css @@ -25,6 +25,7 @@ --color-sidebar-background: var(--bcm-color-table-background); --color-font-sidebar: var(--color-font-base); + --color-font-sidebar-title: #9e77e5; --color-scrollbar-sidebar-background: none; --color-scrollbar-sidebar-foreground: var(--color-menu-child-list-line); @@ -421,6 +422,21 @@ body { background: var(--color-menu-list-separator); } +#sidebar > .menu-container > .menu .menu-title { + display: block; + position: relative; + padding: 0.75rem 0 0; + margin: 0; + font-size: 0.8em; + color: var(--color-font-sidebar-title); +} + +#sidebar > .menu-container > .menu .menu-title:before { + content: "•"; + position: absolute; + left: -1em; +} + #sidebar > .menu-container > .menu .menu-item { display: block; padding: 0.55rem 0; diff --git a/assets/xsd/book.xsd b/assets/xsd/book.xsd index 3fbcda8..e3e122c 100644 --- a/assets/xsd/book.xsd +++ b/assets/xsd/book.xsd @@ -29,6 +29,7 @@ + diff --git a/constant.php b/constant.php index 970ad35..185137b 100644 --- a/constant.php +++ b/constant.php @@ -2,6 +2,6 @@ const APP_NAME = "ph-Bookshelf"; -const VERSION = "0.5.0-alpha8"; +const VERSION = "0.5.0-alpha9"; const CHANNEL = "suk-ws"; const BRANCH = "config-v2.0"; diff --git a/src/Data/SiteMeta.php b/src/Data/SiteMeta.php index 6bf0ed2..87c6620 100644 --- a/src/Data/SiteMeta.php +++ b/src/Data/SiteMeta.php @@ -6,7 +6,6 @@ use Exception; use SukWs\Bookshelf\Data\SiteConfig\ConfigName; use SukWs\Bookshelf\Data\SiteConfig\RobotsPolicy; use SukWs\Bookshelf\Element\Bookshelf; -use SukWs\Bookshelf\Resource\Assets; use SukWs\Bookshelf\Resource\Data; class SiteMeta { @@ -52,7 +51,7 @@ class SiteMeta { "/assets/bread-card-markdown-heading-permalink.css?ver=1", (PageMeta::getConfigurationLevelPage(ConfigName::ext_listing_rainbow)=="true"? "/assets/bread-card-markdown-enhanced-listing-rainbow.css?ver=2":null), - "/assets/main.css?ver=1", + "/assets/main.css?ver=2", ), self::getPrismPluginsCss(PageMeta::prismPlugins()) ); diff --git a/src/Element/BookContent/Chapter.php b/src/Element/BookContent/Chapter.php index 618da87..5930bb1 100644 --- a/src/Element/BookContent/Chapter.php +++ b/src/Element/BookContent/Chapter.php @@ -57,6 +57,9 @@ class Chapter { case "Separator": $node->children[] = Separator::parse($child, $node); break; + case "Title": + $node->children[] = Title::parse($child, $node); + break; case "#comment": break; case "#text": diff --git a/src/Element/BookContent/Title.php b/src/Element/BookContent/Title.php new file mode 100644 index 0000000..a8c1428 --- /dev/null +++ b/src/Element/BookContent/Title.php @@ -0,0 +1,37 @@ +parent = $parent; + $this->title = $title; + } + + /** + * @throws Exception + */ + public static function parse (DOMNode $xmlData, ?Chapter $parent): Title { + if ($xmlData->hasAttributes()) + throw new Exception("Title need be clean with no any attr/children"); + if ($parent->getParent() != null) + throw new Exception("Title must in root contents path"); + return new Title($parent, $xmlData->nodeValue); + } + + public function getParent (): Chapter { + return $this->parent; + } + + public function getSummaryHtml (): string { + return ""; + } + +} \ No newline at end of file