This repository was archived by the owner on Aug 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgenerate-index.py
51 lines (41 loc) · 1.69 KB
/
generate-index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from pathlib import Path
current_path = Path(".").absolute()
def output(depth: int, content: str):
print(" "*depth + content)
def process_path(path: Path, depth: int = 0):
for dir in reversed([d for d in path.iterdir() if d.is_dir()]):
if depth == 0:
output(depth + 1, "<h2>" + dir.name + "</h2>")
else:
output(depth + 1, "<li><button onClick=\"document.getElementById('frame').src = '/" + str(dir.relative_to(".")) + "';\">" + dir.name + "</button></li>")
output(depth, "<ul>")
process_path(dir, depth + 1)
output(depth, "</ul>")
def main():
print("<!DOCTYPE html>")
print("<head>")
print("<title>V2Ray Protobuf Documentation</title>")
print("""<style>
* {box-sizing: border-box; list-style: circle;}
div {height: 100%;}
button {}
.container {display: table; width: 100%; height: 100%;}
.left-half {position: absolute; left: 0px; width: 20%; border-right: 1px solid grey; overflow-y: scroll; margin-left: 10px; margin-right: 10px;}
.right-half {position: absolute; right: 0px; width: 80%;}
iframe {width: 100%; height: 100%; border: none; margin-left: 20px}
</style>
""")
print("</head>")
print("<body class\"container\" style=\"overflow-x: hidden; overflow-y: hidden\">")
print("<div class=\"left-half\">")
print("<li><button onClick=\"document.getElementById('frame').src = '/main.html';\">V2Ray Root</button></li>")
process_path(Path("."))
print("</div>")
print("<div class=\"right-half\">")
print('<iframe id="frame" src="main.html"></iframe>')
print("</div>")
print("</body>")
print("</html>")
pass
if __name__ == "__main__":
main()