This commit is contained in:
2024-10-14 09:25:55 +02:00
parent 2c78917894
commit 6ecabb9ffa

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
VERSION="v0.9"
VERSION="v0.8"
red="\033[1;31m"
greenbold="\033[1;32m"
@@ -15,13 +15,13 @@ reset="\033[0m"
dotenv () {
set -a
# shellcheck disable=SC1091
[ -f ".env" ] && . ".env" || echo -e "${red}\nNo .env file found ! No token for gotify.${reset}"
[ -f ".env" ] && . ".env" || echo -e "${red}\nNo .env file found ! Could'nt get update from Github.'.${reset}"
set +a
}
dotenv
### ChangeNotes: .
### ChangeNotes: Minor corrections.
Github="https://github.com/bruno21/bashbirds"
# Repo normal:
#RawUrl="https://raw.githubusercontent.com/Bruno21/bashbirds/main/bashbirds.sh"
@@ -36,7 +36,8 @@ ScriptWorkDir="$(dirname "$ScriptPath")" # /Users/bruno/Documents/Scripts/bashbi
### Check if there's a new release of the script:
LatestRelease="$(curl -s -r 0-50 $RawUrl | sed -n "/VERSION/s/VERSION=//p" | tr -d '"')"
LatestChanges="$(curl -s -r 0-200 $RawUrl | sed -n "/ChangeNotes/s/### ChangeNotes: //p")"
echo $LatestRelease
#[[ $LatestRelease != $VERSION ]] && new="($LatestRelease)" || new=""
echo -e "${yellowbold}Bashbird${reset} $VERSION\n"
@@ -74,16 +75,28 @@ req2() {
[[ $aut != "" ]] && z="($aut)" || z=""
if [ $ext = ".md" ]; then
echo "| $fr $z |" >>"$f"
echo "|--------------------------------------------------|" >>"$f"
echo "| $lat |" >> "$f"
echo "| $en |" >> "$f"
echo "| $or |" >> "$f"
echo "| $fa |" >> "$f"
echo "| $ln |" >> "$f"
echo "" >> "$f"
#echo "| $fr $z |" >>"$f"
#echo "|--------------------------------------------------|" >>"$f"
#echo "| $lat |" >> "$f"
#echo "| $en |" >> "$f"
#echo "| $or |" >> "$f"
#echo "| $fa |" >> "$f"
#echo "| $ln |" >> "$f"
#echo "" >> "$f"
bird+="| $fr $z |\n"
bird+="|--------------------------------------------------|\n"
bird+="| $lat |\n"
bird+="| $en |\n"
bird+="| $or |\n"
bird+="| $fa |\n"
bird+="| $ln |\n"
bird+=" \n"
elif [ $ext = ".html" ]; then
firstletter="${fr:0:1}"
firstletter="${fr:0:1}"
if [ $firstletter != $old_index ]; then
index+=("$firstletter")
@@ -116,12 +129,19 @@ req2() {
bird="$z"
html
elif [ $ext = ".md" ]; then
echo -e "${yellow}Exporting markdown file...${reset}"
echo "$bird" > "liste_oiseaux$ext"
fi
exit 0
}
html() {
echo -e "${yellow}Exporting html file...${reset}"
cat > liste_oiseaux.html << EOF
<!DOCTYPE html>
<html>
@@ -222,7 +242,11 @@ req1() {
request="";
fi
query1="SELECT * FROM liste WHERE Francais LIKE \"%$request%\" OR Autres LIKE \"%$request%\" OR Latin LIKE \"%$request%\"";
# COLLATE NOCASE, COLLATE UNICODE
# SELECT column FROM table WHERE UNICODE(column) = UNICODE('café');
query1="SELECT * FROM liste WHERE Francais LIKE \"%$request%\" OR Autres LIKE \"%$request%\" OR Latin LIKE \"%$request%\" COLLATE NOACCENTS";
#query1="SELECT * FROM liste WHERE UNICODE(Francais) = UNICODE('$request')"; # OR Autres LIKE \"%$request%\" OR Latin LIKE \"%$request%\"";
echo "$query1"
result1=$(sqlite3 ./birds.db "$query1")
if [ -n "$result1" ]; then