拆分主题

This commit is contained in:
cxykevin 2024-08-31 09:48:04 +08:00
commit 88620df768
22 changed files with 2196 additions and 0 deletions

6
.lintmdrc Executable file
View File

@ -0,0 +1,6 @@
{
"rules":{
"no-empty-code": 1,
"no-long-code": 0
}
}

201
LICENSE-APACHE Executable file
View File

@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2010 The Rust Project Developers
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

4
LICENSE-MIT Executable file
View File

@ -0,0 +1,4 @@
Copyright (C) 2024 Study Area Team
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
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 OR COPYRIGHT HOLDERS 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.

37
README.md Executable file
View File

@ -0,0 +1,37 @@
# Study Area CN
### URL : [learn.study-area.org.cn](https://learn.study-area.org.cn)
## 概述
StudyAreaCN 主题部分
撰写文档时请使用submodule引用本仓库到theme文件夹
并在book.toml中包含
```toml
[output.html]
additional-css = [
"theme/css/icons.css",
"theme/css/mdui.css",
"theme/css/highlight.min.css",
"theme/css/page.css",
"theme/css/font.css",
"theme/font/icons.woff2",
"theme/font/noto.otf",
"theme/font/sourcecodepro.woff2",
]
additional-js = [
"theme/js/mdui.global.js",
"theme/js/highlight.min.js",
"theme/js/mathjax.js",
"theme/js/tocrender.js",
"theme/js/page.js",
]
```
采用mdbook开发编译请预先安装Rust环境。
## 如何帮助开发?
如果您想要协助我们的开发,请参阅[百科](https://git.hmtsai.cn/study-area-cn/study-area-cn/wiki)

21
css/font.css Normal file
View File

@ -0,0 +1,21 @@
@font-face {
font-family: 'Noto Sans';
font-style: normal;
font-weight: 300;
src: local("NotoSansCJK-Medium") url('../font/noto.otf') format('otf');
}
@font-face {
font-family: 'Source Code Pro';
font-style: normal;
font-weight: 300;
src: local("SourceCodePro") url('../font/sourcecodepro.woff2') format('woff2');
}
body {
font-family: 'Noto Sans', sans-serif !important;
}
code {
font-family: 'Source Code Pro', 'Courier New', monospace !important;
}

9
css/highlight.min.css vendored Normal file
View File

@ -0,0 +1,9 @@
/*!
Theme: Default
Description: Original highlight.js style
Author: (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
Maintainer: @highlightjs/core-team
Website: https://highlightjs.org/
License: see project LICENSE
Touched: 2021
*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}

22
css/icons.css Normal file
View File

@ -0,0 +1,22 @@
/* fallback */
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(../font/icons.woff2) format('woff2');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px;
line-height: 1;
letter-spacing: normal;
text-transform: none;
display: inline-block;
white-space: nowrap;
word-wrap: normal;
direction: ltr;
-webkit-font-smoothing: antialiased;
}

1
css/mdui.css Normal file

File diff suppressed because one or more lines are too long

125
css/page.css Normal file
View File

@ -0,0 +1,125 @@
ol,
li {
list-style: none;
font-size: 1em;
}
.part-title {
font-weight: bold;
font-size: 1.2em;
}
a {
position: relative;
text-decoration: none;
color: rgb(var(--mdui-color-primary));
}
a:after {
content: "";
position: absolute;
bottom: -2px;
left: 50%;
width: 0;
height: 2px;
transition: width 0.3s ease-in-out, left 0.3s ease-in-out;
background-color: rgb(var(--mdui-color-primary))
}
a:hover:after {
width: 100%;
left: 0;
}
h1 {
margin-top: 0px !important;
margin-bottom: 20px !important;
}
h2 {
margin-top: 30px !important;
margin-bottom: 15px !important;
}
.container {
min-height: 1rem !important;
}
.menu-link {
color: rgb(var(--mdui-color-on-surface));
}
.menu-link:after {
bottom: -2px;
left: 0;
width: 100%;
height: 2px;
background-color: rgb(var(--mdui-color-primary));
transition: width 0.2s ease-in-out, left 0.2s ease-in-out;
}
.menu-link:hover:after {
width: calc(100% - 20px);
left: 20px;
}
.topbar {
position: fixed !important;
top: 0px;
right: 0px;
left: 0px;
}
.mdui-prose {
margin-left: 50px;
margin-right: 50px;
max-width: 78%;
margin: auto;
left: 0;
right: 0;
}
.toc-drawer {
position: fixed !important;
margin-left: 0px !important;
margin-right: 0px !important;
}
.bottombar {
height: 10em !important;
margin-top: 2em !important;
margin-left: 2em !important;
margin-right: 2em !important;
display: flex !important;
}
.prevpage {
display: flex !important;
font-size: 1.2em !important;
margin-top: 10px !important;
margin-left: 4px !important;
}
.nextpage {
display: flex !important;
font-size: 1.2em !important;
margin-top: 10px !important;
margin-right: 4px !important;
}
hr {
margin-top: 16px !important;
margin-bottom: 16px !important;
}
@media (max-width: 641px) {
.hideonmobile {
display: none !important;
}
}
@media (min-width: 640px) {
.hideonmobile {
display: inline-flex !important;
}
}

