Skip to content

Commit

Permalink
pre-release 0.1 第一个 ph-bookshelf 版本
Browse files Browse the repository at this point in the history
- 根据 /data/bookshelf.xml 和 /data/abc/book.xml 和 /data/abc/main.md 生成书籍和目录的基础功能
- 支持外链/友链
- GitBook 前端修正
  - 侧边栏可以正常折叠和展开
  - 支持了书籍系列折叠和章节折叠
- 添加了书籍列表的折叠功能
  - 同时,在非主书籍的时候自动折叠
- 在侧边栏底的生成程序声明里添加了版本声明
  • Loading branch information
Eyre-S committed May 10, 2021
2 parents 4246f3d + d83fb71 commit e083ea5
Show file tree
Hide file tree
Showing 45 changed files with 5,571 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
6 changes: 6 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -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]
24 changes: 24 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org>
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
# ph-Bookshelf
# ph-Bookshelf

一个基于 Gitbook 的简单的多 book 实现。

因为 web 相关的东西 Sukazyo 最熟悉的就是 php 了所以就用 php 写的。
但是写出来的代码还是十分离谱的不易读的:各种调用交错在一起,前后端也交错在一起

而且也并不好用,不好用到几乎没办法写教程...那种...至少现在如此。

有时间的话会补充的(en

<br/>

### 安装

下载/clone此仓库的内容,然后拖进 php 站点根目录。

**要求 php 环境安装了 php-xml 插件**
(7.0及以下旧版本可能叫做 php-dom 插件)
(安装方法应该是能 Google 到的)

对于 Apache(即 .htaccess 支持的 php 环境),可以直接运行。

对于 Nginx 或者别的之类的 php 环境,需要转换一下伪静态配置,以 .htaccess 文件内的内容为依据即可。

<br/>

### 使用

未来可能会拖出来一个示例之类的...

<br/>

### 开源许可

本软件的代码(因为写得真的不好所以)开源于公共领域,<br/>
(但显然 Gitbook (/assets/gitbook/*) 中的内容还是受限于 Apache 2.0 的)
80 changes: 80 additions & 0 deletions assets/gitbook-fix.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

.fold > ul {
max-height: 0;
overflow: hidden;
transition-duration: 0.5s;
}

.fold.on > ul {
max-height: unset;
}

.book .book-summary ul.summary li a, .book .book-summary ul.summary li span {
padding-left: 30px;
cursor: pointer;
}

.book .book-summary .exc-trigger {
position: absolute;
left: 12px;
top: 12px;
}

.book .book-summary .on > a .exc-trigger:before {
content: "\f078";
}

.book .book-summary .exc-trigger:before {
content: "\f054";
}

.book-summary ul.summary div.summary-container {
padding: 0;
max-height: 0;
overflow: hidden;
}

.book-summary ul.summary div.summary-container.on {
padding: 7px 0;
max-height: unset;
}

.book-summary ul.summary li.divider.block-end {
margin-top: 0;
position: relative;
overflow: unset;
}

.book-summary ul.summary li.divider.block-start {
margin-bottom: 0;
}

.book-summary ul.summary li.divider.block-end .summary-container-icon {
position: absolute;
top: 1px;
right: 20px;
padding: 0 5px 2px;
background: rgba(0,0,0,.07);
color: white;
border-bottom: 0;
border-radius: 0 0 5px 5px;
z-index: 1000;
}

.book-summary ul.summary li.divider.block-end .summary-container-icon .fa:before {
content: "\f078";
}

.book-summary ul.summary div.summary-container.on + li.divider.block-end {
transform: rotateX(180deg);
}

.book .book-summary ul.summary li span.annotation {
padding: 0;
font-size: 0.2em;
color: rgba(0, 0, 0, 0.2);
}

.book .book-summary ul.summary li span.annotation:hover {
text-decoration: none !important;
}
44 changes: 44 additions & 0 deletions assets/gitbook-fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const WITH_SUMMARY_CLASS = "with-summary"

let 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);
}

};

for (let node of document.getElementsByClassName("fold")) {
node.childNodes[0].addEventListener("click", function () {
if (node.classList.contains("on")) {
node.classList.remove("on");
} else node.classList.add("on");
});
}

for (const node of document.getElementsByClassName("summary-container")) {

node.nextElementSibling.innerHTML = node.nextElementSibling.innerHTML + "<a class='summary-container-icon'><i class='fa'></i></a>";
node.nextElementSibling.getElementsByClassName("summary-container-icon")[0].addEventListener("click", function () {
if (node.classList.contains("on")) {
node.classList.remove("on")
} else {
node.classList.add("on")
}
})

}
Binary file added assets/gitbook/fonts/fontawesome/FontAwesome.otf
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit e083ea5

Please sign in to comment.