Skip to content

Commit e083ea5

Browse files
committed
pre-release 0.1 第一个 ph-bookshelf 版本
- 根据 /data/bookshelf.xml 和 /data/abc/book.xml 和 /data/abc/main.md 生成书籍和目录的基础功能 - 支持外链/友链 - GitBook 前端修正 - 侧边栏可以正常折叠和展开 - 支持了书籍系列折叠和章节折叠 - 添加了书籍列表的折叠功能 - 同时,在非主书籍的时候自动折叠 - 在侧边栏底的生成程序声明里添加了版本声明
2 parents 4246f3d + d83fb71 commit e083ea5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+5571
-1
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text eol=lf

.htaccess

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# URL Rewrite
2+
RewriteEngine On
3+
RewriteCond $0 !^index.php.*
4+
RewriteCond $0 !^debug.php.*
5+
RewriteCond $0 !^assets.*
6+
RewriteRule .* index.php?p=$0 [QSA]

LICENSE

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
This is free and unencumbered software released into the public domain.
2+
3+
Anyone is free to copy, modify, publish, use, compile, sell, or
4+
distribute this software, either in source code form or as a compiled
5+
binary, for any purpose, commercial or non-commercial, and by any
6+
means.
7+
8+
In jurisdictions that recognize copyright laws, the author or authors
9+
of this software dedicate any and all copyright interest in the
10+
software to the public domain. We make this dedication for the benefit
11+
of the public at large and to the detriment of our heirs and
12+
successors. We intend this dedication to be an overt act of
13+
relinquishment in perpetuity of all present and future rights to this
14+
software under copyright law.
15+
16+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22+
OTHER DEALINGS IN THE SOFTWARE.
23+
24+
For more information, please refer to <https://unlicense.org>

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,37 @@
1-
# ph-Bookshelf
1+
# ph-Bookshelf
2+
3+
一个基于 Gitbook 的简单的多 book 实现。
4+
5+
因为 web 相关的东西 Sukazyo 最熟悉的就是 php 了所以就用 php 写的。
6+
但是写出来的代码还是十分离谱的不易读的:各种调用交错在一起,前后端也交错在一起
7+
8+
而且也并不好用,不好用到几乎没办法写教程...那种...至少现在如此。
9+
10+
有时间的话会补充的(en
11+
12+
<br/>
13+
14+
### 安装
15+
16+
下载/clone此仓库的内容,然后拖进 php 站点根目录。
17+
18+
**要求 php 环境安装了 php-xml 插件**
19+
(7.0及以下旧版本可能叫做 php-dom 插件)
20+
(安装方法应该是能 Google 到的)
21+
22+
对于 Apache(即 .htaccess 支持的 php 环境),可以直接运行。
23+
24+
对于 Nginx 或者别的之类的 php 环境,需要转换一下伪静态配置,以 .htaccess 文件内的内容为依据即可。
25+
26+
<br/>
27+
28+
### 使用
29+
30+
未来可能会拖出来一个示例之类的...
31+
32+
<br/>
33+
34+
### 开源许可
35+
36+
本软件的代码(因为写得真的不好所以)开源于公共领域,<br/>
37+
(但显然 Gitbook (/assets/gitbook/*) 中的内容还是受限于 Apache 2.0 的)

assets/gitbook-fix.css

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
2+
.fold > ul {
3+
max-height: 0;
4+
overflow: hidden;
5+
transition-duration: 0.5s;
6+
}
7+
8+
.fold.on > ul {
9+
max-height: unset;
10+
}
11+
12+
.book .book-summary ul.summary li a, .book .book-summary ul.summary li span {
13+
padding-left: 30px;
14+
cursor: pointer;
15+
}
16+
17+
.book .book-summary .exc-trigger {
18+
position: absolute;
19+
left: 12px;
20+
top: 12px;
21+
}
22+
23+
.book .book-summary .on > a .exc-trigger:before {
24+
content: "\f078";
25+
}
26+
27+
.book .book-summary .exc-trigger:before {
28+
content: "\f054";
29+
}
30+
31+
.book-summary ul.summary div.summary-container {
32+
padding: 0;
33+
max-height: 0;
34+
overflow: hidden;
35+
}
36+
37+
.book-summary ul.summary div.summary-container.on {
38+
padding: 7px 0;
39+
max-height: unset;
40+
}
41+
42+
.book-summary ul.summary li.divider.block-end {
43+
margin-top: 0;
44+
position: relative;
45+
overflow: unset;
46+
}
47+
48+
.book-summary ul.summary li.divider.block-start {
49+
margin-bottom: 0;
50+
}
51+
52+
.book-summary ul.summary li.divider.block-end .summary-container-icon {
53+
position: absolute;
54+
top: 1px;
55+
right: 20px;
56+
padding: 0 5px 2px;
57+
background: rgba(0,0,0,.07);
58+
color: white;
59+
border-bottom: 0;
60+
border-radius: 0 0 5px 5px;
61+
z-index: 1000;
62+
}
63+
64+
.book-summary ul.summary li.divider.block-end .summary-container-icon .fa:before {
65+
content: "\f078";
66+
}
67+
68+
.book-summary ul.summary div.summary-container.on + li.divider.block-end {
69+
transform: rotateX(180deg);
70+
}
71+
72+
.book .book-summary ul.summary li span.annotation {
73+
padding: 0;
74+
font-size: 0.2em;
75+
color: rgba(0, 0, 0, 0.2);
76+
}
77+
78+
.book .book-summary ul.summary li span.annotation:hover {
79+
text-decoration: none !important;
80+
}

assets/gitbook-fix.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const WITH_SUMMARY_CLASS = "with-summary"
2+
3+
let bookRoot;
4+
5+
function summaryOnOrOff () {
6+
7+
if (bookRoot.classList.contains(WITH_SUMMARY_CLASS)) {
8+
bookRoot.classList.remove(WITH_SUMMARY_CLASS);
9+
} else {
10+
bookRoot.classList.add(WITH_SUMMARY_CLASS);
11+
}
12+
13+
}
14+
15+
window.onload = function () {
16+
17+
bookRoot = document.getElementsByClassName("book")[0];
18+
19+
if (window.innerWidth > 600) {
20+
bookRoot.classList.add(WITH_SUMMARY_CLASS);
21+
}
22+
23+
};
24+
25+
for (let node of document.getElementsByClassName("fold")) {
26+
node.childNodes[0].addEventListener("click", function () {
27+
if (node.classList.contains("on")) {
28+
node.classList.remove("on");
29+
} else node.classList.add("on");
30+
});
31+
}
32+
33+
for (const node of document.getElementsByClassName("summary-container")) {
34+
35+
node.nextElementSibling.innerHTML = node.nextElementSibling.innerHTML + "<a class='summary-container-icon'><i class='fa'></i></a>";
36+
node.nextElementSibling.getElementsByClassName("summary-container-icon")[0].addEventListener("click", function () {
37+
if (node.classList.contains("on")) {
38+
node.classList.remove("on")
39+
} else {
40+
node.classList.add("on")
41+
}
42+
})
43+
44+
}
122 KB
Binary file not shown.
74.7 KB
Binary file not shown.

0 commit comments

Comments
 (0)