mirror of
https://github.com/suk-ws/ph-Bookshelf.git
synced 2024-12-05 09:26:52 +08:00
完成前端页面模板,实现侧边栏的 Links 和 Books 生成
- 前端页面的大致样式完成 - 以 Gitbook 默认样式为基础 - 删除了插件内容 - 搜索栏被改为了站点标题 - 版权(?)声明将 Gitbook 声明为前端,添加 ph-Bookshelf 的声明 - 为 Gitbook 损坏的 js 功能做出补丁 - 侧边栏在 600px 以上高度下自动打开 - 侧边栏伸缩按钮功能 - *暂时还没有主题功能的实现 - 实现了侧边栏的 简单的 Links 和 Books 生成 - 只能够进行基础的列表显示
This commit is contained in:
parent
9d86fd5e53
commit
9bb1dd1a75
6
.htaccess
Normal file
6
.htaccess
Normal file
@ -0,0 +1,6 @@
|
||||
# URL Rewrite
|
||||
RewriteEngine On
|
||||
RewriteCond $0 !^index.php.*
|
||||
RewriteCond $0 !^debug.php.*
|
||||
RewriteCond $0 !^assets.*
|
||||
RewriteRule .* index.php?p=$0 [QSA]
|
23
assets/gitbook-fix.js
Normal file
23
assets/gitbook-fix.js
Normal file
@ -0,0 +1,23 @@
|
||||
const WITH_SUMMARY_CLASS = "with-summary"
|
||||
|
||||
var bookRoot;
|
||||
|
||||
function summaryOnOrOff () {
|
||||
|
||||
if (bookRoot.classList.contains(WITH_SUMMARY_CLASS)) {
|
||||
bookRoot.classList.remove(WITH_SUMMARY_CLASS);
|
||||
} else {
|
||||
bookRoot.classList.add(WITH_SUMMARY_CLASS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
window.onload = function () {
|
||||
|
||||
bookRoot = document.getElementsByClassName("book")[0];
|
||||
|
||||
if (window.innerWidth > 600) {
|
||||
bookRoot.classList.add(WITH_SUMMARY_CLASS);
|
||||
}
|
||||
|
||||
};
|
105
index.php
Normal file
105
index.php
Normal file
@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
require_once "./src/Data/SiteMeta.php";
|
||||
require_once "./src/Data/PageMeta.php";
|
||||
|
||||
try {
|
||||
|
||||
SiteMeta::load();
|
||||
PageMeta::$book = SiteMeta::getBookshelf()->getRootBook();
|
||||
PageMeta::$page = PageMeta::$book->getChilds()->getChilds()[0];
|
||||
PageMeta::$isMainPage = true;
|
||||
|
||||
require "./template/header.php";
|
||||
|
||||
?>
|
||||
|
||||
<div class="book-summary">
|
||||
<div id="book-search-input">
|
||||
<ul id="site-name" class="summary">
|
||||
<li class="chapter active"><a><?= SiteMeta::getBookshelf()->getSiteName() ?></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<nav role="navigation">
|
||||
<ul class="summary">
|
||||
<?= SiteMeta::getBookshelf()->getHtml(); ?>
|
||||
<li class="divider"></li>
|
||||
<li class="chapter active" data-level="1.1" data-path="./"><a href="./">占位主页面</a></li>
|
||||
<li class="chapter " data-level="1.2" data-path="api/">
|
||||
<a href="#">占位章节</a>
|
||||
<ul class="articles">
|
||||
<li class="chapter " data-level="1.2.1" data-path="api/color.html"><a href="chp/page.html">占位页面</a></li>
|
||||
<li class="chapter " data-level="1.2.2" data-path="api/suka-talk.html"><a href="chp/page-other.html">另一个占位页面</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="chapter " data-level="1.3" data-path="srv-dev.html"><a href="backnote.html">占位后记</a></li>
|
||||
<li class="divider"></li>
|
||||
<li><a href="https://github.com/Eyre-S/ph-Bookshelf" target="blank" class="gitbook-link">Generated with ph-Bookshelf</a></li>
|
||||
<li><a href="https://www.gitbook.com" target="blank" class="gitbook-link">Front-End by GitBook</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
<div class="book-body">
|
||||
<div class="body-inner">
|
||||
<div class="book-header" role="navigation">
|
||||
<!-- Title -->
|
||||
<a class="btn pull-left js-toolbar-action" aria-label="" href="#" onclick="summaryOnOrOff()"><i class="fa fa-align-justify"></i></a>
|
||||
<div class="dropdown pull-left font-settings js-toolbar-action">
|
||||
<a class="btn toggle-dropdown" aria-label="Font Settings" href="#"><i class="fa fa-font"></i></a>
|
||||
<div class="dropdown-menu dropdown-right">
|
||||
<div class="dropdown-caret">
|
||||
<span class="caret-outer"></span>
|
||||
<span class="caret-inner"></span>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button class="button size-2 font-reduce">A</button>
|
||||
<button class="button size-2 font-enlarge">A</button>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<button class="button size-2 ">Serif</button>
|
||||
<button class="button size-2 ">Sans</button>
|
||||
</div><div class="buttons">
|
||||
<button class="button size-3 ">White</button>
|
||||
<button class="button size-3 ">Sepia</button>
|
||||
<button class="button size-3 ">Night</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h1>
|
||||
<i class="fa fa-circle-o-notch fa-spin"></i>
|
||||
<a href=".">Workshop Services</a>
|
||||
</h1>
|
||||
</div>
|
||||
<div class="page-wrapper" tabindex="-1" role="main">
|
||||
<div class="page-inner">
|
||||
<div id="book-search-results">
|
||||
<div class="search-noresults">
|
||||
<section class="normal markdown-section">
|
||||
<h1 id="workshop-services"><a name="workshop-services"
|
||||
class="anchor-navigation-ex-anchor" href="#workshop-services"><i
|
||||
class="fa fa-link" aria-hidden="true"></i></a>1. 占位主页面
|
||||
</h1>
|
||||
<p>歌德说过一句富有哲理的话,没有人事先了解自己到底有多大的力量,直到他试过以后才知道。这句话语虽然很短,但令我浮想联翩。 在这种困难的抉择下,本人思来想去,寝食难安。 经过上述讨论, 佚名说过一句富有哲理的话,感激每一个新的挑战,因为它会锻造你的意志和品格。这启发了我。</p>
|
||||
<p>我们都知道,只要有意义,那么就必须慎重考虑。 一般来讲,我们都必须务必慎重的考虑考虑。 本人也是经过了深思熟虑,在每个日日夜夜思考这个问题。 问题的关键究竟为何? 带着这些问题,我们来审视一下占位内容。 就我个人来说,占位内容对我的意义,不能不说非常重大。</p>
|
||||
<p>鲁巴金曾经说过,读书是在别人思想的帮助下,建立起自己的思想。我希望诸位也能好好地体会这句话。</p>
|
||||
<font color="dark-yellow">既然如此, 占位内容因何而发生? 经过上述讨论, 占位内容,发生了会如何,不发生又会如何。
|
||||
`喵~`
|
||||
我们一般认为,抓住了问题的关键,其他一切则会迎刃而解。
|
||||
</font>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
require "./template/footer.php";
|
||||
|
||||
} catch (Exception $e) {
|
||||
|
||||
echo "<h1>ERROR</h1><p>" . $e->getMessage() . "</p>";
|
||||
|
||||
}
|
@ -24,25 +24,13 @@ class SiteMeta {
|
||||
public static function getGitbookStylesheetsList (): array {
|
||||
return array(
|
||||
"/assets/gitbook/style.css",
|
||||
"/assets/gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css",
|
||||
"/assets/gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css",
|
||||
"/assets/gitbook/gitbook-plugin-highlight/website.css",
|
||||
"/assets/gitbook/gitbook-plugin-search/search.css",
|
||||
"/assets/gitbook/gitbook-plugin-fontsettings/website.css"
|
||||
);
|
||||
}
|
||||
|
||||
public static function getGitbookJavascriptList (): array {
|
||||
return array(
|
||||
"/assets/gitbook/gitbook.js",
|
||||
"/assets/gitbook/theme.js",
|
||||
"/assets/gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js",
|
||||
"/assets/gitbook/gitbook-plugin-search/search-engine.js",
|
||||
"/assets/gitbook/gitbook-plugin-search/search.js",
|
||||
"/assets/gitbook/gitbook-plugin-lunr/lunr.min.js",
|
||||
"/assets/gitbook/gitbook-plugin-lunr/search-lunr.js",
|
||||
"/assets/gitbook/gitbook-plugin-sharing/buttons.js",
|
||||
"/assets/gitbook/gitbook-plugin-fontsettings/fontsettings.js"
|
||||
"/assets/gitbook-fix.js",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -52,4 +52,8 @@ class Book {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getHtml (): string {
|
||||
return "<li class='link'><a class='link' href='$this->id'>$this->name</a></li>";
|
||||
}
|
||||
|
||||
}
|
@ -12,9 +12,9 @@ class BookCollection {
|
||||
private array $array;
|
||||
private ?BookCollection $parent;
|
||||
|
||||
private function __construct (string $name, array $a, ?BookCollection $parent) {
|
||||
private function __construct (string $name, ?BookCollection $parent) {
|
||||
$this->name = $name;
|
||||
$this->array = $a;
|
||||
$this->array = array();
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ class BookCollection {
|
||||
else $name = $attrName->nodeValue;
|
||||
} else throw new Exception("BookCollection (not root) xml data missing attributes");
|
||||
}
|
||||
$node = new BookCollection($name, array(), $parent);
|
||||
$node = new BookCollection($name, $parent);
|
||||
for ($child = $root->firstChild; $child != null; $child = $child->nextSibling) {
|
||||
switch ($child->nodeName) {
|
||||
case "Book":
|
||||
@ -70,4 +70,14 @@ class BookCollection {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getHtml (): string {
|
||||
$str = "";
|
||||
if ($this->name != self::ROOT) $str .= "<li><a class='book-collection' href='#'>$this->name</a><ul class='book-collection'>";
|
||||
foreach ($this->array as $node) {
|
||||
$str .= $node->getHtml();
|
||||
}
|
||||
if ($this->name != self::ROOT) $str .= "</ul></li>";
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -70,4 +70,14 @@ class Bookshelf {
|
||||
return $this->rootBook;
|
||||
}
|
||||
|
||||
public function getHtml (): string {
|
||||
$str = "<ul id='global-container' class='summary'>";
|
||||
$str .= $this->links->getHtml();
|
||||
$str .= "<li class='divider'></li>";
|
||||
$str .= $this->books->getHtml();
|
||||
$str .= "</ul>";
|
||||
// TODO books list
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,4 +52,8 @@ class Link {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getHtml (): string {
|
||||
return "<li class='link'><a class='link' href='$this->href' target='_blank'>$this->name</a></li>";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ class LinkCollection {
|
||||
private array $array;
|
||||
private ?LinkCollection $parent;
|
||||
|
||||
private function __construct (string $name, array $a, ?LinkCollection $parent) {
|
||||
private function __construct (string $name, ?LinkCollection $parent) {
|
||||
$this->name = $name;
|
||||
$this->array = $a;
|
||||
$this->array = array();
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
@ -34,7 +34,7 @@ class LinkCollection {
|
||||
else $name = $attrName->nodeValue;
|
||||
} else throw new Exception("LinkCollection (not root) xml data missing attributes");
|
||||
}
|
||||
$node = new LinkCollection($name, array(), $parent);
|
||||
$node = new LinkCollection($name, $parent);
|
||||
for ($child = $root->firstChild; $child != null; $child = $child->nextSibling) {
|
||||
switch ($child->nodeName) {
|
||||
case "Link":
|
||||
@ -70,4 +70,14 @@ class LinkCollection {
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function getHtml (): string {
|
||||
$str = "";
|
||||
if ($this->name != self::ROOT) $str .= "<li><a class='link-collection chapter' href='#'>$this->name</a><ul class='link-collection articles'>";
|
||||
foreach ($this->array as $node) {
|
||||
$str .= $node->getHtml();
|
||||
}
|
||||
if ($this->name != self::ROOT) $str .= "</ul></li>";
|
||||
return $str;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user