50
css/print.css Executable file
View File

@ -0,0 +1,50 @@
#sidebar,
#menu-bar,
.nav-chapters,
.mobile-nav-chapters {
display: none;
}
#page-wrapper.page-wrapper {
transform: none !important;
margin-inline-start: 0px;
overflow-y: initial;
}
#content {
max-width: none;
margin: 0;
padding: 0;
}
.page {
overflow-y: initial;
}
code {
direction: ltr !important;
}
pre > .buttons {
z-index: 2;
}
a, a:visited, a:active, a:hover {
color: #4183c4;
text-decoration: none;
}
h1, h2, h3, h4, h5, h6 {
page-break-inside: avoid;
page-break-after: avoid;
}
pre, code {
page-break-inside: avoid;
white-space: pre-wrap;
}
.fa {
display: none !important;
}

BIN
favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

22
favicon.svg Executable file
View File

@ -0,0 +1,22 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 199.7 184.2">
<style>
@media (prefers-color-scheme: dark) {
svg { fill: white; }
}
</style>
<path d="M189.5,36.8c0.2,2.8,0,5.1-0.6,6.8L153,162c-0.6,2.1-2,3.7-4.2,5c-2.2,1.2-4.4,1.9-6.7,1.9H31.4c-9.6,0-15.3-2.8-17.3-8.4
c-0.8-2.2-0.8-3.9,0.1-5.2c0.9-1.2,2.4-1.8,4.6-1.8H123c7.4,0,12.6-1.4,15.4-4.1s5.7-8.9,8.6-18.4l32.9-108.6
c1.8-5.9,1-11.1-2.2-15.6S169.9,0,164,0H72.7c-1,0-3.1,0.4-6.1,1.1l0.1-0.4C64.5,0.2,62.6,0,61,0.1s-3,0.5-4.3,1.4
c-1.3,0.9-2.4,1.8-3.2,2.8S52,6.5,51.2,8.1c-0.8,1.6-1.4,3-1.9,4.3s-1.1,2.7-1.8,4.2c-0.7,1.5-1.3,2.7-2,3.7c-0.5,0.6-1.2,1.5-2,2.5
s-1.6,2-2.2,2.8s-0.9,1.5-1.1,2.2c-0.2,0.7-0.1,1.8,0.2,3.2c0.3,1.4,0.4,2.4,0.4,3.1c-0.3,3-1.4,6.9-3.3,11.6
c-1.9,4.7-3.6,8.1-5.1,10.1c-0.3,0.4-1.2,1.3-2.6,2.7c-1.4,1.4-2.3,2.6-2.6,3.7c-0.3,0.4-0.3,1.5-0.1,3.4c0.3,1.8,0.4,3.1,0.3,3.8
c-0.3,2.7-1.3,6.3-3,10.8c-1.7,4.5-3.4,8.2-5,11c-0.2,0.5-0.9,1.4-2,2.8c-1.1,1.4-1.8,2.5-2,3.4c-0.2,0.6-0.1,1.8,0.1,3.4
c0.2,1.6,0.2,2.8-0.1,3.6c-0.6,3-1.8,6.7-3.6,11c-1.8,4.3-3.6,7.9-5.4,11c-0.5,0.8-1.1,1.7-2,2.8c-0.8,1.1-1.5,2-2,2.8
s-0.8,1.6-1,2.5c-0.1,0.5,0,1.3,0.4,2.3c0.3,1.1,0.4,1.9,0.4,2.6c-0.1,1.1-0.2,2.6-0.5,4.4c-0.2,1.8-0.4,2.9-0.4,3.2
c-1.8,4.8-1.7,9.9,0.2,15.2c2.2,6.2,6.2,11.5,11.9,15.8c5.7,4.3,11.7,6.4,17.8,6.4h110.7c5.2,0,10.1-1.7,14.7-5.2s7.7-7.8,9.2-12.9
l33-108.6c1.8-5.8,1-10.9-2.2-15.5C194.9,39.7,192.6,38,189.5,36.8z M59.6,122.8L73.8,80c0,0,7,0,10.8,0s28.8-1.7,25.4,17.5
c-3.4,19.2-18.8,25.2-36.8,25.4S59.6,122.8,59.6,122.8z M78.6,116.8c4.7-0.1,18.9-2.9,22.1-17.1S89.2,86.3,89.2,86.3l-8.9,0
l-10.2,30.5C70.2,116.9,74,116.9,78.6,116.8z M75.3,68.7L89,26.2h9.8l0.8,34l23.6-34h9.9l-13.6,42.5h-7.1l12.5-35.4l-24.5,35.4h-6.8
l-0.8-35L82,68.7H75.3z"/>
</svg>
<!-- Original image Copyright Dave Gandy — CC BY 4.0 License -->

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
font/icons.woff2 Normal file

