webbuild-functions: replace Google hint search with ChatGPT

This commit is contained in:
Silvan Calarco 2024-11-01 09:38:42 +01:00
parent ef2a739df4
commit 1d35f4fe2b

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# #
# webbuild functions # webbuild functions
# Copyright (c) 2012-2014 by Silvan Calarco <silvan.calarco@mambasoft.it> # Copyright (c) 2012-2024 by Silvan Calarco <silvan.calarco@mambasoft.it>
# #
. /etc/autodist/config . /etc/autodist/config
@ -273,10 +273,10 @@ function parse_build_output() {
s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|; s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|;
s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|; s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;
s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|; s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;
s|\(.*\)\(error[^0-9A-Za-z]*:[[:space:]]*.*\)|<span class=\"outputboxerror\">\1<a %SRCURL%\2%SRCURLEND%>\2</a></span>|i; s|\(.*\)\(^.*error[^0-9A-Za-z]*:[[:space:]]*.*\)|<span class=\"outputboxerror\">\1<a %SRCURL%\2%SRCURLEND%>\2</a></span>|i;
s|^\(== =.*\)|<span class=\"outputboxok\">\1</span>|; s|^\(== =.*\)|<span class=\"outputboxok\">\1</span>|;
s|^[[:cntrl:]]*\([!%?=][!%!=>] .*\)|<font style=\"color:gold\">\1</font>|; s|^[[:cntrl:]]*\([!%?=][!%!=>] .*\)|<font style=\"color:gold\">\1</font>|;
s|[[:cntrl:]]||g;" | iconv -c | google_search $1 s|[[:cntrl:]]||g;" | iconv -c | hint_search $1
} }
function parse_generic_output() { function parse_generic_output() {
@ -288,17 +288,18 @@ function parse_generic_output() {
s|&lt;/font|</font|g; s|&lt;/font|</font|g;
s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|; s|^\([\+#] .*\)|<font style=\"color:cyan\">\1</font>|;
s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|; s|\(ftp[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;
s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;" | google_search $1 s|\(http[s]*://[[:alnum:]+\,:&?/_.=~%#-]*\)|<a href=\1 target=new>\1</a>|;" | hint_search $1
} }
function google_search() { function hint_search() {
while read line; do while read line; do
if [ "${line/\%SRCURL\%}" == "${line}" ]; then if [ "${line/\%SRCURL\%}" == "${line}" ]; then
echo "$line" echo "$line"
else else
local SEARCH_STRING=`echo "$line" | sed "s|.*%SRCURL%\(.*\)%SRCURLEND%.*|\1|;s|\&lt;|<|"` local SEARCH_STRING=`echo "$line" | sed "s|.*%SRCURL%\(.*\)%SRCURLEND%.*|\1|;s|\&lt;|<|"`
local SEARCH_STRING_ENCODED=`cgi_encodevar "$1 $SEARCH_STRING"` local SEARCH_STRING_ENCODED=`cgi_encodevar "I get this error while building $1: $SEARCH_STRING"`
echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"https://www.google.com/search?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Search this error on the Web\"|g" #echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"https://duckduckgo.gom/?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Search this error on the Web\"|g"
echo "$line" | sed "s|%SRCURL%.*%SRCURLEND%|href=\"https://chatgpt.com/?q=$SEARCH_STRING_ENCODED\" target=_new title=\"Query ChatGPT on this error\"|g"
fi fi
done done
} }