forked from gcoop-libre/freeipa-sssd-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathipa-sss-htm
executable file
·135 lines (93 loc) · 2.52 KB
/
ipa-sss-htm
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
# This script comes with ABSOLUTELY NO WARRANTY, use at own risk
# Copyright (C) 2022 Osiris Alejandro Gomez <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# shellcheck disable=SC1090
# shellcheck disable=SC1091
DIR_BIN="$(dirname "$0")" && source "$DIR_BIN/ipa-src-cfg"
function usage()
{
cat << EOF
## \`$BIN\` Generate HTML gallery of SynLog Plots Images
### Usage
\`\`\`bash
$BIN
\`\`\`
### Description
Generate HTML gallery of SynLog Plots Images
EOF
exit 0
}
[[ "$1" =~ ^[-]+(h|help) ]] && usage
function validate()
{
[[ -z "$HTM_CSS" ]] && cfg 'HTM_CSS'
[[ -z "$HTM_DIR" ]] && cfg 'HTM_DIR'
[[ -z "$HTM_INDEX" ]] && cfg 'HTM_INDEX'
[[ -z "$HTM_TITLE" ]] && cfg 'HTM_TITLE'
[[ -z "$HTM_TPL" ]] && cfg 'HTM_TPL'
[[ -z "$HTM_TOP" ]] && cfg 'HTM_TOP'
[[ -d "$HTM_DIR" ]] || die "NOT FOUND DIR $HTM_DIR"
[[ -e "$HTM_TPL" ]] || HTM_TPL="$DIR_BIN/$HTM_TPL"
[[ -e "$HTM_TPL" ]] || die "NOT FOUND FILE $HTM_TPL"
[[ -e "$HTM_DIR/$HTM_CSS" ]] || die "NOT FOUND FILE $HTM_DIR/$HTM_CSS"
}
function png2href()
{
cd "$HTM_DIR/img" || exit 1
find . -type f -iname '*.png' \
| cut -d/ -f2- \
| sort -nr \
| head -n "$HTM_TOP" \
| while read -r F
do
N="$(basename "$F")"
D="$(echo "$N" | cut -c -10)"
#FIXME split by week
cat << EOF
<div class="row">
<div class="col-sm">
<a href="img/$F"><img src="img/$F" alt="$D"/></a>
</div>
</div>
EOF
done
}
function header()
{
cat << EOF
<header>
<a href="#" class="logo">$HTM_TITLE</a>
</header>
EOF
}
function html()
{
HTML="$(cat "$HTM_TPL")"
HTML="${HTML//<!--=@title-->/${HTM_TITLE}}"
HTML="${HTML//<!--=@css-->/${HTM_CSS}}"
HEADER="$(header)"
HTML="${HTML//<!--+@header-->/${HEADER}}"
CONTENT="$(png2href)"
HTML="${HTML//<!--+@content-->/${CONTENT}}"
echo "$HTML" > "$HTM_DIR/$HTM_INDEX"
}
function main()
{
config
validate
html
}
main