Binary file not shown.

BIN
font/noto.otf Normal file

Binary file not shown.

BIN
font/sourcecodepro.woff2 Normal file

Binary file not shown.

240
index.hbs Executable file
View File

@ -0,0 +1,240 @@
<!DOCTYPE HTML>
<html lang="{{ language }}" dir="{{ text_direction }}" class="mdui-theme-auto" style="height:100%;width:100%">
<head>
<meta NAME="ROBOTS" CONTENT="INDEX,FOLLOW">
<!-- mdbook 内容 -->
<meta charset="UTF-8">
<title>{{ title }}</title>
{{#if is_print }}
<meta name="robots" content="noindex">
{{/if}}
{{#if base_url}}
<base href="{{ base_url }}">
{{/if}}
<!-- 自定义头部 html -->
{{> head}}
<!-- MDUI CSS&JS -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="renderer" content="webkit" />
<link rel="stylesheet" href="{{ ../path_to_root }}theme/css/mdui.css">
<script src="{{ ../path_to_root }}theme/js/mdui.global.js"></script>
<link href="{{ ../path_to_root }}theme/css/icons.css" rel="stylesheet">
<!-- 搜索引擎描述 -->
<meta name="description" content="Study Area CN {{ description }}">
<meta name="theme-color" content="#ffffff">
<meta name="keywords"
content="Study-area, study-area, study-area-cn Study Area CN, study area cn, 酷学园, 酷学园 CN , 酷!学园, netman, linux, mdbook, rockylinux">
<!-- favicon -->
{{#if favicon_svg}}
<link rel="icon" href="{{ ../path_to_root }}favicon.png">
{{/if}}
{{#if favicon_png}}
<link rel="shortcut icon" href="{{ ../path_to_root }}favicon.png">
{{/if}}
{{#if print_enable}}
<link rel="stylesheet" href="{{ path_to_root }}css/print.css" media="print">
{{/if}}
<!-- Highlight.js Stylesheets -->
<link rel="stylesheet" href="{{ ../path_to_root }}theme/css/highlight.min.css">
<script src="{{ ../path_to_root }}theme/js/highlight.min.js"></script>
{{#if mathjax_support}}
<!-- MathJax -->
<script async src="{{ ../path_to_root }}theme/js/mathjax.js"></script>
{{/if}}
<link rel="stylesheet" href="{{ ../path_to_root }}theme/css/page.css">
<!-- 自定义字体 -->
<link href="{{ ../path_to_root }}theme/css/font.css" rel="stylesheet">
</head>
<body style="margin:0;padding:0;">
<!-- 打印页面输出目录 -->
{{#if is_print }}
{{#toc}}{{/toc}}
{{/if}}
<mdui-layout>
{{#unless is_print }}
<!-- 顶栏 -->
<mdui-top-app-bar class="topbar" scroll-behavior="elevate">
<mdui-button-icon icon="menu" id="open-drawer"></mdui-button-icon>
<mdui-button class="hideonmobile" id="open-study-env">实验环境</mdui-button>
<mdui-top-app-bar-title>{{ book_title }}</mdui-top-app-bar-title>
<div style="flex-grow: 1"></div> <!-- 横向填充 -->
<!-- 翻页 -->
<div class="navbtn" style="display: flex;">
{{#previous}}
<mdui-button id="previous—page" class="hideonmobile" href="javascript:void(0);" onclick="prevPage()"
style="margin-right:8px;">上一章</mdui-button>
<a style="display:none;" href="{{ path_to_root }}{{link}}" id="helper_prevpage" class="helper"></a>
{{/previous}}
{{#next}}
<mdui-button id="next—page" class="next—page" href="javascript:void(0);"
onclick="nextPage()">下一章</mdui-button>
<a style="display:none;" href="{{ path_to_root }}{{link}}" id="helper_nextpage"
class="next—pagehelper"></a>
{{/next}}
</div>
<!-- 仓库按钮 -->
{{#if git_repository_url}}
<mdui-button-icon icon="web" href="{{git_repository_url}}"></mdui-button-icon>
{{/if}}
<!-- 打印按钮 -->
{{#if print_enable}}
<mdui-button-icon class="hideonmobile" href="{{ path_to_root }}print.html" title="Print this book"
aria-label="Print this book" icon="print">
</mdui-button-icon>
{{/if}}
</mdui-top-app-bar>
<!-- 菜单栏 -->
<mdui-navigation-drawer close-on-overlay-click class="toc-drawer" id="toc-drawer" placement="left">
<!-- JS 填充内容 -->
</mdui-navigation-drawer>
{{/unless}}
{{#unless is_print }}
<!-- Render toc -->
<div style="display:none;" id="helperframe" class="helperframe">
{{#toc}}{{/toc}}
</div>
<script src="{{ ../path_to_root }}theme/js/tocrender.js"></script>
<!-- Render toc finish -->
{{/unless}}
<!-- 展开菜单按钮 -->
{{#unless is_print }}
<script>
const navigationDrawer = document.querySelector(".toc-drawer");
const openButton = document.getElementById("open-drawer");
openButton.addEventListener("click", () => navigationDrawer.open = !navigationDrawer.open);
</script>
{{/unless}}
<!-- 主要内容 -->
<mdui-layout-main class="example-layout-main" style="min-height: 100%">
<!-- 内容区 -->
<div class="mdui-prose">
{{{ content }}}
</div>
<!-- 学习环境页面 -->
{{#unless is_print }}
<mdui-dialog headline="Study Env" close-on-esc close-on-overlay-click id="study-env-dialog">
<iframe src="about:blank" style="height:80%;width:99%" id="study-env-iframe"></iframe>
</mdui-dialog>
<script>
document.getElementById("open-study-env").addEventListener("click", () => {
document.getElementById("study-env-dialog").open = true
document.getElementById("study-env-iframe").src = "http://jslinux.cxykevin.top"
});
</script>
{{/unless}}
<!-- 下部翻页按钮 -->
<div class="navcard" style="height:10em;display:flex;max-width: 78%;margin: auto;margin-top:2em;">
{{#previous}}
<mdui-card clickable style="width:49%;height: 100%" href="javascript:void(0);" onclick="prevPage()">
<div style="display:flex;font-size:1.2em;margin-top: 10px;margin-left: 4px;">
<mdui-icon name="navigate_before" style="font-size:1.5em;"></mdui-icon> 上一章
</div>
<div style="text-align:center;font-size:1.8em;margin-top: 12px;">
{{title}}
</div>
</mdui-card>
{{/previous}}
<div style="flex-grow:1"></div>
{{#next}}
<mdui-card clickable style="width:49%;height: 100%" href="javascript:void(0);" onclick="nextPage()">
<div style="display:flex;font-size:1.2em;margin-top: 10px;margin-right: 4px;">
<div style="flex-grow:1"></div>下一章<mdui-icon name="navigate_next"
style="font-size:1.5em"></mdui-icon>
</div>
<div style="text-align:center;font-size:1.8em;margin-top: 12px;">
{{title}}
</div>
</mdui-card>
{{/next}}
</div>
</mdui-layout-main>
<!-- 动态更新内容 -->
{{#if live_reload_endpoint}}
<!-- Livereload script (if served using the cli tool) -->
<script>
const wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:';
const wsAddress = wsProtocol + "//" + location.host + "/" + "{{{live_reload_endpoint}}}";
const socket = new WebSocket(wsAddress);
socket.onmessage = function (event) {
if (event.data === "reload") {
socket.close();
location.reload();
}
};
window.onbeforeunload = function () {
socket.close();
}
</script>
{{/if}}
{{#if is_print}}
{{#if mathjax_support}}
<script>
window.addEventListener('load', function () {
MathJax.Hub.Register.StartupHook('End', function () {
window.setTimeout(window.print, 100);
});
});
</script>
{{else}}
<script>
window.addEventListener('load', function () {
window.setTimeout(window.print, 100);
});
</script>
{{/if}}
{{/if}}
</mdui-layout>
<!-- 留白 -->
<div style="height:2em"></div>
<!-- 高亮 -->
<script>
window.addEventListener('load', function () {
hljs.highlightAll();
});
</script>
<!-- 页面 JS -->
<script src="{{ ../path_to_root }}theme/js/page.js"></script>
</body>
</html>

1213
js/highlight.min.js vendored Normal file

File diff suppressed because one or more lines are too long

19
js/mathjax.js Normal file

File diff suppressed because one or more lines are too long

22
js/mdui.global.js Normal file

File diff suppressed because one or more lines are too long

110
js/page.js Normal file
View File

@ -0,0 +1,110 @@
if (window.innerWidth > 640) { // 自动展开导航栏
document.getElementById("toc-drawer").setAttribute('open', true);
}
// 细节修复
function update_text() {
console.log(1)
// 修复 table
var tables = document.getElementsByTagName("table")
if (tables != undefined) {
for (let i = 0; i < tables.length; i++) {
tables[i].parentNode.classList.add('mdui-table');
}
}
// 修复 hr
var hrs = document.getElementsByTagName("hr")
if (hrs != undefined) {
for (let i = 0; i < hrs.length; i++) {
hrs[i].replaceWith(document.createElement("mdui-divider"));
}
}
}
function prevPage() {
var link = document.getElementById("helper_prevpage").href;
console.log("prev page:", link);
changePage(link);
}
function nextPage() {
var link = document.getElementById("helper_nextpage").href;
console.log("next page:", link);
changePage(link);
}
function setPage(url) { // 菜单跳转事件
if (url === "") {
return;
}
console.log("set page:", url);
changePage(url);
}
function changePage(url) {
// 加载图标
var nextbtn = document.getElementsByClassName("next—page")[0]
if (nextbtn != undefined) {
nextbtn.setAttribute("loading", "");
}
// 发送 XHR 动态更新
const xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState !== 4) return; // 加载失败
if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) {
// 滚动到顶部
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
// 更新内容与翻页按钮
var old_tag = document.getElementsByClassName("mdui-prose")[0];
var old_topbar_tag = document.getElementsByClassName("navbtn")[0];
var old_navcard_tag = document.getElementsByClassName("navcard")[0];
var virtualtag = document.createElement('div');
virtualtag.insertAdjacentHTML('beforeend', xhr.responseText);
var title = virtualtag.getElementsByTagName("title")[0].innerText;
old_tag.innerHTML = virtualtag.getElementsByClassName("mdui-prose")[0].innerHTML;
old_topbar_tag.innerHTML = virtualtag.getElementsByClassName("navbtn")[0].innerHTML;
old_navcard_tag.innerHTML = virtualtag.getElementsByClassName("navcard")[0].innerHTML;
// 更新导航栏当前选择的内容
var elements = document.querySelectorAll('[active]');
elements.forEach(element => {
element.removeAttribute('active');
});
var elementshighliht = document.querySelectorAll('[search_link="' + url + '"]');
elementshighliht.forEach(element => {
element.setAttribute('active', "true");
});
// 清除临时标签
virtualtag.remove();
// 添加历史记录
history.pushState({ page: title }, title, url);
// 刷新高亮
hljs.highlightAll();
// 修复内容
update_text();
}
};
// 发送 XHR
xhr.open('GET', url, true);
xhr.send(null);
}
// 当回到上一页时
window.addEventListener('popstate', function (event) {
console.log('pop state:', window.location.protocol + "//" + window.location.host + location.pathname);
changePage(window.location.protocol + "//" + window.location.host + location.pathname);
});
update_text();

94
js/tocrender.js Normal file
View File

@ -0,0 +1,94 @@
// 获取当前 toc 内容
var toc_obj = document.getElementById("helperframe").getElementsByTagName("ol")[0]
// html 转目录树
function createTree(elements) {
let result = [];
last = 0
elements.childNodes.forEach(element => {
// 有子元素并且不是大标题
if (element.childNodes.length > 0 && (!element.classList.contains("part-title"))) {
let a = element.childNodes[0]
let link = a.tagName === 'A' ? a.href : '' // 获取链接,没有的就是目录
if (link == '') { // 目录
if (a.tagName === 'DIV') { // 目录不可点击
result.push({
link: "#",
text: a.textContent,
child: [],
avtive: false
})
} else { // 目录可点击
result[result.length - 1].child = createTree(element.getElementsByTagName("ol")[0])
}
} else { // 文章
result.push({
link: link,
text: a.innerText,
child: [],
active: element.childNodes[0].classList.contains("active") // 当前选中的
})
}
} else if (element.classList.contains("part-title")) { // 大标题
result.push({
link: "",
text: `<h3 style="margin-top: 0px;margin-bottom:0;margin-left:0rem;"><strong>` + element.textContent + "</strong></h3>",
child: [],
active: false
})
}
});
return result
}
// 目录结构树生成新html的dfs部分
function loadTreeItem(treeitem, v) {
var active_str = treeitem.active ? "active" : "" // 是否是当前文章
if (treeitem.child.length > 0) { // 目录
// 添加头部模板
var i_str = `<mdui-collapse-item value=item"` + v.toString() + `">
<mdui-list-item rounded slot="header" search_link="` + treeitem.link + `" ` + active_str + `><a href="javascript:void(0);" onclick="setPage('` + treeitem.link + `')" class="menu-link">` + treeitem.text + `</a><mdui-icon slot="end-icon" name="keyboard_arrow_down"></mdui-icon></mdui-list-item>
<div style="margin-left: 1rem">
<mdui-list-item rounded>
<mdui-collapse>`
var i = 0
treeitem.child.forEach(element => { // 拼接每级目录
i_str = i_str + loadTreeItem(element, i)
i++
})
// 添加尾部模板
i_str = i_str + `</mdui-collapse>
</mdui-list-item>
</div>
</mdui-collapse-item>`
return i_str
} else { // 文章
disabled = treeitem.link === '#' ? "disabled" : ""
return `<mdui-collapse-item><mdui-list-item rounded search_link="` + treeitem.link + `" ` + active_str + ` slot="header" ` + disabled + ` href="javascript:void(0);" onclick="setPage('` + treeitem.link + `')">` + treeitem.text + `</mdui-list-item></mdui-collapse-item>`
}
}
// 目录结构树生成新html
function getResult(obj) {
var get_tree = createTree(obj)
var n_str = `<mdui-list><mdui-collapse>`
var i = 0
get_tree.forEach(element => {
n_str = n_str + loadTreeItem(element, i)
i++
})
n_str = n_str + `</mdui-collapse></mdui-list>`
return n_str
}
// 插入内容
document.getElementById("toc-drawer").insertAdjacentHTML('beforeend', getResult(toc_obj));
// 移除 toc
document.getElementById("helperframe").remove()
// 终端内容
console.info(" _____ __ __ ___ _______ __ \n / ___// /___ ______/ /_ __/ | ________ ____ _/ ____/ | / / \n \\__ \\/ __/ / / / __ / / / / /| | / ___/ _ \\/ __ `/ / / |/ / \n ___/ / /_/ /_/ / /_/ / /_/ / ___ |/ / / __/ /_/ / /___/ /| / \n/____/\\__/\\__,_/\\__,_/\\__, /_/ |_/_/ \\___/\\__,_/\\____/_/ |_/ \n /____/ \n欢迎来到 Study Area CN! \nstudy-area.org.cn \n")
console.info("本站使用mdbook生成gitea action自动构建 \n恭喜你发现了彩蛋")
console.info("欢迎参与我们的开源项目! https://git.hmtsai.cn/study-area-cn/study-area-cn")
console.info("=====================================")