-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhtml.sh
executable file
·77 lines (69 loc) · 1.69 KB
/
html.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
#!/usr/bin/env bash
set -eu
print_emoji() {
file_type=$(file -b "$1")
case "$file_type" in
*PDF*) echo "📖";;
*Audio*) echo "🎧";;
*Media*) echo "🎬";;
*image*) echo "🖼️";;
*text*) echo "📄";;
*directory*) echo "📁";;
*executable*) echo "🚀";;
*compressed*) echo "📦";;
*) echo "❓";;
esac
}
src=$(dirname "$0")
if [ -f $src/vars.sh ]; then
source $src/vars.sh
else
echo "vars.sh: not found"
exit
fi
cd $1
root=$(pwd)
for dir in $(find $root -type d -not -path "$root/.*" -not -name ".*"); do
cd $dir
cat << EOF > $HTMLFILE
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="author" content="$AUTHOR" />
<link rel="stylesheet" href="$BASEURL/style.css" />
<link rel="alternate" type="application/rss+xml" title="$TITLE" href="$BASEURL/$RSSFILE"/>
<!-- <link rel="icon" type="image/x-icon" href="$BASEURL/icon.ico"> -->
<title>$TITLE</title>
</head>
<body>
<h1>$TITLE</h1>
EOF
for item in $(find ./ -maxdepth 1 -mindepth 1 -type d -exec basename {} \; | sort) \
$(find ./ -maxdepth 1 -mindepth 1 -type f -exec basename {} \; | sort); do
if [[ "$item" == .* ]]; then
echo "skipping hidden: $item"
continue
fi
if [[ "${IGNORED_FILES[*]}" =~ "$item" ]]; then
echo "skipping ignored: $item"
continue
fi
cat << EOF >> $HTMLFILE
<a href="$BASEURL${dir/$root/}/$item">$(print_emoji $item)$item</a><br>
EOF
done
cat << EOF >> $HTMLFILE
<hr>
<p class="notice">
© 2023 $AUTHOR
<span class="right">
<a href="$BASEURL/$RSSFILE">rss</a>
<a href="mailto:$CONTACT">kontakt</a>
</span>
</p>
</body>
</html>
EOF
done