Skip to content

Commit c1d8b06

Browse files
committed
update repo layout
1 parent e2d3027 commit c1d8b06

File tree

111 files changed

+958
-4
lines changed

Some content is hidden

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

111 files changed

+958
-4
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
book
1+
en/book
2+
zh-CN/book
23
.DS_Store
File renamed without changes.

en/assets/custom.js

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
(function() {
2+
var path = window.location.pathname;
3+
if (path.endsWith("/print.html")) {
4+
return;
5+
}
6+
7+
var images = document.querySelectorAll("main img")
8+
Array.prototype.forEach.call(images, function(img) {
9+
img.addEventListener("click", function() {
10+
BigPicture({
11+
el: img,
12+
});
13+
});
14+
});
15+
16+
// Un-active everything when you click it
17+
Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function(el) {
18+
el.addEventHandler("click", function() {
19+
Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function(el) {
20+
el.classList.remove("active");
21+
});
22+
el.classList.add("active");
23+
});
24+
});
25+
26+
var updateFunction = function() {
27+
28+
var id;
29+
var elements = document.getElementsByClassName("header");
30+
Array.prototype.forEach.call(elements, function(el) {
31+
if (window.pageYOffset >= el.offsetTop) {
32+
id = el;
33+
}
34+
});
35+
36+
Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function(el) {
37+
el.classList.remove("active");
38+
});
39+
40+
Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function(el) {
41+
if (id.href.localeCompare(el.href) == 0) {
42+
el.classList.add("active");
43+
}
44+
});
45+
};
46+
47+
// Populate sidebar on load
48+
window.addEventListener('load', function() {
49+
var pagetoc = document.getElementsByClassName("pagetoc")[0];
50+
var elements = document.getElementsByClassName("header");
51+
Array.prototype.forEach.call(elements, function(el) {
52+
var link = document.createElement("a");
53+
54+
// Indent shows hierarchy
55+
var indent = "";
56+
switch (el.parentElement.tagName) {
57+
case "H1":
58+
return;
59+
// case "H2":
60+
// indent = "20px";
61+
// break;
62+
case "H3":
63+
indent = "20px";
64+
break;
65+
case "H4":
66+
indent = "40px";
67+
break;
68+
default:
69+
break;
70+
}
71+
72+
link.appendChild(document.createTextNode(el.text));
73+
link.style.paddingLeft = indent;
74+
link.href = el.href;
75+
pagetoc.appendChild(link);
76+
});
77+
updateFunction.call();
78+
});
79+
80+
// Handle active elements on scroll
81+
window.addEventListener("scroll", updateFunction);
82+
83+
var p = path.replace("index.html", "");
84+
p = p.replace(".html", "");
85+
var strs = p.split("/");
86+
if (strs[strs.length-1] == ""){
87+
strs.pop()
88+
}
89+
var str = strs[strs.length-1];
90+
var title = document.querySelector("main>h1,h2>a").textContent
91+
var gitalk = new Gitalk({
92+
clientID: '8e4b2cf9529ebb3dcad6',
93+
clientSecret: '6f6e8c23575a780bdb1faba3c17be08d76dc35f8',
94+
repo: 'rust-by-practice-comments',
95+
owner: 'sunface',
96+
admin: ["sunface"],
97+
labels: ['comments'],
98+
title: title,
99+
createIssueManually: false,
100+
id: str,
101+
distractionFreeMode: true
102+
});
103+
gitalk.render('gitalk-container');
104+
})();
File renamed without changes.

book.toml renamed to en/book.toml

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ enable = true
1313
level = 1
1414

1515
[output.html]
16+
additional-css = ["theme/style2.css"]
17+
additional-js = ["assets/custom.js"]
1618
git-repository-url = "https://github.com/sunface/rust-by-practice"
1719
edit-url-template = "https://github.com/sunface/rust-by-practice/edit/master/{path}"
1820

deploy.sh renamed to en/deploy.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ git remote add origin https://github.com/sunface/rust-by-practice
2121
git push -u -f origin gh-pages
2222

2323
## deploy zh-CN
24-
cd ../zh-CN
24+
cd ../../zh-book
2525
./deploy
File renamed without changes.

0 commit comments

Comments
 (0)