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 LOCAL_ROOT="$HOME/www/mountaineerbr.github.io"
26
27 SITE_ROOT="https://mountaineerbr.github.io"
28
29
30 EXTENSIONS=( htm html php asp aspx jsp )
31
32 EXTENSIONSTREE='*.htm|*.html|*.php|*.asp|*.aspx|*.jsp|sitemap.txt'
33
34
35 EXARR=(
36
37
38
39 '.*google.*'
40
41 '.*/\\..*'
42 '.*/[a-z]/.*'
43 '.*/bak/.*'
44 '.*/css/.*'
45 '.*/gfx/.*'
46 '.*/js/.*'
47 '.*/misc/.*'
48 '.*/PMWMT/.*'
49 '.*/res/.*'
50
51 'index\.html$'
52 '.*/[a-z]\.html$'
53 '.*/fool\.html$'
54 )
55
56 EXTREE='[a-z].html|[a-z]|index.html|fool.html|bak|css|gfx|js|res|misc|google*|PMWMT'
57
58
59
60 SMAPTXT="$LOCAL_ROOT/sitemap.txt"
61
62 SMAPXML="$LOCAL_ROOT/sitemap.xml"
63
64 SMAPTREE="$LOCAL_ROOT/sitemap.html"
65
66
67 SMAPFILES="$LOCAL_ROOT/sitemap.files.txt"
68
69
70 XMLHEAD='<?xml version="1.0" encoding="UTF-8"?>
71 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'
72 XMLTAIL='</urlset>'
73
74
75 HTMLHEAD='<meta http-equiv="content-type" content="text/html; charset=UTF-8">
76 <title>Website map, navigate to all pages</title>
77 <meta name="resource-type" content="document">
78 <meta name="description" content="Site map for human visitors; this navigation page may be preferable for some people to use">
79 <meta name="keywords" content="navigation, navegação, accessibility, acessibilidade, interface, alternativo, alternative, user navigation, navegação de usuário, discover the webste, descubra o website">
80 <meta name="distribution" content="global">
81 <meta name="viewport" content="width=device-width, initial-scale=1.0">
82 <!-- <link rev="made" href="mailto:jamilbio20[[at]]gmail[[dot]]com"> -->
83 <link rel="shortcut icon" href="favicon.ico" type="image/x-icon">'
84
85
86
87
88
89
90 escf()
91 {
92 local url
93
94
95 url="${1/"$LOCAL_ROOT"/"$SITE_ROOT"}"
96
97
98 <<<"$url" sed \
99 -e 's/&/\&/g' \
100 -e "s/'/\'/g" \
101 -e 's/"/\"/g' \
102 -e 's/>/\>/g' \
103 -e 's/</\</g'
104 }
105
106
107
108
109
110
111
112 set -e
113
114
115
116
117
118 cd "$LOCAL_ROOT"
119
120
121 for r in "$SMAPTXT" "$SMAPXML" "$SMAPTREE" "$SMAPFILES"
122 do
123 [[ -f "$r" ]] || continue
124 rm -v "$r"
125 : >"$r"
126 done
127 unset r
128
129
130
131 for ext in "${EXTENSIONS[@]}"
132 do
133 find "$LOCAL_ROOT" \( ! -path '*/.*' \) -name "*.$ext" >>"$SMAPFILES"
134 done
135 unset ext
136
137
138
139
140
141
142
143
144
145 cat >> "$SMAPFILES" <<!
146 $SMAPTXT
147 $SMAPXML
148 $SMAPTREE
149 !
150
151
152
153 empty=""
154 for entry in "${EXARR[@]}"
155 do
156 sed -i -E "s,$entry,$empty,g" "$SMAPFILES"
157 done
158 unset empty entry
159
160
161 sed -i '/^\s*$/d' "$SMAPFILES"
162
163
164 sort -f -V -u -o "$SMAPFILES" "$SMAPFILES"
165
166
167
168
169
170
171
172 sed "s,$LOCAL_ROOT,$SITE_ROOT," "$SMAPFILES" > "$SMAPTXT"
173
174
175
176
177
178
179 {
180
181 echo "$XMLHEAD"
182
183
184 while IFS= read
185 do
186
187 (( ++n ))
188
189
190 URL="$( escf "$REPLY" )"
191
192
193 MOD="$( TZ=0 stat --format="%Y" "$REPLY" )"
194 MOD="$( date -Isec -d@"$MOD" )"
195
196 echo -e '\t<url>'
197 echo -e "\t\t<loc>${URL}</loc>"
198 echo -e "\t\t<lastmod>${MOD}</lastmod>"
199 echo -e '\t</url>'
200
201 done <"$SMAPFILES"
202
203
204 TS="$( date -Isec )"
205
206
207 echo "$XMLTAIL"
208 echo "<!-- generated-on=\"$TS\" -->"
209 echo "<!-- items=\"$n\" -->"
210
211 } >"$SMAPXML"
212 unset REPLY n URL ALT MOD TS
213
214
215
216
217
218
219 rm -v "$SMAPFILES"
220
221
222
223
224
225
226
227
228 tree -H "$SITE_ROOT" -P "$EXTENSIONSTREE" -I "$EXTREE" \
229 -T Sitemap -L 6 -F -v --noreport --charset utf-8 |
230 sed '/<meta/,/<title/ d' > "$SMAPTREE"
231
232
233 sed -i '/<head>/ r /dev/stdin' "$SMAPTREE" <<<"$HTMLHEAD"
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268