-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgen-downloads.sh
executable file
·96 lines (86 loc) · 2.17 KB
/
gen-downloads.sh
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
ROOT_PATH=docs
OUTPUT=index.html
FILTER_FILES=[html,sh,jpg,jpeg,ico,png]
function scandir(){
local parent=$1
if [ -n "$parent" ]; then
parent="$parent/"
fi
# scan files
for file in `ls $parent`; do
local path="$parent$file"
local ext=${file##*.}
if [[ " ${FILTER_FILES[*]} " == *"$ext"* ]]; then
echo Skipping $file ...
elif [ -f "$path" ]; then
local size=`du -sh $path | awk '{print $1}'`
echo ' <li>' >> $OUTPUT
echo ' <a href="'$path'">'$path'</a>' >> $OUTPUT
echo ' <span style="font-size:12px;color:#909090"> '$size'</span>' >> $OUTPUT
echo ' </li>' >> $OUTPUT
fi
done
# scan dirs
for file in `ls $parent`; do
local path="$parent$file"
if [ -d "$path" ]; then
echo ' <br/>' >> $OUTPUT
scandir "$path"
fi
done
}
cd $ROOT_PATH
# header
echo '<!DOCTYPE html><html>
<head>
<meta charset="UTF-8">
<title>HugeGraph downloads</title>
<style type="text/css">
body,td,th {
font-family: Verdana,Arial,Helvetica,sans-serif;
font-size: 15px;
color: #1d1007;
line-height: 24px;
}
html, body {
height: 100%;
}
.wrapper {
position: relative;
min-height: calc(100% - 32px);
padding-bottom: 32px;
box-sizing: border-box;
}
.footer {
position: absolute;
bottom: 0;
height: 32px;
width: 100%;
text-align: center;
line-height: 32px;
font-size: 14px;
}
</style>
<link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
</head>
<body> <div class="wrapper">
<div class="content">
<div>
<a href="https://hugegraph.github.io/hugegraph-doc/"><img src="images/logo.png" style="vertical-align:middle;" height="32" alt="HugeGraph Database"/></a>
<span style="font-size:28px;vertical-align:middle">HugeGraph downloads</span>
</div>
<ul>' > $OUTPUT
# body
scandir
# footer
echo '
</ul>
</div>
<div class="footer">
<p>Contact information: <a href="mailto:[email protected]">[email protected]</a></p>
</div>
</div>
</body>
</html>' >> $OUTPUT
echo Successfully generated downloads file: $OUTPUT