Files
luci/applications/luci-app-olsr-viz/root/usr/libexec/rpcd/olsrvizinfo
Mustafa Can Elmacı ae8bbb814f treewide: HTML Cleanup
* HTML Cleanup: Meta tags.
* Converted charset to shorthand.
* Removed meta tags with `Content-Script-Type` attribute. (Invalid in HTML5 spec.)

* HTML Cleanup: CSS tags.
* Removed `type` attribute with CSS files from link tags. (HTML5 spec recommends omitting it.)
* Removed `type` attribute from style tags. (Deprecated in HTML5 spec.)
https://html.spec.whatwg.org/#attr-link-type
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style

* HTML Cleanup: Convert from XHTML to HTML5
* Removed XML declaration.
* Removed XML namespace.
* Changed doctype to HTML5.

* HTML Cleanup: CDATA tags.
* CDATA sections should not be used within HTML they are considered as comments and not displayed.
https://developer.mozilla.org/en-US/docs/Web/API/CDATASection

* HTML Cleanup: Script tags.
* Removed `language` attribute from script tags. (No longer valid in HTML5)
* Removed `type` attribute with JavaScript MIME type from script tags. (HTML5 spec recommends omitting it.)
https://html.spec.whatwg.org/multipage/scripting.html#attr-script-type
https://mimesniff.spec.whatwg.org/#javascript-mime-type

Signed-off-by: Mustafa Can Elmacı <mustafacan@elmaci.net>
2024-11-22 22:39:46 +01:00

60 lines
1.3 KiB
Bash

#!/bin/sh
. /usr/share/libubox/jshn.sh
case "$1" in
list)
json_init
json_add_object "getolsrvizdata"
json_close_object
json_dump
;;
call)
case "$2" in
getolsrvizdata)
jsonreq4=$(
cat <<EOF
<script>
EOF
# sed + txtinfo plugin
re_ip='[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}'
re_sep='[[:space:]]\{1,\}'
re_nosep='[^[:space:]]\{1,\}'
wget http://127.0.0.1:2006/all -qO - | sed -n "
/^Table: Links$/,/^$/ {
s# # - #g
s#\($re_ip\)$re_sep\($re_ip\)\($re_sep$re_nosep\)\{3\}$re_sep\($re_nosep\)#touch_edge(touch_node('\1').set_metric(1).update(),touch_node('\2').set_metric(1).update(),'\4');#p
}
/^Table: Topology$/,/^$/ {
s#\($re_ip\)$re_sep\($re_ip\)\($re_sep$re_nosep\)\{2\}$re_sep\($re_nosep\)#touch_edge(touch_node('\1').update(),touch_node('\2').update(),'\4');#p
}
/^Table: HNA$/,/^$/ {
s#\($re_ip\)/\([0-9]\{1,\}\)$re_sep\($re_ip\)#touch_hna(touch_node('\3'),'\1','\2');#p
}
/^Table: Routes$/,/^$/ {
s#\($re_ip\)/32$re_sep$re_nosep$re_sep\($re_nosep\).*#touch_node('\1').set_metric('\2').update();#p
}
"
hosts=$(uci show olsrd | grep hosts_file | cut -d "=" -f 2)
if [ -n $hosts ]; then
sed -n "
s#\($re_ip\)$re_sep\($re_nosep\)$re_sep.*#touch_node('\1').set_desc('\2');#p
" <$hosts
fi
cat <<EOF
viz_callback();
</script>
EOF
)
json_init
json_add_string "jsonreq4" "$jsonreq4"
json_dump
;;
esac
;;
esac